Class XmpSerializer


  • public class XmpSerializer
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      XmpSerializer()
      Default constructor.
      XmpSerializer​(javax.xml.transform.TransformerFactory transformerFactory, javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
      Constructor to be used if other factories than the default ones are needed.
    • Field Detail

      • transformerFactory

        private final javax.xml.transform.TransformerFactory transformerFactory
      • documentBuilder

        private final javax.xml.parsers.DocumentBuilder documentBuilder
      • parseTypeResourceForLi

        private boolean parseTypeResourceForLi
    • Constructor Detail

      • XmpSerializer

        public XmpSerializer()
        Default constructor.
      • XmpSerializer

        public XmpSerializer​(javax.xml.transform.TransformerFactory transformerFactory,
                             javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
        Constructor to be used if other factories than the default ones are needed.
        Parameters:
        transformerFactory - transformer factory to be used
        documentBuilderFactory - document builder factory to be used
    • Method Detail

      • serialize

        public void serialize​(XMPMetadata metadata,
                              java.io.OutputStream os,
                              boolean withXpacket)
                       throws javax.xml.transform.TransformerException
        Throws:
        javax.xml.transform.TransformerException
      • serializeSchema

        protected org.w3c.dom.Element serializeSchema​(org.w3c.dom.Document doc,
                                                      XMPSchema schema)
      • serializeFields

        public void serializeFields​(org.w3c.dom.Document doc,
                                    org.w3c.dom.Element parent,
                                    java.util.List<AbstractField> fields,
                                    java.lang.String resourceNS,
                                    java.lang.String prefix,
                                    boolean wrapWithProperty)
      • fillElementWithAttributes

        private void fillElementWithAttributes​(org.w3c.dom.Element target,
                                               AbstractComplexProperty property)
      • normalizeAttributes

        private java.util.List<Attribute> normalizeAttributes​(AbstractComplexProperty property)
        Normalize the list of attributes. Attributes which match a schema property are serialized as child elements so only return the ones which do not match a schema property
        Parameters:
        property - the property that needs to be inspected
        Returns:
        the list of attributed for serializing
      • createRdfElement

        protected org.w3c.dom.Element createRdfElement​(org.w3c.dom.Document doc,
                                                       XMPMetadata metadata,
                                                       boolean withXpacket)
      • save

        private void save​(org.w3c.dom.Node doc,
                          java.io.OutputStream outStream,
                          java.lang.String encoding)
                   throws javax.xml.transform.TransformerException
        Save the XML document to an output stream.
        Parameters:
        doc - The XML document to save.
        outStream - The stream to save the document to.
        encoding - The encoding to save the file as.
        Throws:
        javax.xml.transform.TransformerException - If there is an error while saving the XML.