- java.lang.Object
-
- javax.xml.bind.helpers.AbstractMarshallerImpl
-
- All Implemented Interfaces:
Marshaller
public abstract class AbstractMarshallerImpl extends Object implements Marshaller
Partial defaultMarshaller
implementation.This class provides a partial default implementation for the
Marshaller
interface.The only methods that a JAXB Provider has to implement are
marshal(Object, javax.xml.transform.Result)
,marshal(Object, javax.xml.stream.XMLStreamWriter)
, andmarshal(Object, javax.xml.stream.XMLEventWriter)
.- Since:
- 1.6, JAXB 1.0
- See Also:
Marshaller
-
-
Nested Class Summary
-
Nested classes/interfaces declared in interface javax.xml.bind.Marshaller
Marshaller.Listener
-
-
Field Summary
-
Fields declared in interface javax.xml.bind.Marshaller
JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION
-
-
Constructor Summary
Constructors Constructor Description AbstractMarshallerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getEncoding()
Convenience method for getting the current output encoding.ValidationEventHandler
getEventHandler()
Return the current event handler or the default event handler if one hasn't been set.protected String
getJavaEncoding(String encoding)
Gets the corresponding Java encoding name from an IANA name.Node
getNode(Object obj)
By default, the getNode method is unsupported and throw anUnsupportedOperationException
.protected String
getNoNSSchemaLocation()
Convenience method for getting the current noNamespaceSchemaLocation.Object
getProperty(String name)
Default implementation of the getProperty method handles the four defined properties in Marshaller.protected String
getSchemaLocation()
Convenience method for getting the current schemaLocation.protected boolean
isFormattedOutput()
Convenience method for getting the formatted output flag.protected boolean
isFragment()
Convenience method for getting the fragment flag.protected void
setEncoding(String encoding)
Convenience method for setting the output encoding.void
setEventHandler(ValidationEventHandler handler)
Allow an application to register a validation event handler.protected void
setFormattedOutput(boolean v)
Convenience method for setting the formatted output flag.protected void
setFragment(boolean v)
Convenience method for setting the fragment flag.protected void
setNoNSSchemaLocation(String location)
Convenience method for setting the noNamespaceSchemaLocation.void
setProperty(String name, Object value)
Default implementation of the setProperty method handles the four defined properties in Marshaller.protected void
setSchemaLocation(String location)
Convenience method for setting the schemaLocation.-
Methods declared in interface javax.xml.bind.Marshaller
getAdapter, getListener, getSchema, marshal, marshal, marshal, marshal, marshal, marshal, marshal, marshal, setAdapter, setAdapter, setAttachmentMarshaller, setListener, setSchema
-
-
-
-
Method Detail
-
getNode
public Node getNode(Object obj) throws JAXBException
By default, the getNode method is unsupported and throw anUnsupportedOperationException
. Implementations that choose to support this method must override this method.- Specified by:
getNode
in interfaceMarshaller
- Parameters:
obj
- - JAXB Java representation of XML content- Returns:
- the DOM tree view of the contentTree
- Throws:
JAXBException
- If any unexpected problem occurs
-
getEncoding
protected String getEncoding()
Convenience method for getting the current output encoding.- Returns:
- the current encoding or "UTF-8" if it hasn't been set.
-
setEncoding
protected void setEncoding(String encoding)
Convenience method for setting the output encoding.- Parameters:
encoding
- a valid encoding as specified in the Marshaller class documentation
-
getSchemaLocation
protected String getSchemaLocation()
Convenience method for getting the current schemaLocation.- Returns:
- the current schemaLocation or null if it hasn't been set
-
setSchemaLocation
protected void setSchemaLocation(String location)
Convenience method for setting the schemaLocation.- Parameters:
location
- the schemaLocation value
-
getNoNSSchemaLocation
protected String getNoNSSchemaLocation()
Convenience method for getting the current noNamespaceSchemaLocation.- Returns:
- the current noNamespaceSchemaLocation or null if it hasn't been set
-
setNoNSSchemaLocation
protected void setNoNSSchemaLocation(String location)
Convenience method for setting the noNamespaceSchemaLocation.- Parameters:
location
- the noNamespaceSchemaLocation value
-
isFormattedOutput
protected 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.
-
setFormattedOutput
protected void setFormattedOutput(boolean v)
Convenience method for setting the formatted output flag.- Parameters:
v
- value of the formatted output flag.
-
isFragment
protected 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.
-
setFragment
protected void setFragment(boolean v)
Convenience method for setting the fragment flag.- Parameters:
v
- value of the fragment flag.
-
getJavaEncoding
protected String getJavaEncoding(String encoding) throws UnsupportedEncodingException
Gets 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.
-
setProperty
public void setProperty(String name, Object value) throws PropertyException
Default 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:
setProperty
in interfaceMarshaller
- 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
-
getProperty
public Object getProperty(String name) throws PropertyException
Default 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:
getProperty
in interfaceMarshaller
- 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
-
getEventHandler
public ValidationEventHandler getEventHandler() throws JAXBException
Description copied from interface:Marshaller
Return the current event handler or the default event handler if one hasn't been set.- Specified by:
getEventHandler
in interfaceMarshaller
- 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:
Marshaller.getEventHandler()
-
setEventHandler
public void setEventHandler(ValidationEventHandler handler) throws JAXBException
Description copied from interface:Marshaller
Allow an application to register a validation event handler.The validation event handler will be called by the JAXB 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 default event handler.
- Specified by:
setEventHandler
in interfaceMarshaller
- Parameters:
handler
- the validation event handler- Throws:
JAXBException
- if an error was encountered while setting the event handler- See Also:
Marshaller.setEventHandler(ValidationEventHandler)
-
-