Class CrafterXStreamMarshaller

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.InitializingBean, org.springframework.oxm.Marshaller, org.springframework.oxm.Unmarshaller

    public class CrafterXStreamMarshaller
    extends org.springframework.oxm.xstream.XStreamMarshaller
    Extension of XStreamMarshaller that:

    1. Provides correct marshalling/unmarshalling support for Crafter objects.
    2. Adds a unsupportedClasses property to exclude any unwanted classes from being marshalled/unmarshalled
    Author:
    Alfonso Vásquez
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void customizeXStream​(com.thoughtworks.xstream.XStream xstream)  
      void marshalWriter​(Object graph, Writer writer, com.thoughtworks.xstream.converters.DataHolder dataHolder)
      Just as super(), but instead of a CompactWriter creates a EscapingCompactWriter.
      void setSuppressXmlDeclaration​(boolean suppressXmlDeclaration)  
      void setUnsupportedClasses​(Class[] unsupportedClasses)  
      boolean supports​(Class clazz)
      Returns true if the specified class:
      • Methods inherited from class org.springframework.oxm.xstream.XStreamMarshaller

        afterPropertiesSet, buildXStream, configureXStream, constructXStream, convertXStreamException, getDefaultEncoding, getXStream, marshalDomNode, marshalOutputStream, marshalOutputStream, marshalSaxHandlers, marshalWriter, marshalXmlEventWriter, marshalXmlStreamWriter, setAliases, setAliasesByType, setAnnotatedClasses, setAutodetectAnnotations, setBeanClassLoader, setConverterLookup, setConverterRegistry, setConverters, setEncoding, setFieldAliases, setImplicitCollections, setMapper, setMapperWrappers, setMarshallingStrategy, setMode, setNameCoder, setOmittedFields, setReflectionProvider, setStreamDriver, setSupportedClasses, setTypePermissions, setUseAttributeFor, setUseAttributeForTypes, unmarshalDomNode, unmarshalInputStream, unmarshalInputStream, unmarshalReader, unmarshalReader, unmarshalSaxReader, unmarshalStreamSource, unmarshalXmlEventReader, unmarshalXmlStreamReader
      • Methods inherited from class org.springframework.oxm.support.AbstractMarshaller

        buildDocument, createDocumentBuilder, createDocumentBuilderFactory, createXmlReader, isProcessExternalEntities, isSupportDtd, marshal, marshalDomResult, marshalSaxResult, marshalStaxResult, marshalStreamResult, setProcessExternalEntities, setSupportDtd, unmarshal, unmarshalDomSource, unmarshalSaxSource, unmarshalStaxSource
    • Constructor Detail

      • CrafterXStreamMarshaller

        public CrafterXStreamMarshaller()
    • Method Detail

      • setUnsupportedClasses

        public void setUnsupportedClasses​(Class[] unsupportedClasses)
      • setSuppressXmlDeclaration

        public void setSuppressXmlDeclaration​(boolean suppressXmlDeclaration)
      • customizeXStream

        protected void customizeXStream​(com.thoughtworks.xstream.XStream xstream)
        Overrides:
        customizeXStream in class org.springframework.oxm.xstream.XStreamMarshaller
      • supports

        public boolean supports​(Class clazz)
        Returns true if the specified class:

        1. Is NOT the same, a subclass or subinterface of one of the unsupported classes.
        2. Is the the same, a subclass or subinterface of one of the supported classes.

        Also returns true if there aren't any unsupported or supported classes.

        Specified by:
        supports in interface org.springframework.oxm.Marshaller
        Specified by:
        supports in interface org.springframework.oxm.Unmarshaller
        Overrides:
        supports in class org.springframework.oxm.xstream.XStreamMarshaller
      • marshalWriter

        public void marshalWriter​(Object graph,
                                  Writer writer,
                                  com.thoughtworks.xstream.converters.DataHolder dataHolder)
                           throws org.springframework.oxm.XmlMappingException,
                                  IOException
        Just as super(), but instead of a CompactWriter creates a EscapingCompactWriter. Also if the object graph is a Dom4j document, the document is written directly instead of using XStream.
        Overrides:
        marshalWriter in class org.springframework.oxm.xstream.XStreamMarshaller
        Throws:
        org.springframework.oxm.XmlMappingException
        IOException