Class ParserUtils

java.lang.Object
org.htmlunit.cssparser.util.ParserUtils

public final class ParserUtils extends Object
Utility methods for parser handling.
Author:
Ronald Brill
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    HASH_OFFSET = 37.
    static final int
    HASH_SEED = 17.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    equals(Object obj1, Object obj2)
    Compares two objects for equality.
    static int
    hashCode(int seed, boolean b)
    Calculates a hash code based on a given seed and boolean value.
    static int
    hashCode(int seed, int hashcode)
    Calculates a hash code based on a given seed and integer value.
    static int
    hashCode(int seed, Object obj)
    Calculates a hash code based on a given seed and object.
    static String
    trimBy(StringBuilder s, int left, int right)
    Removes the given number of characters from start and end.
    static String
    Helper that removes the leading "url(", the trailing ")" and surrounding quotes from the given string builder.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • hashCode

      public static int hashCode(int seed, int hashcode)
      Calculates a hash code based on a given seed and integer value.
      Parameters:
      seed - the seed to be used
      hashcode - the hashcode to be used as input
      Returns:
      a hash code calculated based on a given one
    • hashCode

      public static int hashCode(int seed, boolean b)
      Calculates a hash code based on a given seed and boolean value.
      Parameters:
      seed - the seed to be used
      b - the boolean to be used as input
      Returns:
      a hash code calculated based on a given boolean
    • hashCode

      public static int hashCode(int seed, Object obj)
      Calculates a hash code based on a given seed and object.
      Parameters:
      seed - the seed to be used
      obj - the object to be used as input
      Returns:
      a hash code calculated based on a given object
    • equals

      public static boolean equals(Object obj1, Object obj2)
      Compares two objects for equality.
      Parameters:
      obj1 - the first object
      obj2 - the second object
      Returns:
      true if both objects are equal
    • trimBy

      public static String trimBy(StringBuilder s, int left, int right)
      Removes the given number of characters from start and end. There is no parameter checking, the caller has to take care of this.
      Parameters:
      s - the StringBuilder
      left - number of characters to be removed from start
      right - number of characters to be removed from end
      Returns:
      the trimmed string
    • trimUrl

      public static String trimUrl(StringBuilder s)
      Helper that removes the leading "url(", the trailing ")" and surrounding quotes from the given string builder.
      Parameters:
      s - the StringBuilder
      Returns:
      the trimmed string