Class CssRuleSetParser


  • public final class CssRuleSetParser
    extends java.lang.Object
    Utilities class to parse CSS rule sets.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger logger
      The logger.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int getSemicolonPosition​(java.lang.String propertiesStr, int fromIndex)
      Gets the semicolon position.
      static java.util.List<CssDeclaration> parsePropertyDeclarations​(java.lang.String propertiesStr)
      Parses property declarations.
      static java.util.List<CssRuleSet> parseRuleSet​(java.lang.String selectorStr, java.lang.String propertiesStr)
      Parses a rule set into a list of CssRuleSet instances.
      private static java.lang.String[] splitCssProperty​(java.lang.String property)
      Splits CSS properties into an array of String values.
      • Methods inherited from class java.lang.Object

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

      • logger

        private static final org.slf4j.Logger logger
        The logger.
    • Constructor Detail

      • CssRuleSetParser

        private CssRuleSetParser()
        Creates a new CssRuleSetParser instance.
    • Method Detail

      • parsePropertyDeclarations

        public static java.util.List<CssDeclaration> parsePropertyDeclarations​(java.lang.String propertiesStr)
        Parses property declarations.
        Parameters:
        propertiesStr - the property declarations in the form of a String
        Returns:
        the list of CssDeclaration instances
      • parseRuleSet

        public static java.util.List<CssRuleSet> parseRuleSet​(java.lang.String selectorStr,
                                                              java.lang.String propertiesStr)
        Parses a rule set into a list of CssRuleSet instances. This method returns a List because a selector can be compound, like "p, div, #navbar".
        Parameters:
        selectorStr - the selector
        propertiesStr - the properties
        Returns:
        the resulting list of CssRuleSet instances
      • splitCssProperty

        private static java.lang.String[] splitCssProperty​(java.lang.String property)
        Splits CSS properties into an array of String values.
        Parameters:
        property - the properties
        Returns:
        the array of property values
      • getSemicolonPosition

        private static int getSemicolonPosition​(java.lang.String propertiesStr,
                                                int fromIndex)
        Gets the semicolon position.
        Parameters:
        propertiesStr - the properties
        fromIndex - the from index
        Returns:
        the semicolon position