com.sun.xml.bind.v2.model.impl
Class EnumLeafInfoImpl<T,C,F,M>

java.lang.Object
  extended by com.sun.xml.bind.v2.model.impl.TypeInfoImpl<T,C,F,M>
      extended by com.sun.xml.bind.v2.model.impl.EnumLeafInfoImpl<T,C,F,M>
All Implemented Interfaces:
Locatable, Element<T,C>, EnumLeafInfo<T,C>, LeafInfo<T,C>, MaybeElement<T,C>, NonElement<T,C>, TypeInfo<T,C>, Iterable<EnumConstantImpl<T,C,F,M>>
Direct Known Subclasses:
RuntimeEnumLeafInfoImpl

 class EnumLeafInfoImpl<T,C,F,M>
extends TypeInfoImpl<T,C,F,M>
implements EnumLeafInfo<T,C>, Element<T,C>, Iterable<EnumConstantImpl<T,C,F,M>>

EnumLeafInfo implementation.


Field Summary
(package private)  NonElement<T,C> baseType
           
(package private)  C clazz
          The enum class whose information this object represents.
 
Fields inherited from class com.sun.xml.bind.v2.model.impl.TypeInfoImpl
builder, owner
 
Fields inherited from interface com.sun.xml.bind.v2.model.core.NonElement
ANYTYPE_NAME
 
Constructor Summary
EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C clazz, T type)
           
 
Method Summary
 Element<T,C> asElement()
          Returns the Element aspect of this ClassInfo.
protected  void calcConstants()
          Build EnumConstants and discover/report any error in it.
 boolean canBeReferencedByIDREF()
          Deprecated. why are you calling a method whose return value is always known?
protected  EnumConstantImpl<T,C,F,M> createEnumConstant(String name, String literal, F constant, EnumConstantImpl<T,C,F,M> last)
           
 NonElement<T,C> getBaseType()
          Returns the base type of the enumeration.
 C getClazz()
          The same as TypeInfo.getType() but an EnumLeafInfo is guaranteed to represent an enum declaration, which is a kind of a class declaration.
 Iterable<? extends EnumConstantImpl<T,C,F,M>> getConstants()
          Returns the read-only list of enumeration constants.
 QName getElementName()
          Gets the element name of the class, if the class is bound to an element.
 Location getLocation()
          Gets the location object that this object points to.
 ClassInfo<T,C> getScope()
          Deprecated. you shouldn't be invoking this method on ClassInfoImpl.
 Element<T,C> getSubstitutionHead()
          Deprecated. if you are invoking this method directly, there's something wrong.
 T getType()
          Gets the underlying Java type that object represents.
 QName getTypeName()
          Gets the primary XML type ANYTYPE_NAME of the class.
 boolean isElement()
          If the class is bound to an element, return true.
 boolean isSimpleType()
          Returns true if this NonElement maps to text in XML, without any attribute nor child elements.
 Iterator<EnumConstantImpl<T,C,F,M>> iterator()
           
 void link()
           
 
Methods inherited from class com.sun.xml.bind.v2.model.impl.TypeInfoImpl
getUpstream, nav, parseElementName, parseTypeName, parseTypeName, reader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.xml.bind.v2.model.annotation.Locatable
getUpstream
 

Field Detail

clazz

final C clazz
The enum class whose information this object represents.


baseType

NonElement<T,C> baseType
Constructor Detail

EnumLeafInfoImpl

public EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder,
                        Locatable upstream,
                        C clazz,
                        T type)
Parameters:
clazz -
type - clazz and type should both point to the enum class that this EnumLeafInfo represents. Because of the type parameterization we have to take them separately.
Method Detail

calcConstants

protected void calcConstants()
Build EnumConstants and discover/report any error in it.


createEnumConstant

protected EnumConstantImpl<T,C,F,M> createEnumConstant(String name,
                                                       String literal,
                                                       F constant,
                                                       EnumConstantImpl<T,C,F,M> last)

getType

public T getType()
Description copied from interface: TypeInfo
Gets the underlying Java type that object represents.

Specified by:
getType in interface TypeInfo<T,C>
Returns:
always non-null.

canBeReferencedByIDREF

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

Leaf-type cannot be referenced from IDREF.

Specified by:
canBeReferencedByIDREF in interface TypeInfo<T,C>

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 interface NonElement<T,C>
Returns:
null if the object doesn't have an explicit type ANYTYPE_NAME (AKA anonymous.)

getClazz

public C getClazz()
Description copied from interface: EnumLeafInfo
The same as TypeInfo.getType() but an EnumLeafInfo is guaranteed to represent an enum declaration, which is a kind of a class declaration.

Specified by:
getClazz in interface EnumLeafInfo<T,C>
Returns:
always non-null.

getBaseType

public NonElement<T,C> getBaseType()
Description copied from interface: EnumLeafInfo
Returns the base type of the enumeration.

For example, with the following enum class, this method returns BuiltinLeafInfo for Integer.

 &XmlEnum(Integer.class)
 enum Foo {
   &XmlEnumValue("1")
   ONE,
   &XmlEnumValue("2")
   TWO
 }
 

Specified by:
getBaseType in interface EnumLeafInfo<T,C>
Returns:
never null.

isSimpleType

public boolean isSimpleType()
Description copied from interface: NonElement
Returns true if this NonElement maps to text in XML, without any attribute nor child elements.

Specified by:
isSimpleType in interface NonElement<T,C>

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 interface Locatable

getConstants

public Iterable<? extends EnumConstantImpl<T,C,F,M>> getConstants()
Description copied from interface: EnumLeafInfo
Returns the read-only list of enumeration constants.

Specified by:
getConstants in interface EnumLeafInfo<T,C>
Returns:
never null. Can be empty (really?).

link

public void link()
Overrides:
link in class TypeInfoImpl<T,C,F,M>

getSubstitutionHead

public Element<T,C> getSubstitutionHead()
Deprecated. if you are invoking this method directly, there's something wrong.

No substitution.

Specified by:
getSubstitutionHead in interface Element<T,C>
Returns:
null if no such element exists.

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 interface Element<T,C>
Specified by:
getElementName in interface MaybeElement<T,C>
Returns:
non-null iff MaybeElement.isElement().

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 interface MaybeElement<T,C>

asElement

public Element<T,C> asElement()
Description copied from interface: MaybeElement
Returns the Element aspect of this ClassInfo.

Specified by:
asElement in interface MaybeElement<T,C>
Returns:
null if MaybeElement.isElement()==false, non-null if MaybeElement.isElement()==true.

getScope

public ClassInfo<T,C> getScope()
Deprecated. you shouldn't be invoking this method on ClassInfoImpl.

When a bean binds to an element, it's always through XmlRootElement, so this method always return null.

Specified by:
getScope in interface Element<T,C>

iterator

public Iterator<EnumConstantImpl<T,C,F,M>> iterator()
Specified by:
iterator in interface Iterable<EnumConstantImpl<T,C,F,M>>