Home » spring-ws-1.5.9-with-dependencies » org.springframework » oxm » castor » [javadoc | source]
org.springframework.oxm.castor
public class: CastorMarshaller [javadoc | source]
java.lang.Object
   org.springframework.oxm.AbstractMarshaller
      org.springframework.oxm.castor.CastorMarshaller

All Implemented Interfaces:
    org.springframework.beans.factory.InitializingBean, Unmarshaller, Marshaller

Implementation of the Marshaller interface for Castor. By default, Castor does not require any further configuration, though setting a target class or providing a mapping file can be used to have more control over the behavior of Castor.

If a target class is specified using setTargetClass, the CastorMarshaller can only be used to unmarshall XML that represents that specific class. If you want to unmarshall multiple classes, you have to provide a mapping file using setMappingLocations.

Due to Castor's API, it is required to set the encoding used for writing to output streams. It defaults to UTF-8.

Field Summary
public static final  String DEFAULT_ENCODING    The default encoding used for stream access. 
Fields inherited from org.springframework.oxm.AbstractMarshaller:
logger
Method from org.springframework.oxm.castor.CastorMarshaller Summary:
afterPropertiesSet,   convertCastorException,   createXMLContext,   customizeMarshaller,   customizeUnmarshaller,   getIgnoreExtraAttributes,   getIgnoreExtraElements,   getNamespaceMappings,   getWhitespacePreserve,   isSuppressNamespaces,   isSuppressXsiType,   isValidating,   marshalDomNode,   marshalOutputStream,   marshalSaxHandlers,   marshalWriter,   marshalXmlEventWriter,   marshalXmlStreamWriter,   setEncoding,   setIgnoreExtraAttributes,   setIgnoreExtraElements,   setMappingLocation,   setMappingLocations,   setNamespaceMappings,   setSuppressNamespaces,   setSuppressXsiType,   setTargetClass,   setValidating,   setWhitespacePreserve,   supports,   unmarshalDomNode,   unmarshalInputStream,   unmarshalReader,   unmarshalSaxReader,   unmarshalXmlEventReader,   unmarshalXmlStreamReader
Methods from org.springframework.oxm.AbstractMarshaller:
createDocumentBuilder,   createDocumentBuilderFactory,   createXmlReader,   marshal,   marshalDomNode,   marshalDomResult,   marshalOutputStream,   marshalSaxHandlers,   marshalSaxResult,   marshalStaxResult,   marshalStreamResult,   marshalWriter,   marshalXmlEventWriter,   marshalXmlStreamWriter,   unmarshal,   unmarshalDomNode,   unmarshalDomSource,   unmarshalInputStream,   unmarshalReader,   unmarshalSaxReader,   unmarshalSaxSource,   unmarshalStaxSource,   unmarshalStreamSource,   unmarshalXmlEventReader,   unmarshalXmlStreamReader
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.oxm.castor.CastorMarshaller Detail:
 public final  void afterPropertiesSet() throws IOException 
 public XmlMappingException convertCastorException(XMLException ex,
    boolean marshalling) 
    Converts the given CastorException to an appropriate exception from the org.springframework.oxm hierarchy.

    The default implementation delegates to CastorUtils. Can be overridden in subclasses.

    A boolean flag is used to indicate whether this exception occurs during marshalling or unmarshalling, since Castor itself does not make this distinction in its exception hierarchy.

 protected XMLContext createXMLContext(Resource[] mappingLocations,
    Class targetClass) throws MappingException, IOException, ResolverException 
    Creates the Castor XMLContext. Subclasses can override this to create a custom context.

    The default implementation loads mapping files if defined, and the target class if not defined.

 protected  void customizeMarshaller(Marshaller marshaller) 
 protected  void customizeUnmarshaller(Unmarshaller unmarshaller) 
 public boolean getIgnoreExtraAttributes() 
    Returns whether the Castor Unmarshaller should ignore attributes that do not match a specific field.
 public boolean getIgnoreExtraElements() 
    Returns whether the Castor Unmarshaller should ignore elements that do not match a specific field.
 public Properties getNamespaceMappings() 
    Returns the namespace mappings. Property names are interpreted as namespace prefixes; values are namespace URIs.
 public boolean getWhitespacePreserve() 
    Returns whether the Castor Unmarshaller should preserve "ignorable" whitespace.
 public boolean isSuppressNamespaces() 
    Returns whether this marshaller should output namespaces.
 public boolean isSuppressXsiType() 
    Sets whether this marshaller should output the xsi:type attribute.
 public boolean isValidating() 
    Returns whether this marshaller should validate in- and outgoing documents.
 protected final  void marshalDomNode(Object graph,
    Node node) throws XmlMappingException 
 protected final  void marshalOutputStream(Object graph,
    OutputStream outputStream) throws XmlMappingException, IOException 
 protected final  void marshalSaxHandlers(Object graph,
    ContentHandler contentHandler,
    LexicalHandler lexicalHandler) throws XmlMappingException 
 protected final  void marshalWriter(Object graph,
    Writer writer) throws XmlMappingException, IOException 
 protected final  void marshalXmlEventWriter(Object graph,
    XMLEventWriter eventWriter) throws XmlMappingException 
 protected final  void marshalXmlStreamWriter(Object graph,
    XMLStreamWriter streamWriter) throws XmlMappingException 
 public  void setEncoding(String encoding) 
    Sets the encoding to be used for stream access. If this property is not set, the default encoding is used.
 public  void setIgnoreExtraAttributes(boolean ignoreExtraAttributes) 
    Sets whether the Castor Unmarshaller should ignore attributes that do not match a specific field. Default is true: extra attributes are ignored.
 public  void setIgnoreExtraElements(boolean ignoreExtraElements) 
    Sets whether the Castor Unmarshaller should ignore elements that do not match a specific field. Default is false, extra attributes are flagged as an error.
 public  void setMappingLocation(Resource mappingLocation) 
    Sets the locations of the Castor XML Mapping files.
 public  void setMappingLocations(Resource[] mappingLocations) 
    Sets the locations of the Castor XML Mapping files.
 public  void setNamespaceMappings(Properties namespaceMappings) 
    Sets the namespace mappings. Property names are interpreted as namespace prefixes; values are namespace URIs.
 public  void setSuppressNamespaces(boolean suppressNamespaces) 
    Sets whether this marshaller should output namespaces. The default is {@code false}, i.e. namespaces are written.
 public  void setSuppressXsiType(boolean suppressXsiType) 
    Sets whether this marshaller should output the {@code xsi:type} attribute. The default is {@code false}, i.e. the {@code xsi:type} is written.
 public  void setTargetClass(Class targetClass) 
    Sets the Castor target class. If this property is set, this CastorMarshaller is tied to this one specific class. Use a mapping file for unmarshalling multiple classes.
 public  void setValidating(boolean validating) 
    Sets whether this marshaller should validate in- and outgoing documents. Default is false.
 public  void setWhitespacePreserve(boolean whitespacePreserve) 
    Sets whether the Castor Unmarshaller should preserve "ignorable" whitespace. Default is false.
 public boolean supports(Class clazz) 
    Returns true for all classes, i.e. Castor supports arbitrary classes.
 protected final Object unmarshalDomNode(Node node) throws XmlMappingException 
 protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException 
 protected final Object unmarshalReader(Reader reader) throws XmlMappingException, IOException 
 protected final Object unmarshalSaxReader(XMLReader xmlReader,
    InputSource inputSource) throws XmlMappingException, IOException 
 protected final Object unmarshalXmlEventReader(XMLEventReader eventReader) 
 protected final Object unmarshalXmlStreamReader(XMLStreamReader streamReader)