Class XmpReader


  • public class XmpReader
    extends java.lang.Object
    Reads an XMP stream into an org.w3c.dom.Document objects. Allows you to replace the contents of a specific tag.
    Since:
    2.1.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.w3c.dom.Document domDocument  
    • Constructor Summary

      Constructors 
      Constructor Description
      XmpReader​(byte[] bytes)
      Constructs an XMP reader
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.String parent, java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)
      Adds a tag.
      boolean replace​(java.lang.String parent, java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)
      Replaces the content of a tag.
      byte[] serializeDoc()
      Writes the document to a byte array.
      private boolean setNodeText​(org.w3c.dom.Document domDocument, org.w3c.dom.Node n, java.lang.String value)
      Sets the text of this node.
      • Methods inherited from class java.lang.Object

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

      • domDocument

        private org.w3c.dom.Document domDocument
    • Constructor Detail

      • XmpReader

        public XmpReader​(byte[] bytes)
                  throws org.xml.sax.SAXException,
                         java.io.IOException
        Constructs an XMP reader
        Parameters:
        bytes - the XMP content
        Throws:
        ExceptionConverter - Exception with a converter error
        java.io.IOException - Exception with a IO error
        org.xml.sax.SAXException - Exception with a SAX error
    • Method Detail

      • replace

        public boolean replace​(java.lang.String parent,
                               java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String value)
        Replaces the content of a tag.
        Parameters:
        parent - the tag name of the parent
        namespaceURI - the URI of the namespace
        localName - the tag name
        value - the new content for the tag
        Returns:
        true if the content was successfully replaced
        Since:
        2.1.6 the return type has changed from void to boolean
      • add

        public boolean add​(java.lang.String parent,
                           java.lang.String namespaceURI,
                           java.lang.String localName,
                           java.lang.String value)
        Adds a tag.
        Parameters:
        namespaceURI - the URI of the namespace
        parent - the tag name of the parent
        localName - the name of the tag to add
        value - the new content for the tag
        Returns:
        true if the content was successfully added
        Since:
        2.1.6
      • setNodeText

        private boolean setNodeText​(org.w3c.dom.Document domDocument,
                                    org.w3c.dom.Node n,
                                    java.lang.String value)
        Sets the text of this node. All the child's node are deleted and a new child text node is created.
        Parameters:
        domDocument - the Document that contains the node
        n - the Node to add the text to
        value - the text to add
      • serializeDoc

        public byte[] serializeDoc()
                            throws java.io.IOException
        Writes the document to a byte array.
        Returns:
        return a serialize document
        Throws:
        java.io.IOException - with a I/O error