- java.lang.Object
-
- org.glassfish.jaxb.runtime.v2.runtime.JaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
- org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl
-
public final class ElementBeanInfoImpl extends JaxBeanInfo<jakarta.xml.bind.JAXBElement>
JaxBeanInfoimplementation forRuntimeElementInfo.- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
Fields Modifier and Type Field Description ClassexpectedType-
Fields inherited from class org.glassfish.jaxb.runtime.v2.runtime.JaxBeanInfo
flag, isNilIncluded, jaxbType
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedElementBeanInfoImpl(JAXBContextImpl grammar)The constructor for the sole instanceofJaxBeanInfofor handling user-createdJAXBElement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.xml.bind.JAXBElementcreateInstance(UnmarshallingContext context)Creates a new instance of the bean.jakarta.xml.bind.JAXBElementcreateInstanceFromValue(Object o)StringgetElementLocalName(jakarta.xml.bind.JAXBElement e)Returns the local name portion of the element name, if the bean that this class represents is mapped from/to an XML element.StringgetElementNamespaceURI(jakarta.xml.bind.JAXBElement e)Returns the namespace URI portion of the element name, if the bean that this class represents is mapped from/to an XML element.StringgetId(jakarta.xml.bind.JAXBElement e, XMLSerializer target)Gets the ID value of the given bean, if it has an ID value.LoadergetLoader(JAXBContextImpl context, boolean typeSubstitutionCapable)Gets theLoaderthat will unmarshall the given object.Transducer<jakarta.xml.bind.JAXBElement>getTransducer()If the bean's representation in XML is just a text, this method return aTransducerthat lets you convert values between the text and the bean.voidlink(JAXBContextImpl grammar)Called after all theJaxBeanInfos are created.booleanreset(jakarta.xml.bind.JAXBElement e, UnmarshallingContext context)Resets the object to the initial state, as if the object is created fresh.voidserializeAttributes(jakarta.xml.bind.JAXBElement e, XMLSerializer target)Serializes attributes into the specified target.voidserializeBody(jakarta.xml.bind.JAXBElement element, XMLSerializer target)Serializes child elements and texts into the specified target.voidserializeRoot(jakarta.xml.bind.JAXBElement e, XMLSerializer target)Serializes the bean as the root element.voidserializeURIs(jakarta.xml.bind.JAXBElement e, XMLSerializer target)Declares all the namespace URIs this object is using at its top-level scope into the specified target.voidwrapUp()Called at the end of theJAXBContextinitialization phase to clean up any unnecessary references.-
Methods inherited from class org.glassfish.jaxb.runtime.v2.runtime.JaxBeanInfo
getLifecycleMethods, getTypeName, getTypeNames, hasAfterMarshalMethod, hasAfterUnmarshalMethod, hasBeforeMarshalMethod, hasBeforeUnmarshalMethod, hasElementOnlyContentModel, hasElementOnlyContentModel, invokeAfterUnmarshalMethod, invokeBeforeUnmarshalMethod, isElement, isImmutable, isNilIncluded, lookForLifecycleMethods, setLifecycleFlags
-
-
-
-
Field Detail
-
expectedType
public final Class expectedType
-
-
Constructor Detail
-
ElementBeanInfoImpl
protected ElementBeanInfoImpl(JAXBContextImpl grammar)
The constructor for the sole instanceofJaxBeanInfofor handling user-createdJAXBElement. SuchJaxBeanInfois used only for marshalling. This is a hack.
-
-
Method Detail
-
getElementNamespaceURI
public String getElementNamespaceURI(jakarta.xml.bind.JAXBElement e)
Description copied from class:JaxBeanInfoReturns the namespace URI portion of the element name, if the bean that this class represents is mapped from/to an XML element.- Specified by:
getElementNamespaceURIin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
getElementLocalName
public String getElementLocalName(jakarta.xml.bind.JAXBElement e)
Description copied from class:JaxBeanInfoReturns the local name portion of the element name, if the bean that this class represents is mapped from/to an XML element.- Specified by:
getElementLocalNamein classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
getLoader
public Loader getLoader(JAXBContextImpl context, boolean typeSubstitutionCapable)
Description copied from class:JaxBeanInfoGets theLoaderthat will unmarshall the given object.- Specified by:
getLoaderin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>- Parameters:
context- TheJAXBContextImplobject that governs this object. This object is taken as a parameter so thatJaxBeanInfodoesn'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 returnedLoaderis 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 returnedLoaderdoesn't look for @xsi:type.- Returns:
- must return non-null valid object
-
createInstance
public final jakarta.xml.bind.JAXBElement createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException
Description copied from class:JaxBeanInfoCreates a new instance of the bean.This operation is only supported when
JaxBeanInfo.isImmutable()is false.- Specified by:
createInstancein classJaxBeanInfo<jakarta.xml.bind.JAXBElement>- Parameters:
context- Sometimes the created bean remembers the corresponding source location,- Throws:
IllegalAccessExceptionInvocationTargetExceptionInstantiationException
-
createInstanceFromValue
public final jakarta.xml.bind.JAXBElement createInstanceFromValue(Object o) throws IllegalAccessException, InvocationTargetException, InstantiationException
-
reset
public boolean reset(jakarta.xml.bind.JAXBElement e, UnmarshallingContext context)Description copied from class:JaxBeanInfoResets 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:
resetin classJaxBeanInfo<jakarta.xml.bind.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
public String getId(jakarta.xml.bind.JAXBElement e, XMLSerializer target)
Description copied from class:JaxBeanInfoGets the ID value of the given bean, if it has an ID value. Otherwise return null.- Specified by:
getIdin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
serializeBody
public void serializeBody(jakarta.xml.bind.JAXBElement element, XMLSerializer target) throws SAXException, IOException, XMLStreamExceptionDescription copied from class:JaxBeanInfoSerializes child elements and texts into the specified target.- Specified by:
serializeBodyin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>- Throws:
SAXExceptionIOExceptionXMLStreamException
-
serializeRoot
public void serializeRoot(jakarta.xml.bind.JAXBElement e, XMLSerializer target) throws SAXException, IOException, XMLStreamExceptionDescription copied from class:JaxBeanInfoSerializes 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:
serializeRootin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>- Throws:
SAXExceptionIOExceptionXMLStreamException
-
serializeAttributes
public void serializeAttributes(jakarta.xml.bind.JAXBElement e, XMLSerializer target)Description copied from class:JaxBeanInfoSerializes attributes into the specified target.- Specified by:
serializeAttributesin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
serializeURIs
public void serializeURIs(jakarta.xml.bind.JAXBElement e, XMLSerializer target)Description copied from class:JaxBeanInfoDeclares all the namespace URIs this object is using at its top-level scope into the specified target.- Specified by:
serializeURIsin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
getTransducer
public final Transducer<jakarta.xml.bind.JAXBElement> getTransducer()
Description copied from class:JaxBeanInfoIf the bean's representation in XML is just a text, this method return aTransducerthat lets you convert values between the text and the bean.- Specified by:
getTransducerin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
wrapUp
public void wrapUp()
Description copied from class:JaxBeanInfoCalled at the end of theJAXBContextinitialization phase to clean up any unnecessary references.- Overrides:
wrapUpin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
link
public void link(JAXBContextImpl grammar)
Description copied from class:JaxBeanInfoCalled after all theJaxBeanInfos are created.- Overrides:
linkin classJaxBeanInfo<jakarta.xml.bind.JAXBElement>
-
-