Class DomXmlDataFormat

  • All Implemented Interfaces:
    DataFormat

    public class DomXmlDataFormat
    extends java.lang.Object
    implements DataFormat
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory
      the DocumentBuilderFactory used by the reader
      protected static DomXmlLogger LOG  
      protected java.lang.String name  
      protected javax.xml.transform.TransformerFactory transformerFactory
      the TransformerFactory instance used by the writer
    • Constructor Summary

      Constructors 
      Constructor Description
      DomXmlDataFormat​(java.lang.String name)  
      DomXmlDataFormat​(java.lang.String name, javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)  
      DomXmlDataFormat​(java.lang.String name, javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory, javax.xml.transform.TransformerFactory transformerFactory)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canMap​(java.lang.Object value)
      Returns true if this data format can map the provided Java Object.
      protected javax.xml.bind.Marshaller createMarshaller​(java.lang.Class<?>... types)  
      protected javax.xml.bind.Unmarshaller createUnmarshaller​(java.lang.Class<?>... types)  
      static javax.xml.parsers.DocumentBuilderFactory defaultDocumentBuilderFactory()  
      static javax.xml.transform.TransformerFactory defaultTransformerFactory()  
      java.lang.String getCanonicalTypeName​(java.lang.Object value)
      Returns a data-format-specific canonical type name.
      protected javax.xml.bind.JAXBContext getContext​(java.lang.Class<?>... types)  
      protected javax.xml.parsers.DocumentBuilder getDocumentBuilder()  
      javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()  
      java.lang.String getName()
      Returns the data format name.
      protected javax.xml.transform.Transformer getTransformer()  
      javax.xml.transform.TransformerFactory getTransformerFactory()  
      static java.lang.Class<?> loadClass​(java.lang.String classname, DataFormat dataFormat)  
      org.w3c.dom.Element readAsElement​(java.lang.String value)  
      <T> T readValue​(java.lang.String value, java.lang.Class<T> cls)
      Reads the internal representation of a data format to a java object of the desired class.
      <T> T readValue​(java.lang.String value, java.lang.String typeIdentifier)
      Reads the internal representation of a data format to a java object of the desired class.
      protected org.w3c.dom.Element writeAsElement​(java.lang.Object value)  
      protected void writeResult​(javax.xml.transform.stream.StreamResult streamResult, java.lang.Object input)  
      java.lang.String writeValue​(java.lang.Object value)
      Writes a java object to a data format's internal data representation.
      • Methods inherited from class java.lang.Object

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

      • name

        protected java.lang.String name
      • documentBuilderFactory

        protected javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory
        the DocumentBuilderFactory used by the reader
      • transformerFactory

        protected javax.xml.transform.TransformerFactory transformerFactory
        the TransformerFactory instance used by the writer
    • Constructor Detail

      • DomXmlDataFormat

        public DomXmlDataFormat​(java.lang.String name)
      • DomXmlDataFormat

        public DomXmlDataFormat​(java.lang.String name,
                                javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
      • DomXmlDataFormat

        public DomXmlDataFormat​(java.lang.String name,
                                javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory,
                                javax.xml.transform.TransformerFactory transformerFactory)
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: DataFormat
        Returns the data format name.
        Specified by:
        getName in interface DataFormat
      • getDocumentBuilderFactory

        public javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
      • getTransformerFactory

        public javax.xml.transform.TransformerFactory getTransformerFactory()
      • canMap

        public boolean canMap​(java.lang.Object value)
        Description copied from interface: DataFormat
        Returns true if this data format can map the provided Java Object.
        Specified by:
        canMap in interface DataFormat
        Returns:
        true if this object can be mapped.
      • writeValue

        public java.lang.String writeValue​(java.lang.Object value)
        Description copied from interface: DataFormat
        Writes a java object to a data format's internal data representation.
        Specified by:
        writeValue in interface DataFormat
        Parameters:
        value - object that is written into internal data representation
        Returns:
        the data format's internal representation of that object
      • readValue

        public <T> T readValue​(java.lang.String value,
                               java.lang.String typeIdentifier)
        Description copied from interface: DataFormat
        Reads the internal representation of a data format to a java object of the desired class.
        Specified by:
        readValue in interface DataFormat
        Parameters:
        value - the object to be read
        typeIdentifier - the class to map the object to
        Returns:
        a java object of the specified class that was populated with the input parameter
      • readValue

        public <T> T readValue​(java.lang.String value,
                               java.lang.Class<T> cls)
        Description copied from interface: DataFormat
        Reads the internal representation of a data format to a java object of the desired class.
        Specified by:
        readValue in interface DataFormat
        Parameters:
        value - the object to be read
        cls - a data-format-specific type identifier that describes the class to map to
        Returns:
        a java object of the specified class that was populated with the input parameter
      • getCanonicalTypeName

        public java.lang.String getCanonicalTypeName​(java.lang.Object value)
        Description copied from interface: DataFormat
        Returns a data-format-specific canonical type name.
        Specified by:
        getCanonicalTypeName in interface DataFormat
      • writeResult

        protected void writeResult​(javax.xml.transform.stream.StreamResult streamResult,
                                   java.lang.Object input)
      • writeAsElement

        protected org.w3c.dom.Element writeAsElement​(java.lang.Object value)
      • getTransformer

        protected javax.xml.transform.Transformer getTransformer()
      • readAsElement

        public org.w3c.dom.Element readAsElement​(java.lang.String value)
      • getDocumentBuilder

        protected javax.xml.parsers.DocumentBuilder getDocumentBuilder()
      • getContext

        protected javax.xml.bind.JAXBContext getContext​(java.lang.Class<?>... types)
      • createMarshaller

        protected javax.xml.bind.Marshaller createMarshaller​(java.lang.Class<?>... types)
      • createUnmarshaller

        protected javax.xml.bind.Unmarshaller createUnmarshaller​(java.lang.Class<?>... types)
      • defaultTransformerFactory

        public static javax.xml.transform.TransformerFactory defaultTransformerFactory()
      • defaultDocumentBuilderFactory

        public static javax.xml.parsers.DocumentBuilderFactory defaultDocumentBuilderFactory()
      • loadClass

        public static java.lang.Class<?> loadClass​(java.lang.String classname,
                                                   DataFormat dataFormat)