com.sun.tools.xjc.model
Class CEnumLeafInfo

java.lang.Object
  extended by com.sun.tools.xjc.model.CEnumLeafInfo
All Implemented Interfaces:
CCustomizable, CNonElement, CTypeInfo, NClass, NType, TypeUse, com.sun.xml.bind.v2.model.annotation.Locatable, com.sun.xml.bind.v2.model.core.EnumLeafInfo<NType,NClass>, com.sun.xml.bind.v2.model.core.LeafInfo<NType,NClass>, com.sun.xml.bind.v2.model.core.MaybeElement<NType,NClass>, com.sun.xml.bind.v2.model.core.NonElement<NType,NClass>, com.sun.xml.bind.v2.model.core.TypeInfo<NType,NClass>

public final class CEnumLeafInfo
extends java.lang.Object
implements com.sun.xml.bind.v2.model.core.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.


Field Summary
 CNonElement base
          Represents the underlying type of this enumeration and its conversion.
 java.lang.String javadoc
           
 java.util.Collection<CEnumConstant> members
          List of enum members.
 Model model
          The Model object to which this bean belongs.
 CClassInfoParent parent
          The parent into which the enum class should be generated.
 java.lang.String shortName
          Short name of the generated type-safe enum.
 
Constructor Summary
CEnumLeafInfo(Model model, javax.xml.namespace.QName typeName, CClassInfoParent container, java.lang.String shortName, CNonElement base, java.util.Collection<CEnumConstant> _members, com.sun.xml.xsom.XSComponent source, CCustomizations customizations, org.xml.sax.Locator _sourceLocator)
           
 
Method Summary
 com.sun.xml.bind.v2.model.core.Element<NType,NClass> asElement()
           
 boolean canBeReferencedByIDREF()
          Deprecated. why are you calling the method whose return value is known?
 com.sun.codemodel.JExpression createConstant(Outline outline, com.sun.xml.xsom.XmlString literal)
          Creates a constant for the given lexical value.
 java.lang.String fullName()
          Human readable name of this type.
 CAdapter getAdapterUse()
          If this type use is adapting the type, returns the adapter.
 com.sun.xml.bind.v2.model.core.NonElement<NType,NClass> getBaseType()
           
 NClass getClazz()
           
 java.util.Collection<CEnumConstant> getConstants()
           
 CCustomizations getCustomizations()
          Gets the list of customizations attached to this model component.
 javax.xml.namespace.QName getElementName()
           
 javax.activation.MimeType getExpectedMimeType()
          A TypeUse can have an associated MIME type.
 CTypeInfo getInfo()
          Individual item type.
 com.sun.xml.bind.v2.runtime.Location getLocation()
           
 org.xml.sax.Locator getLocator()
          Source line information that points to the place where this type-safe enum is defined.
 com.sun.xml.xsom.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()
           
 javax.xml.namespace.QName getTypeName()
           
 com.sun.xml.bind.v2.model.annotation.Locatable getUpstream()
           
 com.sun.xml.bind.v2.model.core.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()
          If the use can hold multiple values of the specified type.
 boolean isElement()
           
 boolean isPrimitive()
           
 boolean isSimpleType()
           
 boolean needsValueField()
          The spec says the value field in the enum class will be generated only under certain circumstances.
 com.sun.codemodel.JClass toType(Outline o, Aspect aspect)
          Returns the JClass that represents the class being bound, under the given Outline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

public final Model model
The Model object to which this bean belongs.


parent

public final CClassInfoParent parent
The parent into which the enum class should be generated.


shortName

public final java.lang.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 java.util.Collection<CEnumConstant> members
List of enum members.


javadoc

public java.lang.String javadoc
Constructor Detail

CEnumLeafInfo

public CEnumLeafInfo(Model model,
                     javax.xml.namespace.QName typeName,
                     CClassInfoParent container,
                     java.lang.String shortName,
                     CNonElement base,
                     java.util.Collection<CEnumConstant> _members,
                     com.sun.xml.xsom.XSComponent source,
                     CCustomizations customizations,
                     org.xml.sax.Locator _sourceLocator)
Method Detail

getLocator

public org.xml.sax.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 interface CCustomizable
Returns:
never null.

getTypeName

public javax.xml.namespace.QName getTypeName()
Specified by:
getTypeName in interface com.sun.xml.bind.v2.model.core.NonElement<NType,NClass>

getType

