Package org.jdom2

Enum Class Content.CType

All Implemented Interfaces:
Serializable, Comparable<Content.CType>, Constable
Enclosing class:
Content

public static enum Content.CType extends Enum<Content.CType>
An enumeration useful for identifying content types without having to do instanceof type conditionals.

instanceof is not a particularly safe way to test content in JDOM because CDATA extends Text ( a CDATA instance is an instanceof Text).

This CType enumeration provides a direct and sure mechanism for identifying JDOM content.

These can be used in switch-type statements too (which is much neater than chained if (instanceof) else if (instanceof) else .... expressions):

    switch(content.getCType()) {
        case Text :
             .....
             break; 
        case CDATA :
             .....
             break;
        ....
    }
 
Since:
JDOM2
Author:
Rolf Lear
  • Enum Constant Details

  • Method Details

    • values

      public static Content.CType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Content.CType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null