com.sun.xml.bind.v2.runtime
Class MarshallerImpl

java.lang.Object
  extended by javax.xml.bind.helpers.AbstractMarshallerImpl
      extended by com.sun.xml.bind.v2.runtime.MarshallerImpl
All Implemented Interfaces:
Marshaller, ValidationEventHandler

public final class MarshallerImpl
extends AbstractMarshallerImpl
implements ValidationEventHandler

Implementation of Marshaller interface for the JAXB RI.

Eventually all the marshal(java.lang.Object, java.io.OutputStream, javax.xml.namespace.NamespaceContext) methods call into the write(com.sun.xml.bind.v2.runtime.Name, com.sun.xml.bind.v2.runtime.JaxBeanInfo, T, com.sun.xml.bind.v2.runtime.output.XmlOutput, java.lang.Runnable) method.

Author:
Kohsuke Kawaguchi, Vivek Pandey

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.xml.bind.Marshaller
Marshaller.Listener
 
Field Summary
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
           
 
Fields inherited from interface javax.xml.bind.Marshaller
JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION
 
Constructor Summary
MarshallerImpl(JAXBContextImpl c, AssociationMap assoc)
           
 
Method Summary
protected  CharacterEscapeHandler createEscapeHandler(String encoding)
           
 XmlOutput createWriter(OutputStream os)
           
 XmlOutput createWriter(OutputStream os, String encoding)
           
 XmlOutput createWriter(Writer w)
           
 XmlOutput createWriter(Writer w, String encoding)
           
<A extends XmlAdapter>
A
getAdapter(Class<A> type)
           
 AttachmentMarshaller getAttachmentMarshaller()
           
 JAXBContextImpl getContext()
           
 Marshaller.Listener getListener()
           
 Object getProperty(String name)
           
 Schema getSchema()
           
 boolean handleEvent(ValidationEvent event)
          Default error handling behavior fot Marshaller.
 void marshal(Object obj, OutputStream out, NamespaceContext inscopeNamespace)
          Marshals to OutputStream with the given in-scope namespaces taken into account.
 void marshal(Object target, Result result)
           
 void marshal(Object obj, javax.xml.stream.XMLEventWriter writer)
           
 void marshal(Object obj, XmlOutput output)
           
 void marshal(Object obj, javax.xml.stream.XMLStreamWriter writer)
           
<A extends XmlAdapter>
void
setAdapter(Class<A> type, A adapter)
           
 void setAttachmentMarshaller(AttachmentMarshaller am)
           
 void setListener(Marshaller.Listener listener)
           
 void setProperty(String name, Object value)
           
 void setSchema(Schema s)
           
protected
<T> void
write(Name rootTagName, JaxBeanInfo<T> bi, T obj, XmlOutput out, Runnable postInitAction)
          Used by BridgeImpl 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 inside BinderImpl.
Method Detail

getContext

public JAXBContextImpl getContext()

marshal

public void marshal(Object obj,
                    OutputStream out,
                    NamespaceContext inscopeNamespace)
             throws JAXBException
Marshals to OutputStream with the given in-scope namespaces taken into account.

Throws:
JAXBException
Since:
2.1.5

marshal

public void marshal(Object obj,
                    javax.xml.stream.XMLStreamWriter writer)
             throws JAXBException
Specified by:
marshal in interface Marshaller
Overrides:
marshal in class AbstractMarshallerImpl
Throws:
JAXBException

marshal

public void marshal(Object obj,
                    javax.xml.stream.XMLEventWriter writer)
             throws JAXBException
Specified by:
marshal in interface Marshaller
Overrides:
marshal in class AbstractMarshallerImpl
Throws:
JAXBException

marshal

public void marshal(Object obj,
                    XmlOutput output)
             throws JAXBException
Throws:
JAXBException

marshal

public void marshal(Object target,
                    Result result)
             throws JAXBException
Specified by:
marshal in interface Marshaller
Throws:
JAXBException

write

protected final <T> void write(Name rootTagName,
                               JaxBeanInfo<T> bi,
                               T obj,
                               XmlOutput out,
                               Runnable postInitAction)
                    throws JAXBException
Used by BridgeImpl to write an arbitrary object as a fragment.

Throws:
JAXBException

createEscapeHandler

protected CharacterEscapeHandler createEscapeHandler(String encoding)

createWriter

public XmlOutput createWriter(Writer w,
                              String encoding)

createWriter

public XmlOutput createWriter(Writer w)

createWriter

public XmlOutput createWriter(OutputStream os)
                       throws JAXBException
Throws:
JAXBException

createWriter

public XmlOutput createWriter(OutputStream os,
                              String encoding)
                       throws JAXBException
Throws:
JAXBException

getProperty

public Object getProperty(String name)
                   throws PropertyException
Specified by:
getProperty in interface Marshaller
Overrides:
getProperty in class AbstractMarshallerImpl
Throws:
PropertyException

setProperty

public void setProperty(String name,
                        Object value)
                 throws PropertyException
Specified by:
setProperty in interface Marshaller
Overrides:
setProperty in class AbstractMarshallerImpl
Throws:
PropertyException

setAdapter

public <A extends XmlAdapter> void setAdapter(Class<A> type,
                                              A adapter)
Specified by:
setAdapter in interface Marshaller
Overrides:
setAdapter in class AbstractMarshallerImpl

getAdapter

public <A extends XmlAdapter> A getAdapter(Class<A> type)
Specified by:
getAdapter in interface Marshaller
Overrides:
getAdapter in class AbstractMarshallerImpl

setAttachmentMarshaller

public void setAttachmentMarshaller(AttachmentMarshaller am)
Specified by:
setAttachmentMarshaller in interface Marshaller
Overrides:
setAttachmentMarshaller in class AbstractMarshallerImpl

getAttachmentMarshaller

public AttachmentMarshaller getAttachmentMarshaller()
Specified by:
getAttachmentMarshaller in interface Marshaller
Overrides:
getAttachmentMarshaller in class AbstractMarshallerImpl

getSchema

public Schema getSchema()
Specified by:
getSchema in interface Marshaller
Overrides:
getSchema in class AbstractMarshallerImpl

setSchema

public void setSchema(Schema s)
Specified by:
setSchema in interface Marshaller
Overrides:
setSchema in class AbstractMarshallerImpl

handleEvent

public boolean handleEvent(ValidationEvent event)
Default error handling behavior fot Marshaller.

Specified by:
handleEvent in interface ValidationEventHandler

getListener

public Marshaller.Listener getListener()
Specified by:
getListener in interface Marshaller
Overrides:
getListener in class AbstractMarshallerImpl

setListener

public void setListener(Marshaller.Listener listener)
Specified by:
setListener in interface Marshaller
Overrides:
setListener in class AbstractMarshallerImpl


Copyright © 2005-2011 Oracle Corporation. All Rights Reserved.