- java.lang.Object
-
- javax.xml.bind.helpers.AbstractMarshallerImpl
-
- com.sun.xml.bind.v2.runtime.MarshallerImpl
-
- All Implemented Interfaces:
javax.xml.bind.Marshaller
,javax.xml.bind.ValidationEventHandler
public final class MarshallerImpl extends javax.xml.bind.helpers.AbstractMarshallerImpl implements javax.xml.bind.ValidationEventHandler
Implementation ofMarshaller
interface for the JAXB RI.Eventually all the
marshal(java.lang.Object, java.io.OutputStream, javax.xml.namespace.NamespaceContext)
methods call into thewrite(com.sun.xml.bind.v2.runtime.Name, com.sun.xml.bind.v2.runtime.JaxBeanInfo<T>, T, com.sun.xml.bind.v2.runtime.output.XmlOutput, java.lang.Runnable)
method.- Author:
- Kohsuke Kawaguchi, Vivek Pandey
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
C14N
protected static String
ENCODING_HANDLER
protected static String
ENCODING_HANDLER2
protected static String
INDENT_STRING
protected static String
OBJECT_IDENTITY_CYCLE_DETECTION
protected static String
PREFIX_MAPPER
protected XMLSerializer
serializer
protected static String
XML_HEADERS
protected static String
XMLDECLARATION
-
Constructor Summary
Constructors Constructor Description MarshallerImpl(JAXBContextImpl c, AssociationMap assoc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CharacterEscapeHandler
createEscapeHandler(String encoding)
com.sun.xml.bind.v2.runtime.output.XmlOutput
createWriter(OutputStream os)
com.sun.xml.bind.v2.runtime.output.XmlOutput
createWriter(OutputStream os, String encoding)
com.sun.xml.bind.v2.runtime.output.XmlOutput
createWriter(Writer w)
com.sun.xml.bind.v2.runtime.output.XmlOutput
createWriter(Writer w, String encoding)
<A extends javax.xml.bind.annotation.adapters.XmlAdapter>
AgetAdapter(Class<A> type)
javax.xml.bind.attachment.AttachmentMarshaller
getAttachmentMarshaller()
JAXBContextImpl
getContext()
javax.xml.bind.Marshaller.Listener
getListener()
Object
getProperty(String name)
Schema
getSchema()
boolean
handleEvent(javax.xml.bind.ValidationEvent event)
Default error handling behavior fotMarshaller
.void
marshal(Object obj, com.sun.xml.bind.v2.runtime.output.XmlOutput output)
void
marshal(Object obj, OutputStream out, NamespaceContext inscopeNamespace)
Marshals toOutputStream
with the given in-scope namespaces taken into account.void
marshal(Object obj, XMLEventWriter writer)
void
marshal(Object obj, XMLStreamWriter writer)
void
marshal(Object target, Result result)
<A extends javax.xml.bind.annotation.adapters.XmlAdapter>
voidsetAdapter(Class<A> type, A adapter)
void
setAttachmentMarshaller(javax.xml.bind.attachment.AttachmentMarshaller am)
void
setListener(javax.xml.bind.Marshaller.Listener listener)
void
setProperty(String name, Object value)
void
setSchema(Schema s)
protected <T> void
write(Name rootTagName, JaxBeanInfo<T> bi, T obj, com.sun.xml.bind.v2.runtime.output.XmlOutput out, Runnable postInitAction)
Used byBridgeImpl
to write an arbitrary object as a fragment.-
Methods inherited from class javax.xml.bind.helpers.AbstractMarshallerImpl
getEncoding, getEventHandler, getJavaEncoding, getNode, getNoNSSchemaLocation, getSchemaLocation, isFormattedOutput, isFragment, marshal, marshal, marshal, marshal, marshal, setAdapter, setEncoding, setEventHandler, setFormattedOutput, setFragment, setNoNSSchemaLocation, setSchemaLocation
-
-
-
-
Field Detail
-
serializer
protected final XMLSerializer serializer
-
INDENT_STRING
protected static final String INDENT_STRING
- See Also:
- Constant Field Values
-
PREFIX_MAPPER
protected static final String PREFIX_MAPPER
- See Also:
- Constant Field Values
-
ENCODING_HANDLER
protected static final String ENCODING_HANDLER
- See Also:
- Constant Field Values
-
ENCODING_HANDLER2
protected static final String ENCODING_HANDLER2
- See Also:
- Constant Field Values
-
XMLDECLARATION
protected static final String XMLDECLARATION
- See Also:
- Constant Field Values
-
XML_HEADERS
protected static final String XML_HEADERS
- See Also:
- Constant Field Values
-
C14N
protected static final String C14N
- See Also:
- Constant Field Values
-
OBJECT_IDENTITY_CYCLE_DETECTION
protected static final String OBJECT_IDENTITY_CYCLE_DETECTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MarshallerImpl
public MarshallerImpl(JAXBContextImpl c, AssociationMap assoc)
- Parameters:
assoc
- non-null if the marshaller is working insideBinderImpl
.
-
-
Method Detail
-
getContext
public JAXBContextImpl getContext()
-
marshal
public void marshal(Object obj, OutputStream out, NamespaceContext inscopeNamespace) throws javax.xml.bind.JAXBException
Marshals toOutputStream
with the given in-scope namespaces taken into account.- Throws:
javax.xml.bind.JAXBException
- Since:
- 2.1.5
-
marshal
public void marshal(Object obj, XMLStreamWriter writer) throws javax.xml.bind.JAXBException
- Specified by:
marshal
in interfacejavax.xml.bind.Marshaller
- Overrides:
marshal
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
marshal
public void marshal(Object obj, XMLEventWriter writer) throws javax.xml.bind.JAXBException
- Specified by:
marshal
in interfacejavax.xml.bind.Marshaller
- Overrides:
marshal
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
marshal
public void marshal(Object obj, com.sun.xml.bind.v2.runtime.output.XmlOutput output) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
marshal
public void marshal(Object target, Result result) throws javax.xml.bind.JAXBException
- Specified by:
marshal
in interfacejavax.xml.bind.Marshaller
- Throws:
javax.xml.bind.JAXBException
-
write
protected final <T> void write(Name rootTagName, JaxBeanInfo<T> bi, T obj, com.sun.xml.bind.v2.runtime.output.XmlOutput out, Runnable postInitAction) throws javax.xml.bind.JAXBException
Used byBridgeImpl
to write an arbitrary object as a fragment.- Throws:
javax.xml.bind.JAXBException
-
createEscapeHandler
protected CharacterEscapeHandler createEscapeHandler(String encoding)
-
createWriter
public com.sun.xml.bind.v2.runtime.output.XmlOutput createWriter(Writer w, String encoding)
-
createWriter
public com.sun.xml.bind.v2.runtime.output.XmlOutput createWriter(Writer w)
-
createWriter
public com.sun.xml.bind.v2.runtime.output.XmlOutput createWriter(OutputStream os) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
createWriter
public com.sun.xml.bind.v2.runtime.output.XmlOutput createWriter(OutputStream os, String encoding) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
getProperty
public Object getProperty(String name) throws javax.xml.bind.PropertyException
- Specified by:
getProperty
in interfacejavax.xml.bind.Marshaller
- Overrides:
getProperty
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
- Throws:
javax.xml.bind.PropertyException
-
setProperty
public void setProperty(String name, Object value) throws javax.xml.bind.PropertyException
- Specified by:
setProperty
in interfacejavax.xml.bind.Marshaller
- Overrides:
setProperty
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
- Throws:
javax.xml.bind.PropertyException
-
setAdapter
public <A extends javax.xml.bind.annotation.adapters.XmlAdapter> void setAdapter(Class<A> type, A adapter)
- Specified by:
setAdapter
in interfacejavax.xml.bind.Marshaller
- Overrides:
setAdapter
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
getAdapter
public <A extends javax.xml.bind.annotation.adapters.XmlAdapter> A getAdapter(Class<A> type)
- Specified by:
getAdapter
in interfacejavax.xml.bind.Marshaller
- Overrides:
getAdapter
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
setAttachmentMarshaller
public void setAttachmentMarshaller(javax.xml.bind.attachment.AttachmentMarshaller am)
- Specified by:
setAttachmentMarshaller
in interfacejavax.xml.bind.Marshaller
- Overrides:
setAttachmentMarshaller
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
getAttachmentMarshaller
public javax.xml.bind.attachment.AttachmentMarshaller getAttachmentMarshaller()
- Specified by:
getAttachmentMarshaller
in interfacejavax.xml.bind.Marshaller
- Overrides:
getAttachmentMarshaller
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
getSchema
public Schema getSchema()
- Specified by:
getSchema
in interfacejavax.xml.bind.Marshaller
- Overrides:
getSchema
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
setSchema
public void setSchema(Schema s)
- Specified by:
setSchema
in interfacejavax.xml.bind.Marshaller
- Overrides:
setSchema
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
handleEvent
public boolean handleEvent(javax.xml.bind.ValidationEvent event)
Default error handling behavior fotMarshaller
.- Specified by:
handleEvent
in interfacejavax.xml.bind.ValidationEventHandler
-
getListener
public javax.xml.bind.Marshaller.Listener getListener()
- Specified by:
getListener
in interfacejavax.xml.bind.Marshaller
- Overrides:
getListener
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
setListener
public void setListener(javax.xml.bind.Marshaller.Listener listener)
- Specified by:
setListener
in interfacejavax.xml.bind.Marshaller
- Overrides:
setListener
in classjavax.xml.bind.helpers.AbstractMarshallerImpl
-
-