Class CrafterXStreamMarshaller

java.lang.Object
org.springframework.oxm.support.AbstractMarshaller
org.springframework.oxm.xstream.XStreamMarshaller
org.craftercms.core.util.xml.marshalling.xstream.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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    protected boolean
     
    static final String
     
    protected Class[]
     
    static final String
     

    Fields inherited from class org.springframework.oxm.xstream.XStreamMarshaller

    DEFAULT_ENCODING

    Fields inherited from class org.springframework.oxm.support.AbstractMarshaller

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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: Is NOT the same, a subclass or subinterface of one of the unsupported classes. 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.

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CrafterXStreamMarshaller

      public CrafterXStreamMarshaller()
  • Method Details

    • 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