Class ElementBeanInfoImpl
JaxBeanInfo
implementation for RuntimeElementInfo
.- Author:
- Kohsuke Kawaguchi
-
Field Summary
FieldsFields inherited from class com.sun.xml.bind.v2.runtime.JaxBeanInfo
flag, isNilIncluded, jaxbType
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ElementBeanInfoImpl
(JAXBContextImpl grammar) The constructor for the sole instanceofJaxBeanInfo
for handling user-createdJAXBElement
. -
Method Summary
Modifier and TypeMethodDescriptionfinal JAXBElement
createInstance
(UnmarshallingContext context) Creates a new instance of the bean.final JAXBElement
Returns the local name portion of the element name, if the bean that this class represents is mapped from/to an XML element.Returns the namespace URI portion of the element name, if the bean that this class represents is mapped from/to an XML element.getId
(JAXBElement e, XMLSerializer target) Gets the ID value of the given bean, if it has an ID value.getLoader
(JAXBContextImpl context, boolean typeSubstitutionCapable) Gets theLoader
that will unmarshall the given object.final Transducer<JAXBElement>
If the bean's representation in XML is just a text, this method return aTransducer
that lets you convert values between the text and the bean.void
link
(JAXBContextImpl grammar) Called after all theJaxBeanInfo
s are created.boolean
reset
(JAXBElement e, UnmarshallingContext context) Resets the object to the initial state, as if the object is created fresh.void
serializeAttributes
(JAXBElement e, XMLSerializer target) Serializes attributes into the specified target.void
serializeBody
(JAXBElement element, XMLSerializer target) Serializes child elements and texts into the specified target.void
serializeRoot
(JAXBElement e, XMLSerializer target) Serializes the bean as the root element.void
serializeURIs
(JAXBElement e, XMLSerializer target) Declares all the namespace URIs this object is using at its top-level scope into the specified target.void
wrapUp()
Called at the end of theJAXBContext
initialization phase to clean up any unnecessary references.Methods inherited from class com.sun.xml.bind.v2.runtime.JaxBeanInfo
getLifecycleMethods, getTypeName, getTypeNames, hasAfterMarshalMethod, hasAfterUnmarshalMethod, hasBeforeMarshalMethod, hasBeforeUnmarshalMethod, hasElementOnlyContentModel, hasElementOnlyContentModel, invokeAfterUnmarshalMethod, invokeBeforeUnmarshalMethod, isElement, isImmutable, isNilIncluded, lookForLifecycleMethods, setLifecycleFlags
-
Field Details
-
expectedType
-
-
Constructor Details
-
ElementBeanInfoImpl
The constructor for the sole instanceofJaxBeanInfo
for handling user-createdJAXBElement
. SuchJaxBeanInfo
is used only for marshalling. This is a hack.
-
-
Method Details
-
getElementNamespaceURI
Description copied from class:JaxBeanInfo
Returns the namespace URI portion of the element name, if the bean that this class represents is mapped from/to an XML element.- Specified by:
getElementNamespaceURI
in classJaxBeanInfo<JAXBElement>
-
getElementLocalName
Description copied from class:JaxBeanInfo
Returns the local name portion of the element name, if the bean that this class represents is mapped from/to an XML element.- Specified by:
getElementLocalName
in classJaxBeanInfo<JAXBElement>
-
getLoader
Description copied from class:JaxBeanInfo
Gets theLoader
that will unmarshall the given object.- Specified by:
getLoader
in classJaxBeanInfo<JAXBElement>
- Parameters:
context
- TheJAXBContextImpl
object that governs this object. This object is taken as a parameter so thatJaxBeanInfo
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 returnedLoader
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 returnedLoader
doesn't look for @xsi:type.- Returns:
- must return non-null valid object
-
createInstance
public final JAXBElement createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException Description copied from class:JaxBeanInfo
Creates a new instance of the bean.This operation is only supported when
JaxBeanInfo.isImmutable()
is false.- Specified by:
createInstance
in classJaxBeanInfo<JAXBElement>
- Parameters:
context
- Sometimes the created bean remembers the corresponding source location,- Throws:
IllegalAccessException
InvocationTargetException
InstantiationException
-
createInstanceFromValue
public final JAXBElement createInstanceFromValue(Object o) throws IllegalAccessException, InvocationTargetException, InstantiationException -
reset
Description copied from class:JaxBeanInfo
Resets the object to the initial state, as if the object is created fresh.This is used to reuse an existing object for unmarshalling.
- Specified by:
reset
in classJaxBeanInfo<JAXBElement>
context
- used for reporting any errors.- Returns:
- true if the object was successfuly resetted.
False if the object is not resettable, in which case the object will be
discarded and new one will be created.
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.
-
getId
Description copied from class:JaxBeanInfo
Gets the ID value of the given bean, if it has an ID value. Otherwise return null.- Specified by:
getId
in classJaxBeanInfo<JAXBElement>
-
serializeBody
public void serializeBody(JAXBElement element, XMLSerializer target) throws SAXException, IOException, XMLStreamException Description copied from class:JaxBeanInfo
Serializes child elements and texts into the specified target.- Specified by:
serializeBody
in classJaxBeanInfo<JAXBElement>
- Throws:
SAXException
IOException
XMLStreamException
-
serializeRoot
public void serializeRoot(JAXBElement e, XMLSerializer target) throws SAXException, IOException, XMLStreamException Description copied from class:JaxBeanInfo
Serializes the bean as the root element.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
JaxBeanInfo.serializeBody(Object, XMLSerializer)
.- Specified by:
serializeRoot
in classJaxBeanInfo<JAXBElement>
- Throws:
SAXException
IOException
XMLStreamException
-
serializeAttributes
Description copied from class:JaxBeanInfo
Serializes attributes into the specified target.- Specified by:
serializeAttributes
in classJaxBeanInfo<JAXBElement>
-
serializeURIs
Description copied from class:JaxBeanInfo
Declares all the namespace URIs this object is using at its top-level scope into the specified target.- Specified by:
serializeURIs
in classJaxBeanInfo<JAXBElement>
-
getTransducer
Description copied from class:JaxBeanInfo
If the bean's representation in XML is just a text, this method return aTransducer
that lets you convert values between the text and the bean.- Specified by:
getTransducer
in classJaxBeanInfo<JAXBElement>
-
wrapUp
public void wrapUp()Description copied from class:JaxBeanInfo
Called at the end of theJAXBContext
initialization phase to clean up any unnecessary references.- Overrides:
wrapUp
in classJaxBeanInfo<JAXBElement>
-
link
Description copied from class:JaxBeanInfo
Called after all theJaxBeanInfo
s are created.- Overrides:
link
in classJaxBeanInfo<JAXBElement>
-