Top Fields Constructors Methods
org.apache.xmpbox.xml

public Class XmpSerializer

extends Object
Class Inheritance
Imports
java.io.OutputStream, java.util.ArrayList, .List, javax.xml.XMLConstants, javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, .ParserConfigurationException, javax.xml.transform.OutputKeys, .Result, .Transformer, .TransformerException, .TransformerFactory, javax.xml.transform.dom.DOMSource, javax.xml.transform.stream.StreamResult, org.apache.xmpbox.XMPMetadata, .XmpConstants, org.apache.xmpbox.schema.XMPSchema, org.apache.xmpbox.type.AbstractComplexProperty, .AbstractField, .AbstractSimpleProperty, .AbstractStructuredType, .ArrayProperty, .Attribute, org.w3c.dom.Document, .Element, .Node, .ProcessingInstruction

Field Summary

Modifier and TypeField and Description
private final DocumentBuilder
private final TransformerFactory

Constructor Summary

AccessConstructor and Description
public
XmpSerializer()

Default constructor.

public
XmpSerializer(TransformerFactory
transformer factory to be used
transformerFactory
,
DocumentBuilderFactory
document builder factory to be used
documentBuilderFactory
)

Constructor to be used if other factories than the default ones are needed.

Method Summary

Modifier and TypeMethod and Description
protected Element
createRdfElement(Document doc, XMPMetadata metadata, boolean withXpacket)

private void
private List<Attribute>

Returns:

the list of attributed for serializing
normalizeAttributes
(AbstractComplexProperty
the property that needs to be inspected
property
)

Normalize the list of attributes.

private void
save(Node
The XML document to save.
doc
,
OutputStream
The stream to save the document to.
outStream
,
String
The encoding to save the file as.
encoding
)

Save the XML document to an output stream.

public void
serialize(XMPMetadata metadata, OutputStream os, boolean withXpacket)

public void
serializeFields(Document doc, Element parent, List<AbstractField> fields, String resourceNS, String prefix, boolean wrapWithProperty)

protected Element
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

documentBuilderback to summary
private final DocumentBuilder documentBuilder
transformerFactoryback to summary
private final TransformerFactory transformerFactory

Constructor Detail

XmpSerializerback to summary
public XmpSerializer()

Default constructor.

Annotations
@SuppressWarnings:squid:S2755
XmpSerializerback to summary
public XmpSerializer(TransformerFactory transformerFactory, DocumentBuilderFactory documentBuilderFactory)

Constructor to be used if other factories than the default ones are needed.

Parameters
transformerFactory:TransformerFactory

transformer factory to be used

documentBuilderFactory:DocumentBuilderFactory

document builder factory to be used

Method Detail

createRdfElementback to summary
protected Element createRdfElement(Document doc, XMPMetadata metadata, boolean withXpacket)
fillElementWithAttributesback to summary
private void fillElementWithAttributes(Element target, AbstractComplexProperty property)
normalizeAttributesback to summary
private 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:AbstractComplexProperty

the property that needs to be inspected

Returns:List<Attribute>

the list of attributed for serializing

saveback to summary
private void save(Node doc, OutputStream outStream, String encoding) throws TransformerException

Save the XML document to an output stream.

Parameters
doc:Node

The XML document to save.

outStream:OutputStream

The stream to save the document to.

encoding:String

The encoding to save the file as.

Exceptions
TransformerException:
If there is an error while saving the XML.
serializeback to summary
public void serialize(XMPMetadata metadata, OutputStream os, boolean withXpacket) throws TransformerException
serializeFieldsback to summary
public void serializeFields(Document doc, Element parent, List<AbstractField> fields, String resourceNS, String prefix, boolean wrapWithProperty)
serializeSchemaback to summary
protected Element serializeSchema(Document doc, XMPSchema schema)