XmlOutput.
This object coordinates the overall marshalling efforts across different content-tree objects and different target formats.
The following CFG gives the proper sequence of method invocation.
MARSHALLING := ELEMENT
ELEMENT := "startElement" NSDECL* "endNamespaceDecls"
ATTRIBUTE* "endAttributes" BODY "endElement"
NSDECL := "declareNamespace"
ATTRIBUTE := "attribute"
ATTVALUES := "text"*
BODY := ( "text" | ELEMENT )*
A marshalling of one element consists of two stages. The first stage is for marshalling attributes and collecting namespace declarations. The second stage is for marshalling characters/child elements of that element.
Observe that multiple invocation of "text" is allowed.
Also observe that the namespace declarations are allowed only between "startElement" and "endAttributes".
IOException, SAXException, and XMLStreamException
are thrown from XmlOutput. They are always considered fatal, and
therefore caught only by MarshallerImpl.
AccessorException can be thrown when an access to a property/field
fails, and this is considered as a recoverable error, so it's caught everywhere.
| Modifier and Type | Field and Description |
|---|---|
| public AttachmentMarshaller | |
| private Base64Data | base64Data
Cached instance of |
| private ContentHandlerAdaptor | contentHandlerAdapter
Lazily created. |
| pack-priv ThreadLocal | |
| private final CollisionCheckStack | cycleDetectionStack
Used to detect cycles in the object. |
| private MimeType | |
| private boolean | |
| public final JAXBContextImpl | |
| private Transformer | identityTransformer
Lazily created identitiy transformer. |
| private final Set | idReferencedObjects
Objects referenced through IDREF. |
| private boolean | inlineBinaryFlag
True to force inlining. |
| private final IntData | |
| public final int[] | |
| private final MarshallerImpl | marshaller
Marshaller object to which this object belongs. |
| public final NameList | |
| private String | |
| private final NamespaceContextImpl | |
| private NamespaceContextImpl. | |
| private final Set | objectsWithId
Objects with ID. |
| private XmlOutput | out
The XML printer. |
| private String | schemaLocation
Optional attributes to go with root element. |
| private QName | schemaType
Field used to support an |
| private boolean | seenRoot
Set to false once we see the start tag of the root element. |
| private boolean | textHasAlreadyPrinted
Set to true if a text is already written, and we need to print ' ' for additional text methods. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | addInscopeBinding(String nsUri, String prefix)
This method can be called after |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | childAsSoleContent(Object child, String fieldName)
The equivalent of: childAsURIs(child, fieldName); endNamespaceDecls(); childAsAttributes(child, fieldName); endAttributes(); childAsBody(child, fieldName); |
| public void | childAsXsiType(Object
Object to be marshalled. The child, String JaxBeanInfo for
this object must return a type name.property name of the parent objeect from which 'o' comes.
Used as a part of the error message in case anything goes wrong
with 'o'. fieldName, JaxBeanInfo<BeanT> Expected type of the object. expected, boolean nillable)This method is called when a type child object is found. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| private void | fireAfterMarshalEvents(final JaxBeanInfo<BeanT> beanInfo, Object currentTarget)
Invoke the afterMarshal api on the external listener (if it exists) and on the bean embedded afterMarshal api(if it exists). |
| private void | fireBeforeMarshalEvents(final JaxBeanInfo<BeanT> beanInfo, Object currentTarget)
Invoke the beforeMarshal api on the external listener (if it exists) and on the bean embedded beforeMarshal api(if it exists). |
| private void | |
| public Base64Data | getCachedBase64DataInstance()
Deprecated
Base64Data is no longer cached, so that
XMLStreamWriterEx impl can retain the data, like JAX-WS does.
Gets the cached instance of |
| public ValidationEventLocator | |
| public Property | |
| public Transformer | |
| private String | |
| public boolean | |
| public static XMLSerializer | getInstance()
When called from within the realm of the marshaller, this method returns the current in charge. |
| protected ValidationEventLocator | getLocation()
Implements abstract org. Gets the current location. |
| public NamespaceContext2 | |
| public boolean | |
| public QName | |
| public String | |
| public boolean | |
| public boolean | |
| public boolean | handleEvent(ValidationEvent event)
Implements jakarta. Receive notification of a validation warning or error. |
| private void | |
| public void | |
| public void | |
| public void | |
| public String | |
| public String | |
| private Object | Returns: the object that should be marshalled instead of the givenobj,
or null if the error is found and we need to avoid marshalling this object
to prevent infinite recursion. When this method returns null, the error
has already been reported.Pushes the object to |
| pack-priv void | |
| public void | |
| public void | reportError(String
the name of the property being processed when an error is found. fieldName, Throwable t)Report an error found as an exception. |
| private void | |
| public MimeType | setExpectedMimeType(MimeType expectedMimeType)
This method is used by |
| public boolean | |
| public void | |
| public void | |
| public QName | |
| public void | startDocument(XmlOutput out, boolean fragment, String
if non-null, this value is printed on the root element as xsi:schemaLocation schemaLocation, String Similar to 'schemaLocation' but this one works for xsi:noNamespaceSchemaLocation noNsSchemaLocation)Reset this object to write to the specified output. |
| public void | |
| public void | |
| private void | |
| public void | startElementForce(String nsUri, String localName, String forcedPrefix, Object outerPeer)
Variation of |
| public void | |
| public void | |
| public <E> void | |
| public void | writeXsiNilTrue()
Short for the following call sequence:
getNamespaceContext().declareNamespace(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,"xsi",true);
endNamespaceDecls();
attribute(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,"nil","true");
endAttributes();
|
| attachmentMarshaller | back to summary |
|---|---|
| public AttachmentMarshaller attachmentMarshaller | |
| base64Data | back to summary |
|---|---|
| private Base64Data base64Data Cached instance of | |
| contentHandlerAdapter | back to summary |
|---|---|
| private ContentHandlerAdaptor contentHandlerAdapter Lazily created. | |
| currentProperty | back to summary |
|---|---|
| pack-priv ThreadLocal<Property<BeanT>> currentProperty | |
| cycleDetectionStack | back to summary |
|---|---|
| private final CollisionCheckStack<Object> cycleDetectionStack Used to detect cycles in the object. Also used to learn what's being marshalled. | |
| expectedMimeType | back to summary |
|---|---|
| private MimeType expectedMimeType | |
| fragment | back to summary |
|---|---|
| private boolean fragment | |
| grammar | back to summary |
|---|---|
| public final JAXBContextImpl grammar | |
| identityTransformer | back to summary |
|---|---|
| private Transformer identityTransformer Lazily created identitiy transformer. | |
| idReferencedObjects | back to summary |
|---|---|
| private final Set<Object> idReferencedObjects Objects referenced through IDREF. | |
| inlineBinaryFlag | back to summary |
|---|---|
| private boolean inlineBinaryFlag True to force inlining. | |
| intData | back to summary |
|---|---|
| private final IntData intData Cached instance of | |
| knownUri2prefixIndexMap | back to summary |
|---|---|
| public final int[] knownUri2prefixIndexMap | |
| marshaller | back to summary |
|---|---|
| private final MarshallerImpl marshaller Marshaller object to which this object belongs. | |
| nameList | back to summary |
|---|---|
| public final NameList nameList | |
| noNsSchemaLocation | back to summary |
|---|---|
| private String noNsSchemaLocation | |
| nsContext | back to summary |
|---|---|
| private final NamespaceContextImpl nsContext | |
| nse | back to summary |
|---|---|
| private NamespaceContextImpl. | |
| objectsWithId | back to summary |
|---|---|
| private final Set<Object> objectsWithId Objects with ID. | |
| out | back to summary |
|---|---|
| private XmlOutput out The XML printer. | |
| schemaLocation | back to summary |
|---|---|
| private String schemaLocation Optional attributes to go with root element. | |
| schemaType | back to summary |
|---|---|
| private QName schemaType Field used to support an
When we are marshalling a property with an effective | |
| seenRoot | back to summary |
|---|---|
| private boolean seenRoot Set to false once we see the start tag of the root element. | |
| textHasAlreadyPrinted | back to summary |
|---|---|
| private boolean textHasAlreadyPrinted Set to true if a text is already written, and we need to print ' ' for additional text methods. | |
| XMLSerializer | back to summary |
|---|---|
| pack-priv XMLSerializer(MarshallerImpl _owner) | |
| addInscopeBinding | back to summary |
|---|---|
| public void addInscopeBinding(String nsUri, String prefix) This method can be called after This method is useful to avoid redundant namespace declarations when the marshalling is producing a sub-document. | |
| attribute | back to summary |
|---|---|
| public void attribute(String uri, String local, String value) throws SAXException | |
| attribute | back to summary |
|---|---|
| public void attribute(Name name, CharSequence value) throws IOException, XMLStreamException | |
| attWildcardAsAttributes | back to summary |
|---|---|
| public void attWildcardAsAttributes(Map<QName, String> attributes, String fieldName) throws SAXException | |
| attWildcardAsURIs | back to summary |
|---|---|
| public void attWildcardAsURIs(Map<QName, String> attributes, String fieldName) | |
| childAsRoot | back to summary |
|---|---|
| public void childAsRoot(Object obj) throws JAXBException, IOException, SAXException, XMLStreamException | |
| childAsSoleContent | back to summary |
|---|---|
| public void childAsSoleContent(Object child, String fieldName) throws SAXException, IOException, XMLStreamException The equivalent of: childAsURIs(child, fieldName); endNamespaceDecls(); childAsAttributes(child, fieldName); endAttributes(); childAsBody(child, fieldName);This produces the given child object as the sole content of an element. Used to reduce the code size in the generated marshaller. | |
| childAsXsiType | back to summary |
|---|---|
| public void childAsXsiType(Object child, String fieldName, JaxBeanInfo<BeanT> expected, boolean nillable) throws SAXException, IOException, XMLStreamException This method is called when a type child object is found. This method produces events of the following form: NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODYoptionally including @xsi:type if necessary.
| |
| clearCurrentProperty | back to summary |
|---|---|
| public void clearCurrentProperty() Takes care of cleaning the currentProperty. Must be called from the same thread that created the XMLSerializer. | |
| close | back to summary |
|---|---|
| public void close() | |
| endAttributes | back to summary |
|---|---|
| public void endAttributes() throws SAXException, IOException, XMLStreamException Switches to the "marshal child texts/elements" mode. This method has to be called after the 1st pass is completed. | |
| endDocument | back to summary |
|---|---|
| public void endDocument() throws IOException, SAXException, XMLStreamException | |
| endElement | back to summary |
|---|---|
| public void endElement() throws SAXException, IOException, XMLStreamException Ends marshalling of an element. Pops the internal stack. | |
| endNamespaceDecls | back to summary |
|---|---|
| public void endNamespaceDecls(Object innerPeer) throws IOException, XMLStreamException | |
| errorMissingId | back to summary |
|---|---|
| public void errorMissingId(Object obj) throws SAXException Called when a referenced object doesn't have an ID. | |
| fireAfterMarshalEvents | back to summary |
|---|---|
| private void fireAfterMarshalEvents(final JaxBeanInfo<BeanT> beanInfo, Object currentTarget) Invoke the afterMarshal api on the external listener (if it exists) and on the bean embedded afterMarshal api(if it exists). This method is called only after the callee has determined that beanInfo.lookForLifecycleMethods == true. | |
| fireBeforeMarshalEvents | back to summary |
|---|---|
| private void fireBeforeMarshalEvents(final JaxBeanInfo<BeanT> beanInfo, Object currentTarget) Invoke the beforeMarshal api on the external listener (if it exists) and on the bean embedded beforeMarshal api(if it exists). This method is called only after the callee has determined that beanInfo.lookForLifecycleMethods == true. | |
| fireMarshalEvent | back to summary |
|---|---|
| private void fireMarshalEvent(Object target, Method m) | |
| getCachedBase64DataInstance | back to summary |
|---|---|
| public Base64Data getCachedBase64DataInstance()
Deprecated
Gets the cached instance of
| |
| getCurrentLocation | back to summary |
|---|---|
| public ValidationEventLocator getCurrentLocation(String fieldName) | |
| getCurrentProperty | back to summary |
|---|---|
| public Property May return null when the property hasn't been set. Introduced based on Jersey requirements. | |
| getIdentityTransformer | back to summary |
|---|---|
| public Transformer getIdentityTransformer() | |
| getIdFromObject | back to summary |
|---|---|
| private String getIdFromObject(Object identifiableObject) throws SAXException, JAXBException Gets the ID value from an identifiable object. | |
| getInlineBinaryFlag | back to summary |
|---|---|
| public boolean getInlineBinaryFlag() | |
| getInstance | back to summary |
|---|---|
| public static XMLSerializer getInstance() When called from within the realm of the marshaller, this method returns the current in charge. | |
| getLocation | back to summary |
|---|---|
| protected ValidationEventLocator getLocation() Implements abstract org. Doc from org. Gets the current location. Used for reporting the error source location.
| |
| getNamespaceContext | back to summary |
|---|---|
| public NamespaceContext2 getNamespaceContext() | |
| getObjectIdentityCycleDetection | back to summary |
|---|---|
| public boolean getObjectIdentityCycleDetection() | |
| getSchemaType | back to summary |
|---|---|
| public QName getSchemaType() | |
| getXMIMEContentType | back to summary |
|---|---|
| public String getXMIMEContentType() Gets the MIME type with which the binary content shall be printed.
This method shall be used from those | |
| handleError | back to summary |
|---|---|
| public boolean handleError(Exception e) | |
| handleError | back to summary |
|---|---|
| public boolean handleError(Exception e, Object source, String fieldName) | |
| handleEvent | back to summary |
|---|---|
| public boolean handleEvent(ValidationEvent event) Implements jakarta. Doc from jakarta. Receive notification of a validation warning or error.
The ValidationEvent will have a
If an unchecked runtime exception is thrown from this method, the Jakarta XML Binding provider will treat it as if the method returned false and interrupt the current unmarshal, validate, or marshal operation.
| |
| handleMissingObjectError | back to summary |
|---|---|
| private void handleMissingObjectError(String fieldName) throws SAXException, IOException, XMLStreamException | |
| leafElement | back to summary |
|---|---|
| public void leafElement(Name tagName, String data, String fieldName) throws SAXException, IOException, XMLStreamException | |
| leafElement | back to summary |
|---|---|
| public void leafElement(Name tagName, Pcdata data, String fieldName) throws SAXException, IOException, XMLStreamException | |
| leafElement | back to summary |
|---|---|
| public void leafElement(Name tagName, int data, String fieldName) throws SAXException, IOException, XMLStreamException | |
| onID | back to summary |
|---|---|
| public String onID(Object owner, String value) | |
| onIDREF | back to summary |
|---|---|
| public String onIDREF(Object obj) throws SAXException | |
| pushObject | back to summary |
|---|---|
| private Object pushObject(Object obj, String fieldName) throws SAXException Pushes the object to
| |
| reconcileID | back to summary |
|---|---|
| pack-priv void reconcileID() throws SAXException | |
| reportError | back to summary |
|---|---|
| public void reportError(ValidationEvent ve) throws SAXException | |
| reportError | back to summary |
|---|---|
| public void reportError(String fieldName, Throwable t) throws SAXException Report an error found as an exception.
| |
| reportMissingObjectError | back to summary |
|---|---|
| private void reportMissingObjectError(String fieldName) throws SAXException | |
| setExpectedMimeType | back to summary |
|---|---|
| public MimeType setExpectedMimeType(MimeType expectedMimeType) This method is used by | |
| setInlineBinaryFlag | back to summary |
|---|---|
| public boolean setInlineBinaryFlag(boolean value) | |
| setObjectIdentityCycleDetection | back to summary |
|---|---|
| public void setObjectIdentityCycleDetection(boolean val) | |
| setPrefixMapper | back to summary |
|---|---|
| public void setPrefixMapper(NamespacePrefixMapper prefixMapper) | |
| setSchemaType | back to summary |
|---|---|
| public QName setSchemaType(QName st) | |
| startDocument | back to summary |
|---|---|
| public void startDocument(XmlOutput out, boolean fragment, String schemaLocation, String noNsSchemaLocation) throws IOException, SAXException, XMLStreamException Reset this object to write to the specified output. | |
| startElement | back to summary |
|---|---|
| public void startElement(Name tagName, Object outerPeer) | |
| startElement | back to summary |
|---|---|
| public void startElement(String nsUri, String localName, String preferredPrefix, Object outerPeer) | |
| startElement | back to summary |
|---|---|
| private void startElement() | |
| startElementForce | back to summary |
|---|---|
| public void startElementForce(String nsUri, String localName, String forcedPrefix, Object outerPeer) Variation of | |
| text | back to summary |
|---|---|
| public void text(String text, String fieldName) throws SAXException, IOException, XMLStreamException Marshalls text.
This method can be called after the
c.startElement("","foo");
c.endAttributes();
c.text("abc");
c.text("def");
c.startElement("","bar");
c.endAttributes();
c.endElement();
c.text("ghi");
c.endElement();
will generate <foo>abc def<bar/>ghi</foo>.
| |
| text | back to summary |
|---|---|
| public void text(Pcdata text, String fieldName) throws SAXException, IOException, XMLStreamException The | |
| writeDom | back to summary |
|---|---|
| public <E> void writeDom(E element, DomHandler<E, ?> domHandler, Object parentBean, String fieldName) throws SAXException | |
| writeXsiNilTrue | back to summary |
|---|---|
| public void writeXsiNilTrue() throws SAXException, IOException, XMLStreamException Short for the following call sequence:
getNamespaceContext().declareNamespace(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,"xsi",true);
endNamespaceDecls();
attribute(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,"nil","true");
endAttributes();
| |