- All Implemented Interfaces:
- Marshaller
Marshaller implementation.
 
 This class provides a partial default implementation for the
 Marshaller interface.
 
 The only methods that a Jakarta XML Binding Provider has to implement are
 marshal(Object, javax.xml.transform.Result),
 marshal(Object, javax.xml.stream.XMLStreamWriter), and
 marshal(Object, javax.xml.stream.XMLEventWriter).
- Author:
- Kohsuke Kawaguchi, Sun Microsystems, Inc.
 
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface jakarta.xml.bind.MarshallerMarshaller.Listener
- 
Field SummaryFields inherited from interface jakarta.xml.bind.MarshallerJAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDo-nothing constructor for the derived classes.
- 
Method SummaryModifier and TypeMethodDescription<A extends XmlAdapter<?,?>> 
 AgetAdapter(Class<A> type) Gets the adapter associated with the specified type.protected StringConvenience method for getting the current output encoding.Return the current event handler or the default event handler if one hasn't been set.protected StringgetJavaEncoding(String encoding) Gets the corresponding Java encoding name from an IANA name.ReturnMarshaller.Listenerregistered with thisMarshaller.By default, the getNode method is unsupported and throw anUnsupportedOperationException.protected StringConvenience method for getting the current noNamespaceSchemaLocation.getProperty(String name) Default implementation of the getProperty method handles the four defined properties in Marshaller.Get the JAXPSchemaobject being used to perform marshal-time validation.protected StringConvenience method for getting the current schemaLocation.protected booleanConvenience method for getting the formatted output flag.protected booleanConvenience method for getting the fragment flag.voidMarshal the content tree rooted atjaxbElementinto a file.final voidmarshal(Object obj, OutputStream os) Marshal the content tree rooted atjaxbElementinto an output stream.final voidMarshal the content tree rooted atjaxbElementinto a Writer.voidmarshal(Object obj, XMLEventWriter writer) Marshal the content tree rooted atjaxbElementinto aXMLEventWriter.voidmarshal(Object obj, XMLStreamWriter writer) Marshal the content tree rooted atjaxbElementinto aXMLStreamWriter.final voidMarshal the content tree rooted atjaxbElementinto a DOM tree.final voidmarshal(Object obj, ContentHandler handler) Marshal the content tree rooted atjaxbElementinto SAX2 events.<A extends XmlAdapter<?,?>> 
 voidsetAdapter(A adapter) Associates a configured instance ofXmlAdapterwith this marshaller.<A extends XmlAdapter<?,?>> 
 voidsetAdapter(Class<A> type, A adapter) Associates a configured instance ofXmlAdapterwith this marshaller.voidAssociate a context that enables binary data within an XML document to be transmitted as XML-binary optimized attachment.protected voidsetEncoding(String encoding) Convenience method for setting the output encoding.voidsetEventHandler(ValidationEventHandler handler) Allow an application to register a validation event handler.protected voidsetFormattedOutput(boolean v) Convenience method for setting the formatted output flag.protected voidsetFragment(boolean v) Convenience method for setting the fragment flag.voidsetListener(Marshaller.Listener listener) Register marshal event callbackMarshaller.Listenerwith thisMarshaller.protected voidsetNoNSSchemaLocation(String location) Convenience method for setting the noNamespaceSchemaLocation.voidsetProperty(String name, Object value) Default implementation of the setProperty method handles the four defined properties in Marshaller.voidSpecify the JAXPSchemaobject that should be used to validate subsequent marshal operations against.protected voidsetSchemaLocation(String location) Convenience method for setting the schemaLocation.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.xml.bind.Marshallermarshal
- 
Constructor Details- 
AbstractMarshallerImplprotected AbstractMarshallerImpl()Do-nothing constructor for the derived classes.
 
