Enum CssIdentifierEscapeLevel

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CssIdentifierEscapeLevel>

    public enum CssIdentifierEscapeLevel
    extends java.lang.Enum<CssIdentifierEscapeLevel>

    Levels defined for escape/unescape operations of CSS identifiers:

    • Level 1: Escape only the basic escape set. Note the result of a level-1 escape operation might still contain non-ASCII characters if they existed in input, and therefore you will still need to correctly manage your input/output character encoding settings. Such basic set consists of:
      • The Backslash Escapes: \ (U+0020), \! (U+0021), \" (U+0022), \# (U+0023), \$ (U+0024), \% (U+0025), \& (U+0026), \' (U+0027), \( (U+0028), \) (U+0029), \* (U+002A), \+ (U+002B), \, (U+002C), \. (U+002E), \/ (U+002F), \; (U+003B), \< (U+003C), \= (U+003D), \> (U+003E), \? (U+003F), \@ (U+0040), \[ (U+005B), \\ (U+005C), \] (U+005D), \^ (U+005E), \` (U+0060), \{ (U+007B), \| (U+007C), \} (U+007D) and \~ (U+007E). Note that the \- (U+002D) escape sequence exists, but will only be used when an identifier starts with two hypens or hyphen + digit. Also, the \_ (U+005F) escape will only be used at the beginning of an identifier to avoid problems with Internet Explorer 6. In the same sense, note that the \: (U+003A) escape sequence is also defined in the standard, but will not be used for escaping as Internet Explorer < 8 does not recognize it.
      • Two ranges of non-displayable, control characters: U+0000 to U+001F and U+007F to U+009F.
    • Level 2: Escape the basic escape set (as defined in level 1), plus all non-ASCII characters. The result of a level-2 escape operation is therefore always ASCII-only text, and safer to use in complex scenarios with mixed input/output character encodings.
    • Level 3: Escape all non-alphanumeric characters, this is, all but those in the A-Z, a-z and 0-9 ranges. This level can be safely used for completely escaping texts, including whitespace, line feeds, punctuation, etc. in scenarios where this adds an extra level of safety.
    • Level 4: Escape all characters, even alphanumeric ones.

    For further information, see the Glossary and the References sections at the documentation for the CssEscape class.

    Since:
    1.0.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int escapeLevel  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CssIdentifierEscapeLevel​(int escapeLevel)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static CssIdentifierEscapeLevel forLevel​(int level)
      Utility method for obtaining an enum value from its corresponding int level value.
      int getEscapeLevel()
      Return the int escape level.
      static CssIdentifierEscapeLevel valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CssIdentifierEscapeLevel[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • LEVEL_1_BASIC_ESCAPE_SET

        public static final CssIdentifierEscapeLevel LEVEL_1_BASIC_ESCAPE_SET
        Level 1 escape: escape only the basic escape set: Backslash Escape plus non-displayable control chars.
      • LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET

        public static final CssIdentifierEscapeLevel LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET
        Level 2 escape: escape the basic escape set plus all non-ASCII characters (result will always be ASCII).
      • LEVEL_3_ALL_NON_ALPHANUMERIC

        public static final CssIdentifierEscapeLevel LEVEL_3_ALL_NON_ALPHANUMERIC
        Level 3 escape: escape all non-alphanumeric characteres (escape all but those in the A-Z, a-z and 0-9 ranges).
      • LEVEL_4_ALL_CHARACTERS

        public static final CssIdentifierEscapeLevel LEVEL_4_ALL_CHARACTERS
        Level 4 escape: escape all characters, including alphanumeric.
    • Field Detail

      • escapeLevel

        private final int escapeLevel
    • Constructor Detail

      • CssIdentifierEscapeLevel

        private CssIdentifierEscapeLevel​(int escapeLevel)
    • Method Detail

      • values

        public static CssIdentifierEscapeLevel[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CssIdentifierEscapeLevel c : CssIdentifierEscapeLevel.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CssIdentifierEscapeLevel valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • forLevel

        public static CssIdentifierEscapeLevel forLevel​(int level)

        Utility method for obtaining an enum value from its corresponding int level value.

        Parameters:
        level - the level
        Returns:
        the escape level enum constant, or IllegalArgumentException if level does not exist.
      • getEscapeLevel

        public int getEscapeLevel()
        Return the int escape level.
        Returns:
        the escape level.