com.sun.xml.bind.v2.model.impl
Class RuntimeEnumLeafInfoImpl<T extends Enum<T>,B>

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<Type,Class,Field,Method>
          extended by com.sun.xml.bind.v2.model.impl.RuntimeEnumLeafInfoImpl<T,B>
All Implemented Interfaces:
Locatable, Element<Type,Class>, EnumLeafInfo<Type,Class>, LeafInfo<Type,Class>, MaybeElement<Type,Class>, NonElement<Type,Class>, TypeInfo<Type,Class>, RuntimeEnumLeafInfo, RuntimeLeafInfo, RuntimeNonElement, RuntimeTypeInfo, Transducer<T>, Iterable<EnumConstantImpl<Type,Class,Field,Method>>

final class RuntimeEnumLeafInfoImpl<T extends Enum<T>,B>
extends EnumLeafInfoImpl<Type,Class,Field,Method>
implements RuntimeEnumLeafInfo, Transducer<T>


Field Summary
 
Fields inherited from class com.sun.xml.bind.v2.model.impl.EnumLeafInfoImpl
baseType, clazz
 
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
RuntimeEnumLeafInfoImpl(RuntimeModelBuilder builder, Locatable upstream, Class<T> enumType)
           
 
Method Summary
 RuntimeEnumConstantImpl createEnumConstant(String name, String literal, Field constant, EnumConstantImpl<Type,Class,Field,Method> last)
           
 void declareNamespace(T t, XMLSerializer w)
          Declares the namespace URIs used in the given value to w.
 Class getClazz()
          The same as TypeInfo.getType() but an EnumLeafInfo is guaranteed to represent an enum declaration, which is a kind of a class declaration.
 Transducer<T> getTransducer()
          This method doesn't take the reference properties defined on RuntimeNonElementRef into account (such as ID-ness.)
 QName getTypeName(T instance)
          Transducers implicitly work against a single XML type, but sometimes (most notably XMLGregorianCalendar, an instance may choose different XML types.
 QName[] getTypeNames()
          Returns all the type names recognized by this type for unmarshalling.
 boolean isDefault()
          If this Transducer is the default transducer for the ValueT, this method returns true.
 T parse(CharSequence lexical)
          Converts the lexical representation to a value object.
 CharSequence print(T t)
          Converts the given value to its lexical representation.
 boolean useNamespace()
          If true, this Transducer doesn't declare any namespace, and therefore Transducer.declareNamespace(Object, XMLSerializer) is no-op.
 void writeLeafElement(XMLSerializer w, Name tagName, T o, String fieldName)
          Sends the result of the Transducer.print(Object) operation to one of the XMLSerializer.leafElement(Name, String, String) method.
 void writeText(XMLSerializer w, T t, String fieldName)
          Sends the result of the Transducer.print(Object) operation to one of the XMLSerializer.text(String, String) method, but with the best representation of the value, not necessarily String.
 
Methods inherited from class com.sun.xml.bind.v2.model.impl.EnumLeafInfoImpl
asElement, calcConstants, canBeReferencedByIDREF, getBaseType, getConstants, getElementName, getLocation, getScope, getSubstitutionHead, getType, getTypeName, isElement, isSimpleType, iterator, 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.core.EnumLeafInfo
getBaseType, getConstants
 
Methods inherited from interface com.sun.xml.bind.v2.model.core.MaybeElement
asElement, getElementName, isElement
 
Methods inherited from interface com.sun.xml.bind.v2.model.core.NonElement
getTypeName, isSimpleType
 
Methods inherited from interface com.sun.xml.bind.v2.model.core.TypeInfo
canBeReferencedByIDREF, getType
 
Methods inherited from interface com.sun.xml.bind.v2.model.annotation.Locatable
getLocation, getUpstream
 

Constructor Detail

RuntimeEnumLeafInfoImpl

RuntimeEnumLeafInfoImpl(RuntimeModelBuilder builder,
                        Locatable upstream,
                        Class<T> enumType)
Method Detail

getTransducer

public Transducer<T> getTransducer()
Description copied from interface: RuntimeLeafInfo
This method doesn't take the reference properties defined on RuntimeNonElementRef into account (such as ID-ness.)

Specified by:
getTransducer in interface RuntimeLeafInfo
Specified by:
getTransducer in interface RuntimeNonElement
Returns:
always non-null.
See Also:
RuntimeNonElementRef.getTransducer()

createEnumConstant

public RuntimeEnumConstantImpl createEnumConstant(String name,
                                                  String literal,
                                                  Field constant,
                                                  EnumConstantImpl<Type,Class,Field,Method> last)
Overrides:
createEnumConstant in class EnumLeafInfoImpl<Type,Class,Field,Method>

getTypeNames

public QName[] getTypeNames()
Description copied from interface: RuntimeLeafInfo
Returns all the type names recognized by this type for unmarshalling.

While conceptually this method belongs to RuntimeNonElement, if we do that we have to put a lot of dummy implementations everywhere, so it's placed here, where it's actually needed.

Specified by:
getTypeNames in interface RuntimeLeafInfo
Returns:
Always non-null. Do not modify the returned array.

isDefault

public boolean isDefault()
Description copied from interface: Transducer
If this Transducer is the default transducer for the ValueT, this method returns true. Used exclusively by OptimizedTransducedAccessorFactory.get(RuntimePropertyInfo)

Specified by:
isDefault in interface Transducer<T extends Enum<T>>

getClazz

public Class 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<Type,Class>
Specified by:
getClazz in interface RuntimeLeafInfo
Overrides:
getClazz in class EnumLeafInfoImpl<Type,Class,Field,Method>
Returns:
always non-null.

useNamespace

public boolean useNamespace()
Description copied from interface: Transducer
If true, this Transducer doesn't declare any namespace, and therefore Transducer.declareNamespace(Object, XMLSerializer) is no-op. It also means that the Transducer.parse(CharSequence) method won't use the context parameter.

Specified by:
useNamespace in interface Transducer<T extends Enum<T>>

declareNamespace

public void declareNamespace(T t,
                             XMLSerializer w)
                      throws AccessorException
Description copied from interface: Transducer
Declares the namespace URIs used in the given value to w.

Specified by:
declareNamespace in interface Transducer<T extends Enum<T>>
Parameters:
t - never be null.
w - may be null if !{@link #useNamespace()}.
Throws:
AccessorException

print

public CharSequence print(T t)
                   throws AccessorException
Description copied from interface: Transducer
Converts the given value to its lexical representation.

Specified by:
print in interface Transducer<T extends Enum<T>>
Parameters:
t - never be null.
Returns:
always non-null valid lexical representation.
Throws:
AccessorException

parse

public T parse(CharSequence lexical)
                        throws AccessorException,
                               SAXException
Description copied from interface: Transducer
Converts the lexical representation to a value object.

Specified by:
parse in interface Transducer<T extends Enum<T>>
Parameters:
lexical - never be null.
Throws:
AccessorException - if the transducer is used to parse an user bean that uses XmlValue, then this exception may occur when it tries to set the leaf value to the bean.
SAXException - if the lexical form is incorrect, the error should be reported and SAXException may thrown (or it can return null to recover.)

writeText

public void writeText(XMLSerializer w,
                      T t,
                      String fieldName)
               throws IOException,
                      SAXException,
                      javax.xml.stream.XMLStreamException,
                      AccessorException
Description copied from interface: Transducer
Sends the result of the Transducer.print(Object) operation to one of the XMLSerializer.text(String, String) method, but with the best representation of the value, not necessarily String.

Specified by:
writeText in interface Transducer<T extends Enum<T>>
Throws:
IOException
SAXException
javax.xml.stream.XMLStreamException
AccessorException

writeLeafElement

public void writeLeafElement(XMLSerializer w,
                             Name tagName,
                             T o,
                             String fieldName)
                      throws IOException,
                             SAXException,
                             javax.xml.stream.XMLStreamException,
                             AccessorException
Description copied from interface: Transducer
Sends the result of the Transducer.print(Object) operation to one of the XMLSerializer.leafElement(Name, String, String) method. but with the best representation of the value, not necessarily String.

Specified by:
writeLeafElement in interface Transducer<T extends Enum<T>>
Throws:
IOException
SAXException
javax.xml.stream.XMLStreamException
AccessorException

getTypeName

public QName getTypeName(T instance)
Description copied from interface: Transducer
Transducers implicitly work against a single XML type, but sometimes (most notably XMLGregorianCalendar, an instance may choose different XML types.

Specified by:
getTypeName in interface Transducer<T extends Enum<T>>
Returns:
return non-null from this method allows transducers to specify the type it wants to marshal to. Most of the time this method returns null, in which case the implicitly associated type will be used.