public String perform()
{
result.append("\n ");
goto _L1
_L7:
token = tokens.nextToken();
lcToken = token.toLowerCase();
if (!"'".equals(token)) goto _L3; else goto _L2
_L2:
String t = tokens.nextToken();
this.token += t;
if (!"'".equals(t) && tokens.hasMoreTokens()) goto _L2; else goto _L4
_L3:
if (!"\"".equals(token)) goto _L4; else goto _L5
_L5:
t = tokens.nextToken();
this.token += t;
if (!"\"".equals(t)) goto _L5; else goto _L4
_L4:
if (afterByOrSetOrFromOrSelect && ",".equals(token))
commaAfterByOrFromOrSelect();
else
if (afterOn && ",".equals(token))
commaAfterOn();
else
if ("(".equals(token))
openParen();
else
if (")".equals(token))
closeParen();
else
if (BasicFormatterImpl.BEGIN_CLAUSES.contains(lcToken))
beginNewClause();
else
if (BasicFormatterImpl.END_CLAUSES.contains(lcToken))
endNewClause();
else
if ("select".equals(lcToken))
select();
else
if (BasicFormatterImpl.DML.contains(lcToken))
updateOrInsertOrDelete();
else
if ("values".equals(lcToken))
values();
else
if ("on".equals(lcToken))
on();
else
if (afterBetween && lcToken.equals("and"))
{
misc();
afterBetween = false;
} else
if (BasicFormatterImpl.LOGICAL.contains(lcToken))
logical();
else
if (isWhitespace(token))
white();
else
misc();
if (!isWhitespace(token))
lastToken = lcToken;
_L1:
if (tokens.hasMoreTokens()) goto _L7; else goto _L6
_L6:
return result.toString();
}
2 个解决方案
#1
印象中java是支持goto的,只是不建议使用。
不要的话改成条件或循环语句就可以了
不要的话改成条件或循环语句就可以了
#2
result.append( initial );
while ( tokens.hasMoreTokens() ) {
token = tokens.nextToken();
lcToken = token.toLowerCase();
if ( "'".equals( token ) ) {
String t;
do {
t = tokens.nextToken();
token += t;
}
while ( !"'".equals( t ) && tokens.hasMoreTokens() ); // cannot handle single quotes
}
else if ( "\"".equals( token ) ) {
String t;
do {
t = tokens.nextToken();
token += t;
}
while ( !"\"".equals( t ) );
}
if ( afterByOrSetOrFromOrSelect && ",".equals( token ) ) {
commaAfterByOrFromOrSelect();
}
else if ( afterOn && ",".equals( token ) ) {
commaAfterOn();
}
else if ( "(".equals( token ) ) {
openParen();
}
else if ( ")".equals( token ) ) {
closeParen();
}
else if ( BEGIN_CLAUSES.contains( lcToken ) ) {
beginNewClause();
}
else if ( END_CLAUSES.contains( lcToken ) ) {
endNewClause();
}
else if ( "select".equals( lcToken ) ) {
select();
}
else if ( DML.contains( lcToken ) ) {
updateOrInsertOrDelete();
}
else if ( "values".equals( lcToken ) ) {
values();
}
else if ( "on".equals( lcToken ) ) {
on();
}
else if ( afterBetween && lcToken.equals( "and" ) ) {
misc();
afterBetween = false;
}
else if ( LOGICAL.contains( lcToken ) ) {
logical();
}
else if ( isWhitespace( token ) ) {
white();
}
else {
misc();
}
if ( !isWhitespace( token ) ) {
lastToken = lcToken;
}
}
return result.toString();
#1
印象中java是支持goto的,只是不建议使用。
不要的话改成条件或循环语句就可以了
不要的话改成条件或循环语句就可以了
#2
result.append( initial );
while ( tokens.hasMoreTokens() ) {
token = tokens.nextToken();
lcToken = token.toLowerCase();
if ( "'".equals( token ) ) {
String t;
do {
t = tokens.nextToken();
token += t;
}
while ( !"'".equals( t ) && tokens.hasMoreTokens() ); // cannot handle single quotes
}
else if ( "\"".equals( token ) ) {
String t;
do {
t = tokens.nextToken();
token += t;
}
while ( !"\"".equals( t ) );
}
if ( afterByOrSetOrFromOrSelect && ",".equals( token ) ) {
commaAfterByOrFromOrSelect();
}
else if ( afterOn && ",".equals( token ) ) {
commaAfterOn();
}
else if ( "(".equals( token ) ) {
openParen();
}
else if ( ")".equals( token ) ) {
closeParen();
}
else if ( BEGIN_CLAUSES.contains( lcToken ) ) {
beginNewClause();
}
else if ( END_CLAUSES.contains( lcToken ) ) {
endNewClause();
}
else if ( "select".equals( lcToken ) ) {
select();
}
else if ( DML.contains( lcToken ) ) {
updateOrInsertOrDelete();
}
else if ( "values".equals( lcToken ) ) {
values();
}
else if ( "on".equals( lcToken ) ) {
on();
}
else if ( afterBetween && lcToken.equals( "and" ) ) {
misc();
afterBetween = false;
}
else if ( LOGICAL.contains( lcToken ) ) {
logical();
}
else if ( isWhitespace( token ) ) {
white();
}
else {
misc();
}
if ( !isWhitespace( token ) ) {
lastToken = lcToken;
}
}
return result.toString();