Enum JavaScriptEncoder.Mode

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ATTRIBUTE
      Encoding for use in HTML attributes.
      BLOCK
      Encoding for use in HTML script blocks.
      HTML
      Encodes for use in either HTML script attributes or blocks.
      SOURCE
      Standard encoding of JavaScript Strings.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Mode()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static JavaScriptEncoder.Mode valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static JavaScriptEncoder.Mode[] 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

      • SOURCE

        public static final JavaScriptEncoder.Mode SOURCE
        Standard encoding of JavaScript Strings. Escape sequences are chosen according to what is the shortest sequence possible for the character.
      • ATTRIBUTE

        public static final JavaScriptEncoder.Mode ATTRIBUTE
        Encoding for use in HTML attributes. Quote characters are escaped using hex encodes instead of backslashes. The alternate would be to use a sequence of encodes that would actually be longer. In this mode double-quote is "\x22" and single-quote is "\x27". (In HTML attributes the alternate would be encoding "\"" and "\'" with entity escapes to "\"" and "\&39;").
      • BLOCK

        public static final JavaScriptEncoder.Mode BLOCK
        Encoding for use in HTML script blocks. The main concern here is permaturely terminating a script block with a closing "</" inside the string. This encoding escapes "/" as "\/" to prevent such termination.
      • HTML

        public static final JavaScriptEncoder.Mode HTML
        Encodes for use in either HTML script attributes or blocks. Essentially this is both special escapes from HTML_ATTRIBUTE and HTML_CONTENT combined.
    • Constructor Detail

      • Mode

        private Mode()
    • Method Detail

      • values

        public static JavaScriptEncoder.Mode[] 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 (JavaScriptEncoder.Mode c : JavaScriptEncoder.Mode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static JavaScriptEncoder.Mode 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