- java.lang.Object
-
- com.sun.tools.xjc.model.CEnumLeafInfo
-
- All Implemented Interfaces:
CCustomizable
,CNonElement
,CTypeInfo
,NClass
,NType
,TypeUse
,Locatable
,EnumLeafInfo<NType,NClass>
,LeafInfo<NType,NClass>
,MaybeElement<NType,NClass>
,NonElement<NType,NClass>
,TypeInfo<NType,NClass>
public final class CEnumLeafInfo extends Object implements EnumLeafInfo<NType,NClass>, NClass, CNonElement
Transducer that converts a string into an "enumeration class." The structure of the generated class needs to precisely follow the JAXB spec.- Author:
- Kohsuke KAWAGUCHI
-
-
Field Summary
Fields Modifier and Type Field Description CNonElement
base
Represents the underlying type of this enumeration and its conversion.String
javadoc
Collection<CEnumConstant>
members
List of enum members.Model
model
TheModel
object to which this bean belongs.CClassInfoParent
parent
The parent into which the enum class should be generated.String
shortName
Short name of the generated type-safe enum.-
Fields inherited from interface org.glassfish.jaxb.core.v2.model.core.NonElement
ANYTYPE_NAME
-
-
Constructor Summary
Constructors Constructor Description CEnumLeafInfo(Model model, QName typeName, CClassInfoParent container, String shortName, CNonElement base, Collection<CEnumConstant> _members, XSComponent source, CCustomizations customizations, Locator _sourceLocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Element<NType,NClass>
asElement()
boolean
canBeReferencedByIDREF()
Deprecated.why are you calling the method whose return value is known?JExpression
createConstant(Outline outline, XmlString literal)
Creates a constant for the given lexical value.String
fullName()
Human readable name of this type.CAdapter
getAdapterUse()
Deprecated.NonElement<NType,NClass>
getBaseType()
Returns the base type of the enumeration.NClass
getClazz()
The same asTypeInfo.getType()
but an is guaranteed to represent an enum declaration, which is a kind of a class declaration.Collection<CEnumConstant>
getConstants()
Returns the read-only list of enumeration constants.CCustomizations
getCustomizations()
Gets the list of customizations attached to this model component.QName
getElementName()
Gets the element name of the class, if the class is bound to an element.jakarta.activation.MimeType
getExpectedMimeType()
A can have an associated MIME type.CNonElement
getInfo()
Deprecated.Location
getLocation()
Gets the location object that this object points to.Locator
getLocator()
Source line information that points to the place where this type-safe enum is defined.XSComponent
getSchemaComponent()
If this model object is built from XML Schema, this property returns a schema component from which the model is built.NType
getType()
Gets the underlying Java type that object represents.QName
getTypeName()
Gets the primary XML type ANYTYPE_NAME of the class.Locatable
getUpstream()
Gets the upstreamLocation
information.ID
idUse()
Whether the referenced type (individual item type in case of collection) is ID/IDREF.boolean
isAbstract()
boolean
isBoxedType()
Returns true iff this type represents a class that has a unboxed form.boolean
isCollection()
Deprecated.boolean
isElement()
If the class is bound to an element, return true.boolean
isPrimitive()
boolean
isSimpleType()
Returns true if this maps to text in XML, without any attribute nor child elements.boolean
needsValueField()
The spec says the value field in the enum class will be generated only under certain circumstances.JClass
toType(Outline o, Aspect aspect)
Returns the representation of this type in code model.
-
-
-
Field Detail
-
parent
public final CClassInfoParent parent
The parent into which the enum class should be generated.
-
shortName
public final String shortName
Short name of the generated type-safe enum.
-
base
public final CNonElement base
Represents the underlying type of this enumeration and its conversion.To parse XML into a constant, we use the base type to do
lexical -> value
, then use a map to pick up the right one.Hence this also represents the type of the Java value. For example, if this is an enumeration of xs:int, then this field will be Java int.
-
members
public final Collection<CEnumConstant> members
List of enum members.
-
javadoc
public String javadoc
-
-
Constructor Detail
-
CEnumLeafInfo
public CEnumLeafInfo(Model model, QName typeName, CClassInfoParent container, String shortName, CNonElement base, Collection<CEnumConstant> _members, XSComponent source, CCustomizations customizations, Locator _sourceLocator)
-
-
Method Detail
-
getLocator
public Locator getLocator()
Source line information that points to the place where this type-safe enum is defined. Used to report error messages.- Specified by:
getLocator
in interfaceCCustomizable
- Returns:
- never null.
-
getTypeName
public QName getTypeName()
Description copied from interface:NonElement
Gets the primary XML type ANYTYPE_NAME of the class.A Java type can be mapped to multiple XML types, but one of them is considered "primary" and used when we generate a schema.
- Specified by:
getTypeName
in interfaceNonElement<NType,NClass>
- Returns:
- null if the object doesn't have an explicit type ANYTYPE_NAME (AKA anonymous.)
-
getType
public NType getType()
Description copied from interface:TypeInfo
Gets the underlying Java type that object represents.
-
canBeReferencedByIDREF
@Deprecated public boolean canBeReferencedByIDREF()
Deprecated.why are you calling the method whose return value is known?Description copied from interface:TypeInfo
True if this type is a valid target from a property annotated withXmlIDREF
.- Specified by:
canBeReferencedByIDREF
in interfaceTypeInfo<NType,NClass>
-
isElement
public boolean isElement()
Description copied from interface:MaybeElement
If the class is bound to an element, return true.Note that when this is true, the class is bound to both an element and a type.
- Specified by:
isElement
in interfaceMaybeElement<NType,NClass>
-
getElementName
public QName getElementName()
Description copied from interface:MaybeElement
Gets the element name of the class, if the class is bound to an element.- Specified by:
getElementName
in interfaceMaybeElement<NType,NClass>
- Returns:
- non-null iff
MaybeElement.isElement()
.
-
asElement
public Element<NType,NClass> asElement()
Description copied from interface:MaybeElement
- Specified by:
asElement
in interfaceMaybeElement<NType,NClass>
- Returns:
- null if
MaybeElement.isElement()
==false, non-null ifMaybeElement.isElement()
==true.
-
getClazz
public NClass getClazz()
Description copied from interface:EnumLeafInfo
The same asTypeInfo.getType()
but an is guaranteed to represent an enum declaration, which is a kind of a class declaration.- Specified by:
getClazz
in interfaceEnumLeafInfo<NType,NClass>
- Returns:
- always non-null.
-
getSchemaComponent
public XSComponent getSchemaComponent()
Description copied from interface:CCustomizable
If this model object is built from XML Schema, this property returns a schema component from which the model is built.- Specified by:
getSchemaComponent
in interfaceCCustomizable
- Returns:
- null if the model is built from sources other than XML Schema (such as DTD.)
-
toType
public JClass toType(Outline o, Aspect aspect)
Description copied from interface:NType
Returns the representation of this type in code model.This operation requires the whole model to be built, and hence it takes
Outline
.Under some code generation strategy, some bean classes are considered implementation specific (such as impl.FooImpl class) These classes always have accompanying "exposed" type (such as the Foo interface).
For such Jekyll and Hyde type, the aspect parameter determines which personality is returned.
- Specified by:
toType
in interfaceCTypeInfo
- Specified by:
toType
in interfaceNClass
- Specified by:
toType
in interfaceNType
aspect
- IfAspect.IMPLEMENTATION
, this method returns the implementation specific class that this type represents. IfAspect.EXPOSED
, this method returns the publicly exposed type that this type represents. For ordinary classes, the aspect parameter is meaningless.- See Also:
NType.toType(Outline, com.sun.tools.xjc.outline.Aspect)
-
isAbstract
public boolean isAbstract()
- Specified by:
isAbstract
in interfaceNClass
-
isBoxedType
public boolean isBoxedType()
Description copied from interface:NType
Returns true iff this type represents a class that has a unboxed form. For example, forString
this is false, but forInteger
this is true.- Specified by:
isBoxedType
in interfaceNType
-
fullName
public String fullName()
Description copied from interface:NType
Human readable name of this type.
-
isPrimitive
public boolean isPrimitive()
-
isSimpleType
public boolean isSimpleType()
Description copied from interface:NonElement
Returns true if this maps to text in XML, without any attribute nor child elements.- Specified by:
isSimpleType
in interfaceNonElement<NType,NClass>
-
needsValueField
public boolean needsValueField()
The spec says the value field in the enum class will be generated only under certain circumstances.- Returns:
- true if the generated enum class should have the value field.
-
createConstant
public JExpression createConstant(Outline outline, XmlString literal)
Description copied from interface:TypeUse
Creates a constant for the given lexical value.For example, to create a constant 1 for
xs:int
, you'd do:CBuiltinLeafInfo.INT.createConstant( codeModel, "1", null );
This method is invoked at the backend as a part of the code generation process.
- Specified by:
createConstant
in interfaceTypeUse
- Returns:
- null if the constant cannot be created for this (such as when it's a collection)
-
isCollection
@Deprecated public boolean isCollection()
Deprecated.Description copied from interface:CNonElement
Guaranteed to return false.- Specified by:
isCollection
in interfaceCNonElement
- Specified by:
isCollection
in interfaceTypeUse
-
getAdapterUse
@Deprecated public CAdapter getAdapterUse()
Deprecated.Description copied from interface:CNonElement
Guaranteed to return null.- Specified by:
getAdapterUse
in interfaceCNonElement
- Specified by:
getAdapterUse
in interfaceTypeUse
-
getInfo
@Deprecated public CNonElement getInfo()
Deprecated.Description copied from interface:CNonElement
Guaranteed to return this.- Specified by:
getInfo
in interfaceCNonElement
- Specified by:
getInfo
in interfaceTypeUse
-
idUse
public ID idUse()
Description copied from interface:TypeUse
Whether the referenced type (individual item type in case of collection) is ID/IDREF.ID is a property of a relationship. When a bean Foo has an ID property called 'bar' whose type is String, Foo isn't an ID, String isn't an ID, but this relationship is an ID (in the sense that Foo uses this String as an ID.)
The same thing can be said with IDREF. When Foo refers to Bar by means of IDREF, neither Foo nor Bar is IDREF.
That's why we have this method in .
-
getExpectedMimeType
public jakarta.activation.MimeType getExpectedMimeType()
Description copied from interface:TypeUse
A can have an associated MIME type.- Specified by:
getExpectedMimeType
in interfaceTypeUse
-
getConstants
public Collection<CEnumConstant> getConstants()
Description copied from interface:EnumLeafInfo
Returns the read-only list of enumeration constants.- Specified by:
getConstants
in interfaceEnumLeafInfo<NType,NClass>
- Returns:
- never null. Can be empty (really?).
-
getBaseType
public NonElement<NType,NClass> getBaseType()
Description copied from interface:EnumLeafInfo
Returns the base type of the enumeration.For example, with the following enum class, this method returns
BuiltinLeafInfo
forInteger
.&XmlEnum(Integer.class) enum Foo { &XmlEnumValue("1") ONE, &XmlEnumValue("2") TWO }
- Specified by:
getBaseType
in interfaceEnumLeafInfo<NType,NClass>
- Returns:
- never null.
-
getCustomizations
public CCustomizations getCustomizations()
Description copied from interface:CCustomizable
Gets the list of customizations attached to this model component.- Specified by:
getCustomizations
in interfaceCCustomizable
- Returns:
- can be an empty list but never be null. The returned list is read-only. Do not modify.
- See Also:
Plugin.getCustomizationURIs()
-
getUpstream
public Locatable getUpstream()
Description copied from interface:Locatable
Gets the upstreamLocation
information.- Specified by:
getUpstream
in interfaceLocatable
- Returns:
- can be null.
-
getLocation
public Location getLocation()
Description copied from interface:Locatable
Gets the location object that this object points to. This operation could be inefficient and costly.- Specified by:
getLocation
in interfaceLocatable
-
-