public NType getType()
Specified by:
getType in interface com.sun.xml.bind.v2.model.core.TypeInfo<NType,NClass>

canBeReferencedByIDREF

public boolean canBeReferencedByIDREF()
Deprecated. why are you calling the method whose return value is known?

Specified by:
canBeReferencedByIDREF in interface com.sun.xml.bind.v2.model.core.TypeInfo<NType,NClass>

isElement

public boolean isElement()
Specified by:
isElement in interface com.sun.xml.bind.v2.model.core.MaybeElement<NType,NClass>

getElementName

public javax.xml.namespace.QName getElementName()
Specified by:
getElementName in interface com.sun.xml.bind.v2.model.core.MaybeElement<NType,NClass>

asElement

public com.sun.xml.bind.v2.model.core.Element<NType,NClass> asElement()
Specified by:
asElement in interface com.sun.xml.bind.v2.model.core.MaybeElement<NType,NClass>

getClazz

public NClass getClazz()
Specified by:
getClazz in interface com.sun.xml.bind.v2.model.core.EnumLeafInfo<NType,NClass>

getSchemaComponent

public com.sun.xml.xsom.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 interface CCustomizable
Returns:
null if the model is built from sources other than XML Schema (such as DTD.)

toType

public com.sun.codemodel.JClass toType(Outline o,
                                       Aspect aspect)
Description copied from interface: CTypeInfo
Returns the JClass that represents the class being bound, under the given Outline.

Specified by:
toType in interface CTypeInfo
Specified by:
toType in interface NClass
Specified by:
toType in interface NType
aspect - If Aspect.IMPLEMENTATION, this method returns the implementation specific class that this type represents. If Aspect.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, Aspect)

isAbstract

public boolean isAbstract()
Specified by:
isAbstract in interface NClass

isBoxedType

public boolean isBoxedType()
Description copied from interface: NType
Returns true iff this type represents a class that has a unboxed form. For example, for String this is false, but for Integer this is true.

Specified by:
isBoxedType in interface NType

fullName

public java.lang.String fullName()
Description copied from interface: NType
Human readable name of this type.

Specified by:
fullName in interface NType

isPrimitive

public boolean isPrimitive()

isSimpleType

public boolean isSimpleType()
Specified by:
isSimpleType in interface com.sun.xml.bind.v2.model.core.NonElement<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 com.sun.codemodel.JExpression createConstant(Outline outline,
                                                    com.sun.xml.xsom.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 interface TypeUse
Returns:
null if the constant cannot be created for this TypeUse (such as when it's a collection)

isCollection

public boolean isCollection()
Description copied from interface: TypeUse
If the use can hold multiple values of the specified type.

Specified by:
isCollection in interface TypeUse

getAdapterUse

public CAdapter getAdapterUse()
Description copied from interface: TypeUse
If this type use is adapting the type, returns the adapter. Otherwise return null.

Specified by:
getAdapterUse in interface TypeUse

getInfo

public CTypeInfo getInfo()
Description copied from interface: TypeUse
Individual item type.

Specified by:
getInfo in interface TypeUse

idUse

public com.sun.xml.bind.v2.model.core.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 TypeUse.

Specified by:
idUse in interface TypeUse

getExpectedMimeType

public javax.activation.MimeType getExpectedMimeType()
Description copied from interface: TypeUse
A TypeUse can have an associated MIME type.

Specified by:
getExpectedMimeType in interface TypeUse

getConstants

public java.util.Collection<CEnumConstant> getConstants()
Specified by:
getConstants in interface com.sun.xml.bind.v2.model.core.EnumLeafInfo<NType,NClass>

getBaseType

public com.sun.xml.bind.v2.model.core.NonElement<NType,NClass> getBaseType()
Specified by:
getBaseType in interface com.sun.xml.bind.v2.model.core.EnumLeafInfo<NType,NClass>

getCustomizations

public CCustomizations getCustomizations()
Description copied from interface: CCustomizable
Gets the list of customizations attached to this model component.

Specified by:
getCustomizations in interface CCustomizable
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 com.sun.xml.bind.v2.model.annotation.Locatable getUpstream()
Specified by:
getUpstream in interface com.sun.xml.bind.v2.model.annotation.Locatable

getLocation

public com.sun.xml.bind.v2.runtime.Location getLocation()
Specified by:
getLocation in interface com.sun.xml.bind.v2.model.annotation.Locatable