- 
- 
Method Details- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto an output stream.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- obj- The root of content tree to be marshalled.
- os- XML will be added to this stream.
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto a file.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- jaxbElement- The root of content tree to be marshalled.
- output- File to be written. If this file already exists, it will be overwritten.
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto a Writer.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- obj- The root of content tree to be marshalled.
- w- XML will be sent to this writer.
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto SAX2 events.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- obj- The root of content tree to be marshalled.
- handler- XML will be sent to this handler as SAX2 events.
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto a DOM tree.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- obj- The content tree to be marshalled.
- node- DOM nodes will be added as children of this node. This parameter must be a Node that accepts children (- Document,- DocumentFragment, or- Element)
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
getNodeBy default, the getNode method is unsupported and throw anUnsupportedOperationException.Implementations that choose to support this method must override this method. - Specified by:
- getNodein interface- Marshaller
- Parameters:
- obj- - Jakarta XML Binding Java representation of XML content
- Returns:
- the DOM tree view of the contentTree
- Throws:
- JAXBException- If any unexpected problem occurs
 
- 
getEncodingConvenience method for getting the current output encoding.- Returns:
- the current encoding or "UTF-8" if it hasn't been set.
 
- 
setEncodingConvenience method for setting the output encoding.- Parameters:
- encoding- a valid encoding as specified in the Marshaller class documentation
 
- 
getSchemaLocationConvenience method for getting the current schemaLocation.- Returns:
- the current schemaLocation or null if it hasn't been set
 
- 
setSchemaLocationConvenience method for setting the schemaLocation.- Parameters:
- location- the schemaLocation value
 
- 
getNoNSSchemaLocationConvenience method for getting the current noNamespaceSchemaLocation.- Returns:
- the current noNamespaceSchemaLocation or null if it hasn't been set
 
- 
setNoNSSchemaLocationConvenience method for setting the noNamespaceSchemaLocation.- Parameters:
- location- the noNamespaceSchemaLocation value
 
- 
isFormattedOutputprotected boolean isFormattedOutput()Convenience method for getting the formatted output flag.- Returns:
- the current value of the formatted output flag or false if it hasn't been set.
 
- 
setFormattedOutputprotected void setFormattedOutput(boolean v) Convenience method for setting the formatted output flag.- Parameters:
- v- value of the formatted output flag.
 
- 
isFragmentprotected boolean isFragment()Convenience method for getting the fragment flag.- Returns:
- the current value of the fragment flag or false if it hasn't been set.
 
- 
setFragmentprotected void setFragment(boolean v) Convenience method for setting the fragment flag.- Parameters:
- v- value of the fragment flag.
 
- 
getJavaEncodingGets the corresponding Java encoding name from an IANA name.This method is a helper method for the derived class to convert encoding names. - Throws:
- UnsupportedEncodingException- If this implementation couldn't find the Java encoding name.
 
- 
setPropertyDefault implementation of the setProperty method handles the four defined properties in Marshaller. If a provider needs to handle additional properties, it should override this method in a derived class.- Specified by:
- setPropertyin interface- Marshaller
- Parameters:
- name- the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.
- value- the value of the property to be set
- Throws:
- PropertyException- when there is an error processing the given property or value
 
- 
getPropertyDefault implementation of the getProperty method handles the four defined properties in Marshaller. If a provider needs to support additional provider specific properties, it should override this method in a derived class.- Specified by:
- getPropertyin interface- Marshaller
- Parameters:
- name- the name of the property to retrieve
- Returns:
- the value of the requested property
- Throws:
- PropertyException- when there is an error retrieving the given property or value property name
 
- 
getEventHandlerDescription copied from interface:MarshallerReturn the current event handler or the default event handler if one hasn't been set.- Specified by:
- getEventHandlerin interface- Marshaller
- Returns:
- the current ValidationEventHandler or the default event handler if it hasn't been set
- Throws:
- JAXBException- if an error was encountered while getting the current event handler
- See Also:
 
- 
setEventHandlerDescription copied from interface:MarshallerAllow an application to register a validation event handler.The validation event handler will be called by the Jakarta XML Binding Provider if any validation errors are encountered during calls to any of the marshal API's. If the client application does not register a validation event handler before invoking one of the marshal methods, then validation events will be handled by the default event handler which will terminate the marshal operation after the first error or fatal error is encountered. Calling this method with a null parameter will cause the Marshaller to revert back to the default event handler. - Specified by:
- setEventHandlerin interface- Marshaller
- Parameters:
- handler- the validation event handler
- Throws:
- JAXBException- if an error was encountered while setting the event handler
- See Also:
 
- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto aXMLEventWriter.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- obj- The content tree rooted at jaxbElement to be marshalled.
- writer- XML will be sent to this writer.
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
marshalDescription copied from interface:MarshallerMarshal the content tree rooted atjaxbElementinto aXMLStreamWriter.- Specified by:
- marshalin interface- Marshaller
- Parameters:
- obj- The content tree to be marshalled.
- writer- XML will be sent to this writer.
- Throws:
- JAXBException- If any unexpected problem occurs during the marshalling.
 
- 
setSchemaDescription copied from interface:MarshallerSpecify the JAXPSchemaobject that should be used to validate subsequent marshal operations against. Passing null into this method will disable validation.This method allows the caller to validate the marshalled XML as it's marshalled. Initially this property is set to null.- Specified by:
- setSchemain interface- Marshaller
- Parameters:
- schema- Schema object to validate marshal operations against or null to disable validation
 
- 
getSchemaDescription copied from interface:MarshallerGet the JAXPSchemaobject being used to perform marshal-time validation. If there is no Schema set on the marshaller, then this method will return null indicating that marshal-time validation will not be performed.- Specified by:
- getSchemain interface- Marshaller
- Returns:
- the Schema object being used to perform marshal-time validation or null if not present.
 
- 
setAdapterDescription copied from interface:MarshallerAssociates a configured instance ofXmlAdapterwith this marshaller.This is a convenience method that invokes setAdapter(adapter.getClass(),adapter);.- Specified by:
- setAdapterin interface- Marshaller
- Type Parameters:
- A- the type of the adapter
- Parameters:
- adapter- The instance of the adapter to be used. If null, it will un-register the current adapter set for this type.
- See Also:
 
- 
setAdapterDescription copied from interface:MarshallerAssociates a configured instance ofXmlAdapterwith this marshaller.Every marshaller internally maintains a Map<Class,XmlAdapter>, which it uses for marshalling classes whose fields/methods are annotated withXmlJavaTypeAdapter.This method allows applications to use a configured instance of XmlAdapter. When an instance of an adapter is not given, a marshaller will create one by invoking its default constructor.- Specified by:
- setAdapterin interface- Marshaller
- Type Parameters:
- A- the type of the adapter
- Parameters:
- type- The type of the adapter. The specified instance will be used when- XmlJavaTypeAdapter.value()refers to this type.
- adapter- The instance of the adapter to be used. If null, it will un-register the current adapter set for this type.
 
- 
getAdapterDescription copied from interface:MarshallerGets the adapter associated with the specified type. This is the reverse operation of theMarshaller.setAdapter(A)method.- Specified by:
- getAdapterin interface- Marshaller
- Type Parameters:
- A- the type of the adapter
- Parameters:
- type- The type of the adapter. The specified instance will be used when- XmlJavaTypeAdapter.value()refers to this type.
- Returns:
- The adapter associated with the specified type.
 
- 
setAttachmentMarshallerDescription copied from interface:MarshallerAssociate a context that enables binary data within an XML document to be transmitted as XML-binary optimized attachment. The attachment is referenced from the XML document content model by content-id URIs(cid) references stored within the xml document.- Specified by:
- setAttachmentMarshallerin interface- Marshaller
- Parameters:
- am- the attachment marshaller to be set
 
- 
getAttachmentMarshaller- Specified by:
- getAttachmentMarshallerin interface- Marshaller
 
- 
setListenerDescription copied from interface:MarshallerRegister marshal event callback Marshaller.Listenerwith thisMarshaller.There is only one Listener per Marshaller. Setting a Listener replaces the previous set Listener. One can unregister current Listener by setting listener to null.- Specified by:
- setListenerin interface- Marshaller
- Parameters:
- listener- an instance of a class that implements- Marshaller.Listener
 
- 
getListenerDescription copied from interface:MarshallerReturn Marshaller.Listenerregistered with thisMarshaller.- Specified by:
- getListenerin interface- Marshaller
- Returns:
- registered Marshaller.Listenerornullif no Listener is registered with this Marshaller.
 
 
-