Package com.aowagie.text.xml.xmp
Class XmpReader
- java.lang.Object
-
- com.aowagie.text.xml.xmp.XmpReader
-
public class XmpReader extends java.lang.ObjectReads an XMP stream into an org.w3c.dom.Document objects. Allows you to replace the contents of a specific tag.- Since:
- 2.1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classXmpReader.SafeEmptyEntityResolver
-
Field Summary
Fields Modifier and Type Field Description private org.w3c.dom.DocumentdomDocumentprivate static java.util.logging.LoggerLOGGERprivate static javax.xml.parsers.DocumentBuilderFactorySECURE_FACTORY
-
Constructor Summary
Constructors Constructor Description XmpReader(byte[] bytes)Constructs an XMP reader
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.String parent, java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)Adds a tag.private static javax.xml.parsers.DocumentBuilderFactorygetSecureDocumentFactory()booleanreplace(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 booleansetNodeText(org.w3c.dom.Document domDocument, org.w3c.dom.Node n, java.lang.String value)Sets the text of this node.
-
-
-
Constructor Detail
-
XmpReader
public XmpReader(byte[] bytes) throws org.xml.sax.SAXException, java.io.IOExceptionConstructs an XMP reader- Parameters:
bytes- the XMP content- Throws:
java.io.IOException- Exception with information about a IO errororg.xml.sax.SAXException- Exception with information about a SAX error
-
-
Method Detail
-
getSecureDocumentFactory
private static javax.xml.parsers.DocumentBuilderFactory getSecureDocumentFactory()
-
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 parentnamespaceURI- the URI of the namespacelocalName- the tag namevalue- 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 namespaceparent- the tag name of the parentlocalName- the name of the tag to addvalue- 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- theDocumentthat contains the noden- theNodeto add the text tovalue- the text to add
-
serializeDoc
public byte[] serializeDoc() throws java.io.IOExceptionWrites the document to a byte array.- Returns:
- array with bytes of a doc
- Throws:
java.io.IOException- Exception about a IO error
-
-