Enum XMLEncoder.Mode

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<XMLEncoder.Mode>
    Enclosing class:
    XMLEncoder

    static enum XMLEncoder.Mode
    extends java.lang.Enum<XMLEncoder.Mode>
    An enum of supported "modes" of operation for the XMLEncoder.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ALL
      All significant characters are encoded (& < > ' ").
      ATTRIBUTE
      Characters are encoded for attribute values--either single or double quoted.
      CONTENT
      Characters are encoded for content (a.k.a.
      DOUBLE_QUOTED_ATTRIBUTE
      Characters are encoded for double-quoted attribute values.
      SINGLE_QUOTED_ATTRIBUTE
      Characters are encoded for single-quoted attribute values.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long _validMask
      The bit-mask of characters that do not need encoding in this mode.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Mode​(java.lang.String encodedChars)
      Sole constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) long validMask()
      Accessor for _validMask.
      static XMLEncoder.Mode valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static XMLEncoder.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

      • ALL

        public static final XMLEncoder.Mode ALL
        All significant characters are encoded (& < > ' "). This mode is safe for use in either content or attributes. See note on CONTENT for explanation of why '>' is encoded.
      • CONTENT

        public static final XMLEncoder.Mode CONTENT
        Characters are encoded for content (a.k.a. "CharData"). This means & < and >. Note: > only requires encoding if it follows "]]". However for maximum compatibility and to avoid the overhead of looking for "]]", we just always encode '>' to '&gt;'.
      • ATTRIBUTE

        public static final XMLEncoder.Mode ATTRIBUTE
        Characters are encoded for attribute values--either single or double quoted. This means the characters & < ' and " are encoded. Note: > is NOT encoded, and thus this mode is not suitable for content.
      • SINGLE_QUOTED_ATTRIBUTE

        public static final XMLEncoder.Mode SINGLE_QUOTED_ATTRIBUTE
        Characters are encoded for single-quoted attribute values. Thus, the same as ATTRIBUTE except ' is not encoded.
      • DOUBLE_QUOTED_ATTRIBUTE

        public static final XMLEncoder.Mode DOUBLE_QUOTED_ATTRIBUTE
        Characters are encoded for double-quoted attribute values. Thus, the same as ATTRIBUTE except " is not encoded.
    • Field Detail

      • _validMask

        private final long _validMask
        The bit-mask of characters that do not need encoding in this mode.
    • Constructor Detail

      • Mode

        private Mode​(java.lang.String encodedChars)
        Sole constructor.
        Parameters:
        encodedChars - -- a string of characters must be encoded in this mode. This string is converted to a bit-mask.
    • Method Detail

      • values

        public static XMLEncoder.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 (XMLEncoder.Mode c : XMLEncoder.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 XMLEncoder.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