Class CssReader

java.lang.Object
org.idpf.epubcheck.util.css.CssReader

final class CssReader extends Object
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
    Modifier and Type
    Class
    Description
    (package private) final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int[]
     
    (package private) int
    The current column in the resource being read
    (package private) int
    The char that this reader is currently positioned at, or -1 if EOF is reached.
    (package private) static final int
     
    private final Reader
     
    (package private) int
    The current line in the resource being read
    (package private) int
    The offset (in characters) of prevChar from the start of the resource being read.
    private int
     
    (package private) int
    The previous char, or 0 if curChar is the first character in the resource being read.
    private int
     
    (package private) final String
    The systemID of the resource being read.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CssReader(Reader reader, String systemID, int pushbackSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int
    at(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) CssReader
    forward(int n)
    Read forward n characters, or until the next character is EOF.
    (package private) CssReader
    forward(com.google.common.base.CharMatcher matcher)
    Read forward until the next non-escaped character matches the given CharMatcher or is EOF.
    (package private) CssReader.Mark
     
    (package private) int
    Returns the next character in the stream and advances the readers position.
    (package private) int
    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 CssReader
     
     
    (package private) void
    unread(int[] cbuf, int off, int len, CssReader.Mark mark)
     
    (package private) void
    unread(int[] cbuf, CssReader.Mark mark)
     
    (package private) void
    unread(int ch, CssReader.Mark mark)
     
    (package private) void
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      private final Reader in
    • prevLine

      private int prevLine
    • systemID

      final 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
  • Constructor Details

    • CssReader

      CssReader(Reader reader, String systemID, int pushbackSize)
  • Method Details

    • next

      int next() throws 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:
      IOException
    • peek

      int peek() throws IOException
      Returns the next character in the stream without advancing the readers position. If there are no more characters, -1 is returned.
      Throws:
      IOException
    • peek

      int[] peek(int n) throws IOException
      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

      int at(int n) throws IOException
      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

      int[] collect(int n) throws IOException
      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

      CssReader forward(com.google.common.base.CharMatcher matcher) throws IOException
      Read forward until the next non-escaped character matches the given CharMatcher or is EOF.
      Throws:
      IOException
    • forward

      CssReader forward(int n) throws IOException
      Read forward n characters, or until the next character is EOF.
      Throws:
      IOException
    • unread

      void unread(int ch, CssReader.Mark mark)
    • unread

      void unread(int[] cbuf, CssReader.Mark mark) throws IOException
      Throws:
      IOException
    • unread

      void unread(List<Integer> cbuf, CssReader.Mark mark) throws IOException
      Throws:
      IOException
    • unread

      void unread(int[] cbuf, int off, int len, CssReader.Mark mark)
    • mark

    • reset

      private CssReader reset(CssReader.Mark mark)
    • toString

      public String toString()
      Overrides:
      toString in class Object