java.lang.Object
org.apache.wicket.util.io.FullyBufferedReader
This is not a reader like e.g. FileReader. It rather reads the whole data until the end from a
source reader into memory and besides that it maintains the current position (like a reader) it
provides String like methods which conveniently let you navigate (usually forward) in the stream.
Because the source data are expected to be text, the line and column numbers are maintained as
well for location precise error messages. But it does NOT automatically update the line and
column numbers. You must call countLinesTo(int)
- Author:
- Juergen Donnerstag
-
Constructor Summary
ConstructorDescriptionFullyBufferedReader
(Reader reader) Read all the data from the resource into memory.FullyBufferedReader
(String input) Construct. -
Method Summary
Modifier and TypeMethodDescriptionfinal char
charAt
(int pos) Get the character at the position providedfinal void
countLinesTo
(int end) Counts lines starting where we last left off up to the index provided.final int
find
(char ch) Find a char starting at the current input positionfinal int
find
(char ch, int startPos) Find a char starting at the position providedfinal int
Find the string starting at the current input positionfinal int
Find the string starting at the position providedint
findOutOfQuotes
(char ch, int startPos) Find a char starting at the position provided.int
findOutOfQuotes
(char ch, int startPos, char quotationChar) Find a char starting at the position provided.final int
Get the column number.final int
Get the line number.final int
Gets the current input positionfinal CharSequence
getSubstring
(int toPos) Get the characters from the position marker to toPos.final CharSequence
getSubstring
(int fromPos, int toPos) Get the characters from in between both positions including the char at fromPos, excluding the char at toPosfinal void
setPosition
(int pos) Position the reader at the index provided.final void
setPositionMarker
(int pos) Remember the current position in markupfinal int
size()
Get the number of character read from the source resource.toString()
-
Constructor Details
-
FullyBufferedReader
Read all the data from the resource into memory.- Parameters:
reader
- The source reader to load the data from- Throws:
IOException
-
FullyBufferedReader
Construct.- Parameters:
input
- The source string
-
-
Method Details
-
getSubstring
Get the characters from the position marker to toPos.If toPos < 0, than get all data from the position marker until the end. If toPos less than the current position marker than return an empty string ""
- Parameters:
toPos
- Index of first character not included- Returns:
- Raw markup (a string) in between these two positions.
-
getSubstring
Get the characters from in between both positions including the char at fromPos, excluding the char at toPos- Parameters:
fromPos
- first indextoPos
- second index- Returns:
- the string (raw markup) in between both positions
-
getPosition
Gets the current input position- Returns:
- input position
-
setPositionMarker
Remember the current position in markup- Parameters:
pos
-
-
toString
-
countLinesTo
Counts lines starting where we last left off up to the index provided.- Parameters:
end
- End index
-
find
Find a char starting at the current input position- Parameters:
ch
- The char to search for- Returns:
- -1 if not found
-
find
Find a char starting at the position provided- Parameters:
ch
- The char to search forstartPos
- The index to start at- Returns:
- -1 if not found
-
find
Find the string starting at the current input position- Parameters:
str
- The string to search for- Returns:
- -1 if not found
-
find
Find the string starting at the position provided- Parameters:
str
- The string to search forstartPos
- The index to start at- Returns:
- -1 if not found
-
findOutOfQuotes
Find a char starting at the position provided. The char must not be inside a quoted string (single or double)- Parameters:
ch
- The char to search forstartPos
- The index to start at- Returns:
- -1 if not found
- Throws:
ParseException
-
findOutOfQuotes
Find a char starting at the position provided. The char must not be inside a quoted string (single or double)- Parameters:
ch
- The char to search forstartPos
- The index to start atquotationChar
- The current quotation char. Must be ' or ", otherwise will be ignored.- Returns:
- -1 if not found
- Throws:
ParseException
-
setPosition
Position the reader at the index provided. Could be anywhere within the data- Parameters:
pos
- The new current position
-
getColumnNumber
Get the column number. Note: The column number depends on you calling countLinesTo(pos). It is not necessarily the column number matching the current position in the stream.- Returns:
- column number
-
getLineNumber
Get the line number. Note: The line number depends on you calling countLinesTo(pos). It is not necessarily the line number matching the current position in the stream.- Returns:
- line number
-
size
Get the number of character read from the source resource. The whole content, not just until the current position.- Returns:
- Size of the data
-
charAt
Get the character at the position provided- Parameters:
pos
- The position- Returns:
- char at position
-