Class CSSProcessor


  • public class CSSProcessor
    extends java.lang.Object
    Class to parse CSS stylesheets in order to manipulate them within Guise.
    Author:
    Garret Wilson
    See Also:
    CSS 3 Syntax
    • Constructor Summary

      Constructors 
      Constructor Description
      CSSProcessor()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void parseDeclarationBlock​(com.globalmentor.io.ParseReader parseReader, Rule rule)
      Parses an input stream is expected to contain a block of declaration names and values, with appropriate beginning and ending delimiters.
      static boolean parseDeclarations​(com.globalmentor.io.ParseReader parseReader, Rule rule)
      Parses an input stream is expected to contain a set of declaration names and values.
      protected static Rule parseRule​(com.globalmentor.io.ParseReader parseReader)
      Parses an input stream that is expected to begin with a CSS rule.
      protected static void parseStylesheetContent​(com.globalmentor.io.ParseReader parseReader, CSSStylesheet stylesheet)
      Parses an input stream that contains stylesheet information.
      CSSStylesheet process​(com.globalmentor.io.ParseReader parseReader)
      Processes a CSS stylesheet.
      protected static void skipWhitespaceCommentsEOF​(com.globalmentor.io.ParseReader parseReader)
      Skips whitespace and comments without throwing an error if the end of the input was reached.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CSSProcessor

        public CSSProcessor()
    • Method Detail

      • skipWhitespaceCommentsEOF

        protected static void skipWhitespaceCommentsEOF​(com.globalmentor.io.ParseReader parseReader)
                                                 throws java.io.IOException
        Skips whitespace and comments without throwing an error if the end of the input was reached. Peeking is reset.
        Parameters:
        parseReader - The reader from which to retrieve characters.
        Throws:
        java.io.IOException - Thrown if there is an error reading the input or the input is invalid.
      • parseDeclarations

        public static boolean parseDeclarations​(com.globalmentor.io.ParseReader parseReader,
                                                Rule rule)
                                         throws java.io.IOException
        Parses an input stream is expected to contain a set of declaration names and values.
        Parameters:
        parseReader - The reader from which to retrieve characters.
        rule - The rule which will hold the declarations.
        Returns:
        true if the end-of-rule-group character was found, false if the end of the stream was reached.
        Throws:
        java.io.IOException - Thrown if there is an error reading the input, the input is invalid, or the end of the input was reached unexpectedly.
      • parseDeclarationBlock

        public static void parseDeclarationBlock​(com.globalmentor.io.ParseReader parseReader,
                                                 Rule rule)
                                          throws java.io.IOException
        Parses an input stream is expected to contain a block of declaration names and values, with appropriate beginning and ending delimiters.
        Parameters:
        parseReader - The reader from which to retrieve characters.
        rule - The rule which will hold the declarations.
        Throws:
        java.io.IOException - Thrown if there is an error reading the input, the input is invalid, or the end of the input was reached unexpectedly.
      • parseRule

        protected static Rule parseRule​(com.globalmentor.io.ParseReader parseReader)
                                 throws java.io.IOException
        Parses an input stream that is expected to begin with a CSS rule.
        Parameters:
        parseReader - The reader from which to retrieve characters.
        Returns:
        A new CSS rule constructed from the reader.
        Throws:
        java.io.IOException - Thrown if there is an error reading the input, the input is invalid, or the end of the input was reached unexpectedly.
      • parseStylesheetContent

        protected static void parseStylesheetContent​(com.globalmentor.io.ParseReader parseReader,
                                                     CSSStylesheet stylesheet)
                                              throws java.io.IOException
        Parses an input stream that contains stylesheet information.
        Parameters:
        parseReader - The reader from which to retrieve characters.
        stylesheet - The stylesheet being constructed.
        Throws:
        java.io.IOException - Thrown if there is an error reading the input, the input is invalid, or the end of the input was reached unexpectedly.
      • process

        public CSSStylesheet process​(com.globalmentor.io.ParseReader parseReader)
                              throws java.io.IOException
        Processes a CSS stylesheet.
        Parameters:
        parseReader - The reader from which to retrieve characters.
        Returns:
        stylesheet The constructed stylesheet.
        Throws:
        java.io.IOException - Thrown if there is an error reading the input, the input is invalid, or the end of the input was reached unexpectedly.