Class CssValueUtil



  • public class CssValueUtil
    extends java.lang.Object
    Since:
    1.0.0
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCssValuePartStartEndValue​(java.lang.String start, java.lang.String end)
      The given value is used by Web Firm Framework Index Based Extraction algorithm to extract css value parts, i.e.
      static java.util.List<java.lang.String> split​(java.lang.String cssValue)
      splits each cssValue part based on the css rule.
      static void throwExceptionForInvalidValue​(java.lang.String cssValue)
      This method throws NullValueException if the given cssValue is null or InvalidValueException if the given cssValue is blank.
      • Methods inherited from class java.lang.Object

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

      • addCssValuePartStartEndValue

        public void addCssValuePartStartEndValue​(java.lang.String start,
                                                 java.lang.String end)
        The given value is used by Web Firm Framework Index Based Extraction algorithm to extract css value parts, i.e. the CssValueUtil#split(String) is extracting values based on the given values.
        Eg :-
         addCssValuePartStartEndValue("rgb(", ")");
         
        And the following "rgb(", ")", "rgba(", ")", "hsl(", ")", "hsla(", ")" values are already added.
        Parameters:
        start -
        end -
        Since:
        1.0.0
      • split

        public static java.util.List<java.lang.String> split​(java.lang.String cssValue)
        splits each cssValue part based on the css rule.
        This extraction is done based on the Web Firm Framework Index Based Extraction algorithm. It will throw InvalidValueException if the given cssValue contains no space in between any valid cssValue part, eg:- rgb(1, 2, 5)rgb(11, 12, 15). And, it doesn't validate the extracted cssValue parts so the extracted cssValue parts (i.e. the returned List<String>) may contain invalid cssValue part.

        Sample code to test
         final List<String> splitTest = CssValueUtil.split("hsla(7, 8, 9, 1) red rgb(3, 5, 6) rgb(7, 8, 9) rgba(7, 8, 9, 1) middle hsl(10, 11, 12) green   blue");
         for (final String each : splitTest) {
             System.out.println(each);
         }
        
         gives out as :
         
         hsla(7, 8, 9, 1)
         red
         rgb(3, 5, 6)
         rgb(7, 8, 9)
         rgba(7, 8, 9, 1)
         middle
         hsl(10, 11, 12)
         green
         blue
         
        Parameters:
        cssValue - the value from which the css parts will be extracted
        Returns:
        the list containing cssValue parts
        Since:
        1.0.0