Methods Summary |
---|
public static java.lang.String | ANTLRVersion()INTERNAL
Returns the ANTLR version currently used.
return "2.7.3";
|
public void | addError(java.lang.Exception e)INTERNAL
Add the exception to the list of errors.
if (e instanceof ANTLRException) {
e = handleANTLRException((ANTLRException)e);
} else if (!(e instanceof EJBQLException)) {
e = EJBQLException.generalParsingException(getQueryInfo(), e);
}
errors.add(e);
|
public static oracle.toplink.essentials.internal.parsing.EJBQLParseTree | buildParseTree(java.lang.String queryText)INTERNAL
Builds a parser, parses the specified query string and returns the
parse tree. Any error in the query text results in an EJBQLException.
This method is used for dynamic queries.
return buildParseTree(null, queryText);
|
public static oracle.toplink.essentials.internal.parsing.EJBQLParseTree | buildParseTree(java.lang.String queryName, java.lang.String queryText)INTERNAL
Builds a parser, parses the specified query string and returns the
parse tree. Any error in the query text results in an EJBQLException.
EJBQLParser parser = buildParserFor(queryName, queryText);
return parser.parse();
|
public static oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser | buildParserFor(java.lang.String queryText)INTERNAL
Creates a parser for the specified query string. The query string is
not parsed (see method parse).
This method is used for dynamic queries.
return buildParserFor(null, queryText);
|
public static oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser | buildParserFor(java.lang.String queryName, java.lang.String queryText)INTERNAL
Creates a parser for the specified query string. The query string is
not parsed (see method parse).
try {
EJBQLParser parser = EJBQLParserBuilder.buildParser(queryText);
parser.setQueryName(queryName);
parser.setQueryText(queryText);
parser.setNodeFactory(new NodeFactoryImpl(parser.getQueryInfo()));
return parser;
} catch (Exception ex) {
throw EJBQLException.generalParsingException(queryText, ex);
}
|
public abstract void | document()This is the parser start method. It will be implemented by the ANTLR
generated subclass.
|
protected oracle.toplink.essentials.exceptions.EJBQLException | generateException()INTERNAL
Generate an exception which encapsulates all the exceptions generated
by this parser. Special case where the first exception is an
EJBQLException.
//Handle exceptions we expect (such as expressionSotSupported)
Exception firstException = (Exception)getErrors().get(0);
if (firstException instanceof EJBQLException) {
return (EJBQLException)firstException;
}
//Handle general exceptions, such as NPE
EJBQLException exception =
EJBQLException.generalParsingException(getQueryInfo());
exception.setInternalExceptions(getErrors());
return exception;
|
public java.util.List | getErrors()INTERNAL
Returns the list of errors found during the parsing process.
return errors;
|
public oracle.toplink.essentials.internal.parsing.NodeFactory | getNodeFactory()INTERNAL
Returns the factory used by the parser to create a parse tree and parse
tree nodes.
return factory;
|
public oracle.toplink.essentials.internal.parsing.EJBQLParseTree | getParseTree()INTERNAL
Returns the parse tree created by a successful run of the parse
method.
return (EJBQLParseTree)getRootNode();
|
public java.lang.String | getQueryInfo()INTERNAL
Return the the query text prefixed by the query name in case of a
named query. The method returns just the query text in case of a dynamic
query.
return (queryName == null) ? queryText :
queryName + ": " + queryText;
|
public java.lang.String | getQueryName()INTERNAL
Return the name of the current query being compiled. This method returns
null if the current query is a dynamic query and not a named
query.
return queryText;
|
public java.lang.String | getQueryText()INTERNAL
Return the text of the current query being compiled.
return queryText;
|
public abstract java.lang.Object | getRootNode()Returns the root node after representing the parse tree for the current
query string. It will be implemented by the ANTLR generated subclass.
|
protected oracle.toplink.essentials.exceptions.EJBQLException | handleANTLRException(persistence.antlr.ANTLRException ex)INTERNAL
Map an exception thrown by the ANTLR generated code to an
EJBQLException.
EJBQLException result = null;
if (ex instanceof MismatchedCharException) {
MismatchedCharException mismatched = (MismatchedCharException)ex;
if (mismatched.foundChar == EOF_CHAR) {
result = EJBQLException.unexpectedEOF(getQueryInfo(),
mismatched.getLine(), mismatched.getColumn(), ex);
} else if (mismatched.mismatchType == MismatchedCharException.CHAR) {
result = EJBQLException.expectedCharFound(getQueryInfo(),
mismatched.getLine(), mismatched.getColumn(),
String.valueOf((char)mismatched.expecting),
String.valueOf((char)mismatched.foundChar),
ex);
}
}
else if (ex instanceof MismatchedTokenException) {
MismatchedTokenException mismatched = (MismatchedTokenException)ex;
Token token = mismatched.token;
if (token != null) {
if (token.getType() == Token.EOF_TYPE) {
result = EJBQLException.unexpectedEOF(getQueryInfo(),
mismatched.getLine(), mismatched.getColumn(), ex);
}
else {
result = EJBQLException.syntaxErrorAt(getQueryInfo(),
mismatched.getLine(), mismatched.getColumn(),
token.getText(), ex);
}
}
}
else if (ex instanceof NoViableAltException) {
NoViableAltException noviable = (NoViableAltException)ex;
Token token = noviable.token;
if (token != null) {
if (token.getType() == Token.EOF_TYPE) {
result = EJBQLException.unexpectedEOF(getQueryInfo(),
noviable.getLine(), noviable.getColumn(), ex);
}
else {
result = EJBQLException.unexpectedToken(getQueryInfo(),
noviable.getLine(), noviable.getColumn(),
token.getText(), ex);
}
}
}
else if (ex instanceof NoViableAltForCharException) {
NoViableAltForCharException noViableAlt = (NoViableAltForCharException)ex;
result = EJBQLException.unexpectedChar(getQueryInfo(),
noViableAlt.getLine(), noViableAlt.getColumn(),
String.valueOf((char)noViableAlt.foundChar), ex);
}
else if (ex instanceof TokenStreamRecognitionException) {
result = handleANTLRException(((TokenStreamRecognitionException)ex).recog);
}
if (result == null) {
// no special handling from aboves matches the exception if this
// line is reached => make it a syntax error
result = EJBQLException.syntaxError(getQueryInfo(), ex);
}
return result;
|
public boolean | hasErrors()INTERNAL
Returns true if there were errors during the parsing process.
return !getErrors().isEmpty();
|
public oracle.toplink.essentials.internal.parsing.EJBQLParseTree | parse()INTERNAL
Parse the query string that was specified on parser creation.
try {
document();
} catch (Exception e) {
addError(e);
}
// Handle any errors generated by the Parser
if (hasErrors()) {
throw generateException();
}
// return the parser tree
return getParseTree();
|
public void | reportError(persistence.antlr.RecognitionException ex)Method called by the ANTLR generated code in case of an error.
addError(ex);
|
public void | setNodeFactory(oracle.toplink.essentials.internal.parsing.NodeFactory factory)INTERNAL
Set the factory used by the parser to create a parse tree and parse
tree nodes.
this.factory = factory;
|
public void | setQueryName(java.lang.String queryName)INTERNAL
Set the name of the current query being compiled.
Please note, setting the query name using this method is for error
handling and debugging purposes.
this.queryName = queryName;
|
public void | setQueryText(java.lang.String queryText)INTERNAL
Set the text of the current query being compiled.
Please note, setting the query text using this method is for error
handling and debugging purposes.
this.queryText = queryText;
|