org.eigenbase.sql.parser
Class SqlParseException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.eigenbase.sql.parser.SqlParseException
All Implemented Interfaces:
Serializable, EigenbaseParserException

public class SqlParseException
extends Exception
implements EigenbaseParserException

SqlParseException defines a checked exception corresponding to SqlParser.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/parser/SqlParseException.java#20 $
Author:
John V. Sichi
See Also:
Serialized Form

Field Summary
private  int[][] expectedTokenSequences
           
private  Throwable parserException
          The original exception thrown by the generated parser.
private  SqlParserPos pos
           
private  String[] tokenImages
           
 
Constructor Summary
SqlParseException(String message, SqlParserPos pos, int[][] expectedTokenSequences, String[] tokenImages, Throwable parserException)
          Creates a SqlParseException.
 
Method Summary
 Throwable getCause()
           
 Collection<String> getExpectedTokenNames()
          Returns a list of the token names which could have legally occurred at this point.
 int[][] getExpectedTokenSequences()
          Returns the expected token sequences.
 SqlParserPos getPos()
          Returns the position where this error occurred.
 String[] getTokenImages()
          Returns the token images.
private  Object writeReplace()
          Per Serializable API, provides a replacement object to be written during serialization.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pos

private final SqlParserPos pos

expectedTokenSequences

private final int[][] expectedTokenSequences

tokenImages

private final String[] tokenImages

parserException

private final transient Throwable parserException
The original exception thrown by the generated parser. Unfortunately, each generated parser throws exceptions of a different class. So, we keep the exception for forensic purposes, but don't print it publicly.

Also, make it transient, because it is a ParseException generated by JavaCC and contains a non-serializable Token.

Constructor Detail

SqlParseException

public SqlParseException(String message,
                         SqlParserPos pos,
                         int[][] expectedTokenSequences,
                         String[] tokenImages,
                         Throwable parserException)
Creates a SqlParseException.

Parameters:
message - Message
pos - Position
expectedTokenSequences - Token sequences
tokenImages - Token images
parserException - Parser exception
Method Detail

getPos

public SqlParserPos getPos()
Returns the position where this error occurred.

Returns:
parser position

getExpectedTokenNames

public Collection<String> getExpectedTokenNames()
Returns a list of the token names which could have legally occurred at this point.

If some of the alternatives contain multiple tokens, returns the last token of only these longest sequences. (This occurs when the parser is maintaining more than the usual lookup.) For instance, if the possible tokens are

 {"IN"}
 {"BETWEEN"}
 {"LIKE"}
 {"=", "<IDENTIFIER>"}
 {"=", "USER"}
 
returns
 "<IDENTIFIER>"
 "USER"
 

Returns:
list of token names which could have occurred at this point

getTokenImages

public String[] getTokenImages()
Returns the token images.

Returns:
token images

getExpectedTokenSequences

public int[][] getExpectedTokenSequences()
Returns the expected token sequences.

Returns:
expected token sequences

getCause

public Throwable getCause()
Overrides:
getCause in class Throwable

writeReplace

private Object writeReplace()
Per Serializable API, provides a replacement object to be written during serialization.

SqlParseException is serializable but is not available on the client. This implementation converts this SqlParseException into a vanilla RuntimeException with the same message.