Class CssReader
java.lang.Object
org.idpf.epubcheck.util.css.CssReader
A wrapper around java.io.Reader with a pushback buffer, offset and
line+column tracking. This is used by CssScanner.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[](package private) intThe current column in the resource being read(package private) intThe char that this reader is currently positioned at, or -1 if EOF is reached.(package private) static final intprivate final Reader(package private) intThe current line in the resource being read(package private) intThe offset (in characters) of prevChar from the start of the resource being read.private int(package private) intThe previous char, or 0 if curChar is the first character in the resource being read.private int(package private) final StringThe systemID of the resource being read. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) intat(int n) Peek and return the character at position n from current position, or -1 if EOF is reached before or at that position.(package private) int[]collect(int n) Reads forward and returns the the next n characters in the stream.(package private) CssReaderforward(int n) Read forward n characters, or until the next character is EOF.(package private) CssReaderforward(com.google.common.base.CharMatcher matcher) Read forward until the next non-escaped character matches the given CharMatcher or is EOF.(package private) CssReader.Markmark()(package private) intnext()Returns the next character in the stream and advances the readers position.(package private) intpeek()Returns the next character in the stream without advancing the readers position.(package private) int[]peek(int n) Returns the the next n characters in the stream without advancing the readers position.private CssReaderreset(CssReader.Mark mark) toString()(package private) voidunread(int[] cbuf, int off, int len, CssReader.Mark mark) (package private) voidunread(int[] cbuf, CssReader.Mark mark) (package private) voidunread(int ch, CssReader.Mark mark) (package private) voidunread(List<Integer> cbuf, CssReader.Mark mark)
-
Field Details
-
DEFAULT_PUSHBACK_BUFFER_SIZE
static final int DEFAULT_PUSHBACK_BUFFER_SIZE- See Also:
-
buf
private final int[] buf -
pos
private int pos -
in
-
prevLine
private int prevLine -
systemID
The systemID of the resource being read. If the resource being read is virtual the value is set to CssLocaton.NO_SID -
curChar
int curCharThe char that this reader is currently positioned at, or -1 if EOF is reached. -
prevChar
int prevCharThe previous char, or 0 if curChar is the first character in the resource being read. -
offset
int offsetThe offset (in characters) of prevChar from the start of the resource being read. -
line
int lineThe current line in the resource being read -
col
int colThe current column in the resource being read
-
-
Constructor Details
-
CssReader
-
-
Method Details
-
next
Returns the next character in the stream and advances the readers position. If there are no more characters, -1 is returned the first time this method is invoked in that state; multiple invocations at EOF will yield an IllegalStateException.- Throws:
IOException
-
peek
Returns the next character in the stream without advancing the readers position. If there are no more characters, -1 is returned.- Throws:
IOException
-
peek
Returns the the next n characters in the stream without advancing the readers position.- Parameters:
n- the number of characters to read- Returns:
- An array with guaranteed length n, with -1 being the value for all elements at and after EOF.
- Throws:
IOException
-
at
Peek and return the character at position n from current position, or -1 if EOF is reached before or at that position.- Throws:
IOException
-
collect
Reads forward and returns the the next n characters in the stream. Escapes are returned verbatim. At return, the reader is at positioned such that next() will return n+1 or EOF (-1).- Parameters:
n- the number of characters to read- Returns:
- An array with guaranteed length n, with -1 being the value for all elements at and after EOF.
- Throws:
IOException
-
forward
Read forward until the next non-escaped character matches the given CharMatcher or is EOF.- Throws:
IOException
-
forward
Read forward n characters, or until the next character is EOF.- Throws:
IOException
-
unread
-
unread
- Throws:
IOException
-
unread
- Throws:
IOException
-
unread
-
mark
CssReader.Mark mark() -
reset
-
toString
-