Class CssScanner

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

final class CssScanner extends Object
A lexical scanner for CSS.

Lexical errors are stored as attributes on the tokens in which they occurred. The supplied CssErrorHandler is also invoked when a lexical error occurs, so that clients can terminate the scanning by a rethrow.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    Memoizer for escapes at forward reader positions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final com.google.common.base.CharMatcher
     
    private static final int[]
    The three last characters in the AND token
     
    private static final int[]
    The two last characters in the CDC token
    private static final int[]
    The three last characters in the CDO token
     
    private char
     
    private final boolean
     
    private final CssErrorHandler
     
     
    (package private) static final com.google.common.base.CharMatcher
     
    private Locale
     
    private static final com.google.common.base.CharMatcher
     
    private static final com.google.common.base.CharMatcher
    {nmchar} excluding {escape}
    private static final com.google.common.base.CharMatcher
    {nmstart} excluding {escape}
    private static final int[]
    The three last characters in the NOT token
    private static final com.google.common.base.CharMatcher
     
    private static final com.google.common.base.CharMatcher
    {num}
    private static final com.google.common.base.CharMatcher
    {num} end char cannot be period
    private static final com.google.common.base.CharMatcher
    {num} start char can be unary operators
    private static final com.google.common.base.CharMatcher
     
    private static final int[]
    The three last characters in the ONLY token
    private static final int
     
    private static final com.google.common.base.CharMatcher
    start of quantities that followed after {num} excluding {escape}
    private static final Map<int[], CssToken.Type>
     
    (package private) static final com.google.common.base.CharMatcher
     
    private final CssReader
     
    (package private) static final com.google.common.base.CharMatcher
     
    private static final com.google.common.base.CharMatcher
     
    private static final com.google.common.base.CharMatcher
     
    private static final com.google.common.base.CharMatcher
     
    private static final com.google.common.base.CharMatcher
     
    private static final int[]
    The three last characters in the URI start token
    (package private) static final com.google.common.base.CharMatcher
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    CssScanner(Reader in, String systemID, CssErrorHandler errHandler, CssToken.CssTokenConsumer consumer, int pushbackBufferSize, Locale locale)
     
    (package private)
    CssScanner(Reader in, String systemID, CssErrorHandler errHandler, CssToken.CssTokenConsumer consumer, Locale locale)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
     
    private void
    ATKEYWORD '@'[-]?{nmstart}{nmchar}* nmstart [_a-z]|{nonascii}|{escape} nmchar [_a-z0-9-]|{nonascii}|{escape}
    private void
     
    private void
     
    private void
    CLASSNAME "."{name} This is not part of formal lexical constructs, but seems to be safe to do at scanner level.
    private void
    Builds a comment token, excluding the leading and trailing comment tokens.
    private void
    DASHMATCH |=
    private void
    FUNCTION {ident}\(
    private void
    HASHNAME "#"{name} name {nmchar}+ [_a-z0-9-]|{nonascii}|{escape}
    private void
    IDENT ([-]?{nmstart}|[--]){nmchar}*
    private void
    IMPORTANT !{w}important
    private void
    INCLUDES ~=
    private void
     
    private void
     
    private void
     
    private void
    PREFIXMATCH ^=
    private void
    With incoming builder containing a valid NUMBER, and next char being a valid QNTSTART, modify the type and append to the builder
    private void
    string1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\" string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\'
    private void
    SUBSTRINGMATCH *=
    private void
    SUFFIXMATCH $=
    private void
    Builds a UNICODE_RANGE token.
    private void
    URI url\({w}{string}{w}\) | url\({w}([!#$%invalid input: '&'*-\[\]-~]|{nonascii}|{escape})*{w}\)
    private void
    _ws()
    Whitespace w ::= wc wc ::= #x9 | #xA | #xC | #xD | #x20
    private void
    append(com.google.common.base.CharMatcher matcher)
    Parse forward and append to the TokenBuilder field all characters that match matcher, or until the next character is EOF.
    private void
    append(com.google.common.base.CharMatcher matcher, CssToken.TokenBuilder builder)
    Parse forward and append to the supplied builder all characters that match matcher, or until the next character is EOF.
    private static boolean
    equals(int[] a, int[] b)
    Like Arrays.equals, but does not return true when both are null.
    private static boolean
    equals(int[] a, int[] b, boolean ignoreAsciiCase)
    Like Arrays.equals, but does not return true when both are null.
    private boolean
    forwardMatch(String match, boolean ignoreCase, boolean resetOnTrue)
    Check if a forward scan will equal given match string
    (package private) static int
    isNewLine(int[] chars)
    Determine whether a sequence of chars begin with a CSS newline.
    private boolean
    Returns true if reader next() is the start of a valid escape sequence.
    private static boolean
    matches(int ch, com.google.common.base.CharMatcher matcher)
    Return true if ch matches matcher, false if not or if ch represents EOF (-1).
    private static boolean
    matchesOrEOF(int ch, com.google.common.base.CharMatcher matcher)
    Return true if ch represents EOF (-1), or if it matches matcher.
    (package private) void
     
    private String
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • reader

      private final CssReader reader
    • consumer

      private final CssToken.CssTokenConsumer consumer
    • escapes

      private final CssScanner.CssEscapeMemoizer escapes
    • builder

      private CssToken.TokenBuilder builder
    • errHandler

      private final CssErrorHandler errHandler
    • debug

      private final boolean debug
      See Also:
    • cur

      private char cur
    • locale

      private Locale locale
    • QNT_TOKEN_MAXLENGTH

      private static final int QNT_TOKEN_MAXLENGTH
      See Also:
    • quantities

      private static final Map<int[], CssToken.Type> quantities
    • WHITESPACE

      static final com.google.common.base.CharMatcher WHITESPACE
    • NOT_WHITESPACE

      private static final com.google.common.base.CharMatcher NOT_WHITESPACE
    • QUOTES

      static final com.google.common.base.CharMatcher QUOTES
    • U

      private static final com.google.common.base.CharMatcher U
    • O

      private static final com.google.common.base.CharMatcher O
    • N

      private static final com.google.common.base.CharMatcher N
    • A

      private static final com.google.common.base.CharMatcher A
    • NMSTART

      private static final com.google.common.base.CharMatcher NMSTART
      {nmstart} excluding {escape}
    • NMCHAR

      private static final com.google.common.base.CharMatcher NMCHAR
      {nmchar} excluding {escape}
    • QNTSTART

      private static final com.google.common.base.CharMatcher QNTSTART
      start of quantities that followed after {num} excluding {escape}
    • NUMEND

      private static final com.google.common.base.CharMatcher NUMEND
      {num} end char cannot be period
    • NUM

      private static final com.google.common.base.CharMatcher NUM
      {num}
    • UNARY

      private static final com.google.common.base.CharMatcher UNARY
    • NUMSTART

      private static final com.google.common.base.CharMatcher NUMSTART
      {num} start char can be unary operators
    • HEXCHAR

      static final com.google.common.base.CharMatcher HEXCHAR
    • URANGESTART

      private static final com.google.common.base.CharMatcher URANGESTART
    • URANGECHAR

      private static final com.google.common.base.CharMatcher URANGECHAR
    • TERMINATOR

      static final com.google.common.base.CharMatcher TERMINATOR
    • CDO_LL

      private static final int[] CDO_LL
      The three last characters in the CDO token
    • CDC_LL

      private static final int[] CDC_LL
      The two last characters in the CDC token
    • URI_LL

      private static final int[] URI_LL
      The three last characters in the URI start token
    • ONLY_LL

      private static final int[] ONLY_LL
      The three last characters in the ONLY token
    • NOT_LL

      private static final int[] NOT_LL
      The three last characters in the NOT token
    • AND_LL

      private static final int[] AND_LL
      The three last characters in the AND token
  • Constructor Details

  • Method Details