Class DomXmlDataFormatMapper

  • All Implemented Interfaces:
    DataFormatMapper

    public class DomXmlDataFormatMapper
    extends java.lang.Object
    implements DataFormatMapper
    DataFormatMapper using JAXB for mapping Java Objects to XML and vice-versa.
    Author:
    Stefan Hentschel., Daniel Meyer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canMap​(java.lang.Object parameter)
      Returns true if this mapper can map the provided Java Object.
      java.lang.String getCanonicalTypeName​(java.lang.Object object)  
      protected javax.xml.bind.Marshaller getMarshaller​(java.lang.Class<?> parameter)  
      protected javax.xml.bind.Unmarshaller getUnmarshaller​(java.lang.Class<?> parameter)  
      <T> T mapInternalToJava​(java.lang.Object parameter, java.lang.Class<T> javaClass)
      Maps the internal representation of a data format to a java object of the desired class.
      <T> T mapInternalToJava​(java.lang.Object parameter, java.lang.Class<T> javaClass, DeserializationTypeValidator validator)
      Maps the internal representation of a data format to a java object of the desired class.
      <T> T mapInternalToJava​(java.lang.Object parameter, java.lang.String classIdentifier)
      Maps the internal representation of a data format to a java object of the desired class.
      <T> T mapInternalToJava​(java.lang.Object parameter, java.lang.String classIdentifier, DeserializationTypeValidator validator)
      Maps the internal representation of a data format to a java object of the desired class.
      java.lang.Object mapJavaToInternal​(java.lang.Object parameter)
      Maps a java object to a data format's internal data representation.
      protected void marshalNonRootElement​(java.lang.Object parameter, javax.xml.bind.Marshaller marshaller, javax.xml.transform.dom.DOMResult domResult)  
      protected void marshalRootElement​(java.lang.Object parameter, javax.xml.bind.Marshaller marshaller, javax.xml.transform.dom.DOMResult domResult)  
      protected void validateType​(java.lang.Class<?> type, DeserializationTypeValidator validator)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DomXmlDataFormatMapper

        public DomXmlDataFormatMapper​(DomXmlDataFormat format)
    • Method Detail

      • canMap

        public boolean canMap​(java.lang.Object parameter)
        Description copied from interface: DataFormatMapper
        Returns true if this mapper can map the provided Java Object.
        Specified by:
        canMap in interface DataFormatMapper
        Parameters:
        parameter - the java object to check
        Returns:
        true if this object can be mapped.
      • mapJavaToInternal

        public java.lang.Object mapJavaToInternal​(java.lang.Object parameter)
        Description copied from interface: DataFormatMapper
        Maps a java object to a data format's internal data representation.
        Specified by:
        mapJavaToInternal in interface DataFormatMapper
        Parameters:
        parameter - object that is mapped
        Returns:
        the data format's internal representation of that object
      • marshalRootElement

        protected void marshalRootElement​(java.lang.Object parameter,
                                          javax.xml.bind.Marshaller marshaller,
                                          javax.xml.transform.dom.DOMResult domResult)
                                   throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • marshalNonRootElement

        protected void marshalNonRootElement​(java.lang.Object parameter,
                                             javax.xml.bind.Marshaller marshaller,
                                             javax.xml.transform.dom.DOMResult domResult)
                                      throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • mapInternalToJava

        public <T> T mapInternalToJava​(java.lang.Object parameter,
                                       java.lang.Class<T> javaClass)
        Description copied from interface: DataFormatMapper
        Maps the internal representation of a data format to a java object of the desired class. The desired class is not validated prior to the mapping.
        Specified by:
        mapInternalToJava in interface DataFormatMapper
        Parameters:
        parameter - the object to be mapped
        javaClass - the class to map the object to
        Returns:
        a java object of the specified class that was populated with the input parameter
      • mapInternalToJava

        public <T> T mapInternalToJava​(java.lang.Object parameter,
                                       java.lang.Class<T> javaClass,
                                       DeserializationTypeValidator validator)
        Description copied from interface: DataFormatMapper
        Maps the internal representation of a data format to a java object of the desired class. The desired class is validated by the validator prior to the mapping.
        Specified by:
        mapInternalToJava in interface DataFormatMapper
        Parameters:
        parameter - the object to be mapped
        javaClass - the class to map the object to
        validator - the validator for the target class
        Returns:
        a java object of the specified class that was populated with the input parameter
      • mapInternalToJava

        public <T> T mapInternalToJava​(java.lang.Object parameter,
                                       java.lang.String classIdentifier)
        Description copied from interface: DataFormatMapper
        Maps the internal representation of a data format to a java object of the desired class. The type identifier is given in a data format specific format. Its interpretation is data-format-specific. For example, it can be used to express generic type information that cannot be expressed by a Class object. The desired class is not validated prior to the mapping.
        Specified by:
        mapInternalToJava in interface DataFormatMapper
        Parameters:
        parameter - the object to be mapped
        classIdentifier - a data-format-specific type identifier that describes the class to map to
        Returns:
        a java object of the specified type that was populated with the input parameter
      • mapInternalToJava

        public <T> T mapInternalToJava​(java.lang.Object parameter,
                                       java.lang.String classIdentifier,
                                       DeserializationTypeValidator validator)
        Description copied from interface: DataFormatMapper
        Maps the internal representation of a data format to a java object of the desired class. The type identifier is given in a data format specific format. Its interpretation is data-format-specific. For example, it can be used to express generic type information that cannot be expressed by a Class object. The desired class is validated by the validator prior to the mapping.
        Specified by:
        mapInternalToJava in interface DataFormatMapper
        Parameters:
        parameter - the object to be mapped
        classIdentifier - a data-format-specific type identifier that describes the class to map to
        validator - the validator for the target class
        Returns:
        a java object of the specified type that was populated with the input parameter
      • getMarshaller

        protected javax.xml.bind.Marshaller getMarshaller​(java.lang.Class<?> parameter)
                                                   throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • getUnmarshaller

        protected javax.xml.bind.Unmarshaller getUnmarshaller​(java.lang.Class<?> parameter)
                                                       throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException