|
Spring Web Services Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.oxm.AbstractMarshaller
org.springframework.oxm.xstream.XStreamMarshaller
public class XStreamMarshaller
Implementation of the Marshaller interface for XStream. By default, XStream does not require any further
configuration, though class aliases can be used to have more control over the behavior of XStream.
UTF-8.
Note that XStream is an XML serialization library, not a data binding library. Therefore, it has limited
namespace support. As such, it is rather unsuitable for usage within Web services.
setEncoding(String),
DEFAULT_ENCODING,
setAliases(Map),
setConverters(ConverterMatcher[])| Field Summary | |
|---|---|
static String |
DEFAULT_ENCODING
The default encoding used for stream access. |
| Fields inherited from class org.springframework.oxm.AbstractMarshaller |
|---|
logger |
| Constructor Summary | |
|---|---|
XStreamMarshaller()
|
|
| Method Summary | |
|---|---|
void |
addAlias(String name,
Class type)
Adds an alias for the given type. |
void |
addImplicitCollection(String name,
Class type)
Adds an implicit Collection for the given type. |
void |
addOmittedField(Class type,
String fieldName)
Adds an omitted field for the given type. |
XmlMappingException |
convertXStreamException(Exception ex,
boolean marshalling)
Convert the given XStream exception to an appropriate exception from the org.springframework.oxm
hierarchy. |
String |
getEncoding()
Returns the encoding to be used for stream access. |
com.thoughtworks.xstream.XStream |
getXStream()
Returns the XStream instance used by this marshaller. |
protected void |
marshalDomNode(Object graph,
Node node)
Abstract template method for marshalling the given object graph to a DOM Node. |
protected void |
marshalOutputStream(Object graph,
OutputStream outputStream)
Abstract template method for marshalling the given object graph to a OutputStream. |
protected void |
marshalSaxHandlers(Object graph,
ContentHandler contentHandler,
LexicalHandler lexicalHandler)
Abstract template method for marshalling the given object graph to a SAX ContentHandler. |
protected void |
marshalWriter(Object graph,
Writer writer)
Abstract template method for marshalling the given object graph to a Writer. |
protected void |
marshalXmlEventWriter(Object graph,
XMLEventWriter eventWriter)
Abstract template method for marshalling the given object to a StAX XMLEventWriter. |
protected void |
marshalXmlStreamWriter(Object graph,
XMLStreamWriter streamWriter)
Abstract template method for marshalling the given object to a StAX XMLStreamWriter. |
void |
setAliases(Map aliases)
Set a alias/type map, consisting of string aliases mapped to Class instances (or Strings to be
converted to Class instances). |
void |
setConverters(com.thoughtworks.xstream.converters.ConverterMatcher[] converters)
Sets the Converters or SingleValueConverters to be registered with the
XStream instance. |
void |
setEncoding(String encoding)
Sets the encoding to be used for stream access. |
void |
setImplicitCollection(Map implicitCollection)
Set a implicit colletion/type map, consisting of string implicit collection mapped to Class
instances (or Strings to be converted to Class instances). |
void |
setMode(int mode)
Sets the XStream mode. |
void |
setOmittedFields(Map omittedFields)
Sets a ommited field map, consisting of Class instances (or Strings to be converted to
Class instances) mapped to comma separated field names. |
void |
setStreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver streamDriver)
Sets the XStream hierarchical stream driver to be used with stream readers and writers |
void |
setSupportedClasses(Class[] supportedClasses)
Sets the classes supported by this marshaller. |
void |
setUseAttributeFor(Map attributes)
Sets the types to use XML attributes for. |
void |
setUseAttributeForTypes(Class[] types)
Sets types to use XML attributes for. |
boolean |
supports(Class clazz)
Indicates whether this marshaller can marshal instances of the supplied type. |
protected Object |
unmarshalDomNode(Node node)
Abstract template method for unmarshalling from a given DOM Node. |
protected Object |
unmarshalInputStream(InputStream inputStream)
Abstract template method for unmarshalling from a given InputStream. |
protected Object |
unmarshalReader(Reader reader)
Abstract template method for unmarshalling from a given Reader. |
protected Object |
unmarshalSaxReader(XMLReader xmlReader,
InputSource inputSource)
Abstract template method for unmarshalling using a given SAX XMLReader and
InputSource. |
protected Object |
unmarshalXmlEventReader(XMLEventReader eventReader)
Abstract template method for unmarshalling from a given Stax XMLEventReader. |
protected Object |
unmarshalXmlStreamReader(XMLStreamReader streamReader)
Abstract template method for unmarshalling from a given Stax XMLStreamReader. |
| Methods inherited from class org.springframework.oxm.AbstractMarshaller |
|---|
createDocumentBuilder, createDocumentBuilderFactory, createXmlReader, marshal, marshalDomResult, marshalSaxResult, marshalStaxResult, marshalStreamResult, unmarshal, unmarshalDomSource, unmarshalSaxSource, unmarshalStaxSource, unmarshalStreamSource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_ENCODING
| Constructor Detail |
|---|
public XStreamMarshaller()
| Method Detail |
|---|
public String getEncoding()
DEFAULT_ENCODINGpublic void setEncoding(String encoding)
DEFAULT_ENCODINGpublic com.thoughtworks.xstream.XStream getXStream()
public void setMode(int mode)
XStream.XPATH_REFERENCES,
XStream.ID_REFERENCES,
XStream.NO_REFERENCESpublic void setSupportedClasses(Class[] supportedClasses)
supports(Class)public void setConverters(com.thoughtworks.xstream.converters.ConverterMatcher[] converters)
Converters or SingleValueConverters to be registered with the
XStream instance.
Converter,
SingleValueConverterpublic void setStreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver streamDriver)
public void setAliases(Map aliases)
Class instances (or Strings to be
converted to Class instances).
ClassEditor
public void addAlias(String name,
Class type)
name - alias to be used for the typetype - the type to be aliasedpublic void setUseAttributeForTypes(Class[] types)
XStream.useAttributeFor(Class)public void setUseAttributeFor(Map attributes)
<String, Class>
pairs, in which case XStream.useAttributeFor(String,Class) is called, or <Class,
String> pairs, which results in XStream.useAttributeFor(Class,String).
public void addImplicitCollection(String name,
Class type)
XStream.addImplicitCollection(Class, String)public void setImplicitCollection(Map implicitCollection)
Class
instances (or Strings to be converted to Class instances).
XStream.addImplicitCollection(Class, String)
public void addOmittedField(Class type,
String fieldName)
type - the type to be containing the fieldfieldName - field to omittXStream.omitField(Class, String)public void setOmittedFields(Map omittedFields)
Class instances (or Strings to be converted to
Class instances) mapped to comma separated field names.
XStream.omitField(Class, String)public boolean supports(Class clazz)
Marshaller
clazz - the class that this marshaller is being asked if it can marshal
true if this marshaller can indeed marshal instances of the supplied class;
false otherwise
public XmlMappingException convertXStreamException(Exception ex,
boolean marshalling)
org.springframework.oxm
hierarchy.
The default implementation delegates to XStreamUtils. Can be overridden in subclasses.
ex - exception that occuredmarshalling - indicates whether the exception occurs during marshalling (true), or
unmarshalling (false)
XmlMappingException instanceXStreamUtils.convertXStreamException(Exception,boolean)
protected void marshalDomNode(Object graph,
Node node)
throws XmlMappingException
AbstractMarshallerNode.
In practice, node is be a Document node, a DocumentFragment node, or a
Element node. In other words, a node that accepts children.
marshalDomNode in class AbstractMarshallergraph - the root of the object graph to marshalnode - The DOM node that will contain the result tree
XmlMappingException - if the given object cannot be marshalled to the DOM nodeDocument,
DocumentFragment,
Element
protected void marshalXmlEventWriter(Object graph,
XMLEventWriter eventWriter)
throws XmlMappingException
AbstractMarshallerXMLEventWriter.
marshalXmlEventWriter in class AbstractMarshallergraph - the root of the object graph to marshaleventWriter - the XMLEventWriter to write to
XmlMappingException - if the given object cannot be marshalled to the DOM node
protected void marshalXmlStreamWriter(Object graph,
XMLStreamWriter streamWriter)
throws XmlMappingException
AbstractMarshallerXMLStreamWriter.
marshalXmlStreamWriter in class AbstractMarshallergraph - the root of the object graph to marshalstreamWriter - the XMLStreamWriter to write to
XmlMappingException - if the given object cannot be marshalled to the DOM node
protected void marshalOutputStream(Object graph,
OutputStream outputStream)
throws XmlMappingException,
IOException
AbstractMarshallerOutputStream.
marshalOutputStream in class AbstractMarshallergraph - the root of the object graph to marshaloutputStream - the OutputStream to write to
XmlMappingException - if the given object cannot be marshalled to the writer
IOException - if an I/O exception occurs
protected void marshalSaxHandlers(Object graph,
ContentHandler contentHandler,
LexicalHandler lexicalHandler)
throws XmlMappingException
AbstractMarshallerContentHandler.
marshalSaxHandlers in class AbstractMarshallergraph - the root of the object graph to marshalcontentHandler - the SAX ContentHandlerlexicalHandler - the SAX2 LexicalHandler. Can be null.
XmlMappingException - if the given object cannot be marshalled to the handlers
protected void marshalWriter(Object graph,
Writer writer)
throws XmlMappingException,
IOException
AbstractMarshallerWriter.
marshalWriter in class AbstractMarshallergraph - the root of the object graph to marshalwriter - the Writer to write to
XmlMappingException - if the given object cannot be marshalled to the writer
IOException - if an I/O exception occurs
protected Object unmarshalDomNode(Node node)
throws XmlMappingException
AbstractMarshallerNode.
unmarshalDomNode in class AbstractMarshallernode - The DOM node that contains the objects to be unmarshalled
XmlMappingException - if the given DOM node cannot be mapped to an object
protected Object unmarshalXmlEventReader(XMLEventReader eventReader)
throws XmlMappingException
AbstractMarshallerXMLEventReader.
unmarshalXmlEventReader in class AbstractMarshallereventReader - The XMLEventReader to read from
XmlMappingException - if the given event reader cannot be converted to an object
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader)
throws XmlMappingException
AbstractMarshallerXMLStreamReader.
unmarshalXmlStreamReader in class AbstractMarshallerstreamReader - The XMLStreamReader to read from
XmlMappingException - if the given stream reader cannot be converted to an object
protected Object unmarshalInputStream(InputStream inputStream)
throws XmlMappingException,
IOException
AbstractMarshallerInputStream.
unmarshalInputStream in class AbstractMarshallerinputStream - the InputStreamStream to read from
XmlMappingException - if the given stream cannot be converted to an object
IOException - if an I/O exception occurs
protected Object unmarshalReader(Reader reader)
throws XmlMappingException,
IOException
AbstractMarshallerReader.
unmarshalReader in class AbstractMarshallerreader - the Reader to read from
XmlMappingException - if the given reader cannot be converted to an object
IOException - if an I/O exception occurs
protected Object unmarshalSaxReader(XMLReader xmlReader,
InputSource inputSource)
throws XmlMappingException,
IOException
AbstractMarshallerXMLReader and
InputSource.
unmarshalSaxReader in class AbstractMarshallerxmlReader - the SAX XMLReader to parse withinputSource - the input source to parse from
XmlMappingException - if the given reader and input source cannot be converted to an object
IOException - if an I/O exception occurs
|
Spring Web Services Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||