Class ScriptReader
java.lang.Object
org.h2.util.ScriptReader
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanOnly valid if insideRemark is true.private char[]private intThe position in the buffer of the last available charprivate intThe position in the buffer of the next char to be readprivate intThe position in the buffer of the statement startprivate booleanTrue if we have read past the end of fileprivate booleanTrue if we are inside a commentprivate final Readerprivate intThe position in buffer of start of commentprivate booleanTrue if comments should be skipped completely by this reader. -
Constructor Summary
ConstructorsConstructorDescriptionScriptReader(Reader reader) Create a new SQL script reader from the given reader -
Method Summary
Modifier and TypeMethodDescriptionprivate voidvoidclose()Close the underlying reader.private voidbooleanIf currently inside a remark, this method tells if it is a block comment (true) or single line comment (false)booleanCheck if this is the last statement, and if the single line or block comment is not finished yet.private intread()private intRead a statement from the reader.private StringvoidsetSkipRemarks(boolean skipRemarks) If comments should be skipped completely by this reader.private voidstartRemark(boolean block)
-
Field Details
-
reader
-
buffer
private char[] buffer -
bufferPos
private int bufferPosThe position in the buffer of the next char to be read -
bufferStart
private int bufferStartThe position in the buffer of the statement start -
bufferEnd
private int bufferEndThe position in the buffer of the last available char -
endOfFile
private boolean endOfFileTrue if we have read past the end of file -
insideRemark
private boolean insideRemarkTrue if we are inside a comment -
blockRemark
private boolean blockRemarkOnly valid if insideRemark is true. True if we are inside a block comment, false if we are inside a line comment -
skipRemarks
private boolean skipRemarksTrue if comments should be skipped completely by this reader. -
remarkStart
private int remarkStartThe position in buffer of start of comment
-
-
Constructor Details
-
ScriptReader
Create a new SQL script reader from the given reader- Parameters:
reader- the reader
-
-
Method Details
-
close
public void close()Close the underlying reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
readStatement
Read a statement from the reader. This method returns null if the end has been reached.- Returns:
- the SQL statement or null
-
readStatementLoop
- Throws:
IOException
-
startRemark
private void startRemark(boolean block) -
endRemark
private void endRemark() -
clearRemark
private void clearRemark() -
read
- Throws:
IOException
-
readBuffer
- Throws:
IOException
-
isInsideRemark
public boolean isInsideRemark()Check if this is the last statement, and if the single line or block comment is not finished yet.- Returns:
- true if the current position is inside a remark
-
isBlockRemark
public boolean isBlockRemark()If currently inside a remark, this method tells if it is a block comment (true) or single line comment (false)- Returns:
- true if inside a block comment
-
setSkipRemarks
public void setSkipRemarks(boolean skipRemarks) If comments should be skipped completely by this reader.- Parameters:
skipRemarks- true if comments should be skipped
-