|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.xml.bind.v2.runtime.JaxBeanInfo<BeanT>
public abstract class JaxBeanInfo<BeanT>
Encapsulates various JAXB operations on objects bound by JAXB. Immutable and thread-safe.
Each JAXB-bound class has a corresponding JaxBeanInfo
object,
which performs all the JAXB related operations on behalf of
the JAXB-bound object.
Given a class, the corresponding JaxBeanInfo
can be located
via JAXBContextImpl.getBeanInfo(Class,boolean)
.
Typically, JaxBeanInfo
implementations should be generated
by XJC/JXC. Those impl classes will register themselves to their
master ObjectFactory class.
The type parameter BeanT is the Java class of the bean that this represents.
Field Summary | |
---|---|
protected short |
flag
Various boolean flags combined into one field to improve memory footprint. |
java.lang.Class<BeanT> |
jaxbType
Gets the JAXB bound class type that this JaxBeanInfo
handles. |
javax.xml.namespace.QName |
typeName
Returns the XML Schema type name if the bean is mapped to/from a complex type of XML Schema. |
Constructor Summary | |
---|---|
protected |
JaxBeanInfo(JAXBContextImpl grammar,
RuntimeTypeInfo rti,
java.lang.Class<BeanT> jaxbType,
javax.xml.namespace.QName typeName,
boolean isElement,
boolean isImmutable,
boolean hasLifecycleEvents)
|
Method Summary | |
---|---|
abstract BeanT |
createInstance(UnmarshallingContext context)
Creates a new instance of the bean. |
abstract java.lang.String |
getElementLocalName(BeanT o)
Returns the local name portion of the element name, if the bean that this class represents is mapped from/to an XML element. |
abstract java.lang.String |
getElementNamespaceURI(BeanT o)
Returns the namespace URI portion of the element name, if the bean that this class represents is mapped from/to an XML element. |
abstract java.lang.String |
getId(BeanT o,
XMLSerializer target)
Gets the ID value of the given bean, if it has an ID value. |
LifecycleMethods |
getLifecycleMethods()
Return the LifecycleMethods cache for this ClassBeanInfo's corresponding jaxbType if it exists, else return null. |
abstract Loader |
getLoader(JAXBContextImpl context,
boolean typeSubstitutionCapable)
Gets the Loader that will unmarshall the given object. |
abstract Transducer<BeanT> |
getTransducer()
If the bean's representation in XML is just a text, this method return a Transducer that lets you convert
values between the text and the bean. |
boolean |
hasAfterMarshalMethod()
True if jaxbType has the lifecycle method. |
boolean |
hasAfterUnmarshalMethod()
True if jaxbType has the lifecycle method. |
boolean |
hasBeforeMarshalMethod()
True if jaxbType has the lifecycle method. |
boolean |
hasBeforeUnmarshalMethod()
True if jaxbType has the lifecycle method. |
boolean |
hasElementOnlyContentModel()
True if this bean has an element-only content model. |
protected void |
hasElementOnlyContentModel(boolean value)
True if this bean has an element-only content model. |
void |
invokeAfterUnmarshalMethod(UnmarshallerImpl unm,
java.lang.Object child,
java.lang.Object parent)
Invokes the afterUnmarshal method if applicable. |
void |
invokeBeforeUnmarshalMethod(UnmarshallerImpl unm,
java.lang.Object child,
java.lang.Object parent)
Invokes the beforeUnmarshal method if applicable. |
boolean |
isElement()
Returns true if the bean is mapped to/from an XML element. |
boolean |
isImmutable()
Returns true if the bean is immutable. |
protected void |
link(JAXBContextImpl grammar)
Called after all the JaxBeanInfo s are created. |
boolean |
lookForLifecycleMethods()
This method is used to determine which of the sub-classes should be interrogated for the existence of lifecycle methods. |
abstract boolean |
reset(BeanT o,
UnmarshallingContext context)
Resets the object to the initial state, as if the object is created fresh. |
abstract void |
serializeAttributes(BeanT o,
XMLSerializer target)
Serializes attributes into the specified target. |
abstract void |
serializeBody(BeanT o,
XMLSerializer target)
Serializes child elements and texts into the specified target. |
abstract void |
serializeRoot(BeanT o,
XMLSerializer target)
Serializes the bean as the root element. |
abstract void |
serializeURIs(BeanT o,
XMLSerializer target)
Declares all the namespace URIs this object is using at its top-level scope into the specified target. |
protected void |
setLifecycleFlags()
use reflection to determine which of the 4 object lifecycle methods exist on the JAXB bound type. |
void |
wrapUp()
Called at the end of the JAXBContext initialization phase
to clean up any unnecessary references. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected short flag
public final java.lang.Class<BeanT> jaxbType
JaxBeanInfo
handles.
IOW, when a bean info object is requested for T, sometimes the bean info for one of its base classes might be returned.
public final javax.xml.namespace.QName typeName
This is an ugly necessity to correctly handle the type substitution semantics of XML Schema.
A single Java class maybe mapped to more than one XML types. This method returns the "primary type" for that Java class, which we use when we marshal.
null if the class is not bound to a schema type.
Constructor Detail |
---|
protected JaxBeanInfo(JAXBContextImpl grammar, RuntimeTypeInfo rti, java.lang.Class<BeanT> jaxbType, javax.xml.namespace.QName typeName, boolean isElement, boolean isImmutable, boolean hasLifecycleEvents)
Method Detail |
---|
public final boolean hasBeforeUnmarshalMethod()
jaxbType
has the lifecycle method.
public final boolean hasAfterUnmarshalMethod()
jaxbType
has the lifecycle method.
public final boolean hasBeforeMarshalMethod()
jaxbType
has the lifecycle method.
public final boolean hasAfterMarshalMethod()
jaxbType
has the lifecycle method.
public final boolean isElement()
When this method returns true, getElementNamespaceURI(Object)
and getElementLocalName(Object)
returns the element name of
the bean.
public final boolean isImmutable()
If this is true, Binder won't try to ueuse this object, and the unmarshaller won't create a new instance of it before it starts.
public final boolean hasElementOnlyContentModel()
If this flag is true, the unmarshaller can work faster by ignoring whitespaces more efficiently.
protected final void hasElementOnlyContentModel(boolean value)
Should be considered immutable, though I can't mark it final because it cannot be computed in this constructor.
public boolean lookForLifecycleMethods()
public abstract java.lang.String getElementNamespaceURI(BeanT o)
java.lang.UnsupportedOperationException
- if isElement()
is false.public abstract java.lang.String getElementLocalName(BeanT o)
java.lang.UnsupportedOperationException
- if isElement()
is false.public abstract BeanT createInstance(UnmarshallingContext context) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException, org.xml.sax.SAXException
This operation is only supported when isImmutable()
is false.
context
- Sometimes the created bean remembers the corresponding source location,
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
org.xml.sax.SAXException
public abstract boolean reset(BeanT o, UnmarshallingContext context) throws org.xml.sax.SAXException
This is used to reuse an existing object for unmarshalling.
context
- used for reporting any errors.
If the object is resettable but failed by an error, it should be reported to the context, then return false. If the object is not resettable to begin with, do not report an error.
org.xml.sax.SAXException
- as a result of reporting an error, the context may throw a SAXException
.public abstract java.lang.String getId(BeanT o, XMLSerializer target) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public abstract void serializeBody(BeanT o, XMLSerializer target) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.stream.XMLStreamException
org.xml.sax.SAXException
java.io.IOException
javax.xml.stream.XMLStreamException
public abstract void serializeAttributes(BeanT o, XMLSerializer target) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.stream.XMLStreamException
org.xml.sax.SAXException
java.io.IOException
javax.xml.stream.XMLStreamException
public abstract void serializeRoot(BeanT o, XMLSerializer target) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.stream.XMLStreamException
In the java-to-schema binding, an object might marshal in two different ways depending on whether it is used as the root of the graph or not. In the former case, an object could marshal as an element, whereas in the latter case, it marshals as a type.
This method is used to marshal the root of the object graph to allow this semantics to be implemented.
It is doubtful to me if it's a good idea for an object to marshal in two ways depending on the context.
For schema-to-java, this is equivalent to serializeBody(Object, XMLSerializer)
.
org.xml.sax.SAXException
java.io.IOException
javax.xml.stream.XMLStreamException
public abstract void serializeURIs(BeanT o, XMLSerializer target) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public abstract Loader getLoader(JAXBContextImpl context, boolean typeSubstitutionCapable)
Loader
that will unmarshall the given object.
context
- The JAXBContextImpl
object that governs this object.
This object is taken as a parameter so that JaxBeanInfo
doesn't have
to store them on its own.
When this method is invoked from within the unmarshaller, tihs parameter can be
null (because the loader is constructed already.)typeSubstitutionCapable
- If true, the returned Loader
is capable of recognizing @xsi:type (if necessary)
and unmarshals a subtype. This allowes an optimization where this bean info
is guaranteed not to have a type substitution.
If false, the returned Loader
doesn't look for @xsi:type.
public abstract Transducer<BeanT> getTransducer()
Transducer
that lets you convert
values between the text and the bean.
protected void link(JAXBContextImpl grammar)
JaxBeanInfo
s are created.
grammar
- public void wrapUp()
JAXBContext
initialization phase
to clean up any unnecessary references.
protected final void setLifecycleFlags()
public final LifecycleMethods getLifecycleMethods()
public final void invokeBeforeUnmarshalMethod(UnmarshallerImpl unm, java.lang.Object child, java.lang.Object parent) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public final void invokeAfterUnmarshalMethod(UnmarshallerImpl unm, java.lang.Object child, java.lang.Object parent) throws org.xml.sax.SAXException
org.xml.sax.SAXException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |