Semicolons inside comments, strings, and delimited identifiers are not considered to be statement terminators but to be part of those tokens.
Comments currently recognized include the SQL comment, which begins with "--" and ends at the next EOL, and nested bracketed comments.
Strings and delimited identifiers are permitted to contain newlines; the actual IJ or JSQL parsers will report errors when those cases occur.
There are no escaped characters, i.e. "\n" is considered to be two characters, '\' and 'n'.
| Modifier and Type | Field and Description |
|---|---|
| private static final char | |
| private boolean | |
| private boolean | |
| private boolean | |
| private static final char | |
| private static final int | |
| private static final int | |
| private static final char | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final char | |
| private static final char | |
| private char | |
| private boolean | |
| private boolean | |
| private LocalizedOutput | |
| private static final char | |
| private static final char | |
| private static final char | |
| private static final char | |
| private Reader | |
| private static final char | |
| private int | |
| private StringBuffer | |
| private static final char |
| Access | Constructor and Description |
|---|---|
| public | StatementFinder(LocalizedInput
the input stream for reading statements from. s, LocalizedOutput LocalizedOutput stream to write line
continuation prompts ("> ") to. If null,
no such prompts will be written. promptDest)The constructor does not assume the stream is data input or buffered, so it will wrap it appropriately. |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| public void | |
| public String | Returns: the next statement in the input stream.get the next statement in the input stream. |
| private char | Returns: the next character in the source stream.return the next character in the source stream, without advancing. |
| private boolean | |
| private void | readBracketedComment()
Advance the source stream to the end of a comment if it is on one, assuming the first character of a potential bracketed comment has been found. |
| private char | Returns: the next character in the source stream.return the next character in the source stream and append it to the statement buffer. |
| private void | readSingleLineComment(char
the character whose duplication signifies
the start of the comment. commentChar)Advance the source stream to the end of a comment if it is on one, assuming the first character of a potential single line comment has been found. |
| private void | readString(char
the starting and ending character
for the string being read. stringDelimiter)Advance the stream to the end of the string. |
| public void | ReInit(LocalizedInput
the input stream for reading statements from. s)Reinit is used to redirect the finder to another stream. |
| private boolean | Returns: true if the character is whitespacethe character to consider c)Determine if the given character is considered whitespace |
| ASTERISK | back to summary |
|---|---|
| private static final char ASTERISK | |
| atEOF | back to summary |
|---|---|
| private boolean atEOF | |
| continuedStatement | back to summary |
|---|---|
| private boolean continuedStatement | |
| doPrompt | back to summary |
|---|---|
| private boolean doPrompt | |
| DOUBLEQUOTE | back to summary |
|---|---|
| private static final char DOUBLEQUOTE | |
| END_OF_INPUT | back to summary |
|---|---|
| private static final int END_OF_INPUT | |
| END_OF_STATEMENT | back to summary |
|---|---|
| private static final int END_OF_STATEMENT | |
| FORMFEED | back to summary |
|---|---|
| private static final char FORMFEED | |
| IN_SQLCOMMENT | back to summary |
|---|---|
| private static final int IN_SQLCOMMENT | |
| IN_STATEMENT | back to summary |
|---|---|
| private static final int IN_STATEMENT | |
| IN_STRING | back to summary |
|---|---|
| private static final int IN_STRING | |
| MINUS | back to summary |
|---|---|
| private static final char MINUS | |
| NEWLINE | back to summary |
|---|---|
| private static final char NEWLINE | |
| peekChar | back to summary |
|---|---|
| private char peekChar | |
| peeked | back to summary |
|---|---|
| private boolean peeked | |
| peekEOF | back to summary |
|---|---|
| private boolean peekEOF | |
| promptwriter | back to summary |
|---|---|
| private LocalizedOutput promptwriter | |
| RETURN | back to summary |
|---|---|
| private static final char RETURN | |
| SEMICOLON | back to summary |
|---|---|
| private static final char SEMICOLON | |
| SINGLEQUOTE | back to summary |
|---|---|
| private static final char SINGLEQUOTE | |
| SLASH | back to summary |
|---|---|
| private static final char SLASH | |
| source | back to summary |
|---|---|
| private Reader source | |
| SPACE | back to summary |
|---|---|
| private static final char SPACE | |
| state | back to summary |
|---|---|
| private int state | |
| statement | back to summary |
|---|---|
| private StringBuffer statement | |
| TAB | back to summary |
|---|---|
| private static final char TAB | |
| StatementFinder | back to summary |
|---|---|
| public StatementFinder(LocalizedInput s, LocalizedOutput promptDest) The constructor does not assume the stream is data input or buffered, so it will wrap it appropriately. If the StatementFinder's input stream is connected to System.in, a LocalizedOutput stream may be given to print line continuation prompts when StatementFinder reads a newline.
| |
| atEOF | back to summary |
|---|---|
| private boolean atEOF() | |
| close | back to summary |
|---|---|
| public void close() throws IOException | |
| nextStatement | back to summary |
|---|---|
| public String nextStatement() get the next statement in the input stream. Returns it, dropping its closing semicolon if it has one. If there is no next statement, return a null.
| |
| peekChar | back to summary |
|---|---|
| private char peekChar() return the next character in the source stream, without advancing.
| |
| peekEOF | back to summary |
|---|---|
| private boolean peekEOF() | |
| readBracketedComment | back to summary |
|---|---|
| private void readBracketedComment() Advance the source stream to the end of a comment if it is on one, assuming the first character of a potential bracketed comment has been found. If it is not a comment, do not advance the stream. | |
| readChar | back to summary |
|---|---|
| private char readChar() return the next character in the source stream and append it to the statement buffer.
| |
| readSingleLineComment | back to summary |
|---|---|
| private void readSingleLineComment(char commentChar) Advance the source stream to the end of a comment if it is on one, assuming the first character of a potential single line comment has been found. If it is not a comment, do not advance the stream. The form of a single line comment is, in regexp, XX.*$, where XX is two instances of commentChar.
| |
| readString | back to summary |
|---|---|
| private void readString(char stringDelimiter) Advance the stream to the end of the string. Assumes the opening delimiter of the string has been read. This handles the SQL ability to put the delimiter within the string by doubling it, by reading those as two strings sitting next to one another. I.e, 'Mary''s lamb' is read by this class as two strings, 'Mary' and 's lamb'. The delimiter of the string is expected to be repeated at its other end. If the other flavor of delimiter occurs within the string, it is just a normal character within it. All characters except the delimiter are permitted within the string. If EOF is hit before the closing delimiter is found, the end of the string is assumed. Parsers using this parser will detect the error in that case and return appropriate messages.
| |
| ReInit | back to summary |
|---|---|
| public void ReInit(LocalizedInput s) Reinit is used to redirect the finder to another stream. The previous stream should not have been in a PEEK state. If an output stream was given when constructing this StatementFinder and the input is standard input, continuation prompting will be enabled.
| |
| whiteSpace | back to summary |
|---|---|
| private boolean whiteSpace(char c) Determine if the given character is considered whitespace
| |