Package org.idpf.epubcheck.util.css
Class CssReader
- java.lang.Object
-
- org.idpf.epubcheck.util.css.CssReader
-
final class CssReader extends java.lang.ObjectA wrapper around java.io.Reader with a pushback buffer, offset and line+column tracking. This is used by CssScanner.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classCssReader.Mark
-
Field Summary
Fields Modifier and Type Field Description private int[]buf(package private) intcolThe current column in the resource being read(package private) intcurCharThe char that this reader is currently positioned at, or -1 if EOF is reached.(package private) static intDEFAULT_PUSHBACK_BUFFER_SIZEprivate java.io.Readerin(package private) intlineThe current line in the resource being read(package private) intoffsetThe offset (in characters) of prevChar from the start of the resource being read.private intpos(package private) intprevCharThe previous char, or 0 if curChar is the first character in the resource being read.private intprevLine(package private) java.lang.StringsystemIDThe systemID of the resource being read.
-
Constructor Summary
Constructors Constructor Description CssReader(java.io.Reader reader, java.lang.String systemID, int pushbackSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (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)java.lang.StringtoString()(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(java.util.List<java.lang.Integer> cbuf, CssReader.Mark mark)
-
-
-
Field Detail
-
DEFAULT_PUSHBACK_BUFFER_SIZE
static final int DEFAULT_PUSHBACK_BUFFER_SIZE
- See Also:
- Constant Field Values
-
buf
private final int[] buf
-
pos
private int pos
-
in
private final java.io.Reader in
-
prevLine
private int prevLine
-
systemID
final java.lang.String 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 curChar
The char that this reader is currently positioned at, or -1 if EOF is reached.
-
prevChar
int prevChar
The previous char, or 0 if curChar is the first character in the resource being read.
-
offset
int offset
The offset (in characters) of prevChar from the start of the resource being read.
-
line
int line
The current line in the resource being read
-
col
int col
The current column in the resource being read
-
-
Method Detail
-
next
int next() throws java.io.IOException
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:
java.io.IOException
-
peek
int peek() throws java.io.IOException
Returns the next character in the stream without advancing the readers position. If there are no more characters, -1 is returned.- Throws:
java.io.IOException
-
peek
int[] peek(int n) throws java.io.IOExceptionReturns 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:
java.io.IOException
-
at
int at(int n) throws java.io.IOException
Peek and return the character at position n from current position, or -1 if EOF is reached before or at that position.- Throws:
java.io.IOException
-
collect
int[] collect(int n) throws java.io.IOExceptionReads 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:
java.io.IOException
-
forward
CssReader forward(com.google.common.base.CharMatcher matcher) throws java.io.IOException
Read forward until the next non-escaped character matches the given CharMatcher or is EOF.- Throws:
java.io.IOException
-
forward
CssReader forward(int n) throws java.io.IOException
Read forward n characters, or until the next character is EOF.- Throws:
java.io.IOException
-
unread
void unread(int ch, CssReader.Mark mark)
-
unread
void unread(int[] cbuf, CssReader.Mark mark) throws java.io.IOException- Throws:
java.io.IOException
-
unread
void unread(java.util.List<java.lang.Integer> cbuf, CssReader.Mark mark) throws java.io.IOException- Throws:
java.io.IOException
-
unread
void unread(int[] cbuf, int off, int len, CssReader.Mark mark)
-
mark
CssReader.Mark mark()
-
reset
private CssReader reset(CssReader.Mark mark)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-