Package org.jdom2
Enum Content.CType
- java.lang.Object
-
- java.lang.Enum<Content.CType>
-
- org.jdom2.Content.CType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Content.CType>
- Enclosing class:
- Content
public static enum Content.CType extends java.lang.Enum<Content.CType>
An enumeration useful for identifying content types without having to doinstanceof
type conditionals.instanceof
is not a particularly safe way to test content in JDOM because CDATA extends Text ( a CDATA instance is aninstanceof
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 Summary
Enum Constants Enum Constant Description CDATA
RepresentsCDATA
contentComment
RepresentsComment
contentDocType
RepresentsDocType
contentElement
RepresentsElement
contentEntityRef
RepresentsEntityRef
contentProcessingInstruction
RepresentsProcessingInstruction
contentText
RepresentsText
content
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Content.CType
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Content.CType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
Comment
public static final Content.CType Comment
RepresentsComment
content
-
Element
public static final Content.CType Element
RepresentsElement
content
-
ProcessingInstruction
public static final Content.CType ProcessingInstruction
RepresentsProcessingInstruction
content
-
EntityRef
public static final Content.CType EntityRef
RepresentsEntityRef
content
-
Text
public static final Content.CType Text
RepresentsText
content
-
CDATA
public static final Content.CType CDATA
RepresentsCDATA
content
-
DocType
public static final Content.CType DocType
RepresentsDocType
content
-
-
Method Detail
-
values
public static Content.CType[] 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 (Content.CType c : Content.CType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Content.CType 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 namejava.lang.NullPointerException
- if the argument is null
-
-