public abstract class XMLCatalogImpl extends CatalogImpl implements XMLCatalog
For a definition of the terms expanded name, qualified name or QName, namespace prefix, local part and local name, please see http://www.w3.org/TR/REC-xml-names
By default the following namespace prefixes are bound:
<root xmlns:x="http://x.demo.org" xmlns:y="http://x.demo.org"> <x:elem>value</x:elem> <y:elem>value</y:elem> </root>However, reading of those documents is supported.
| Modifier and Type | Class and Description |
|---|---|
class |
XMLCatalogImpl.CatalogEntry
Element representation.
|
CatalogImpl.AdapterMediaPackageElement.Type| Modifier and Type | Field and Description |
|---|---|
protected XmlNamespaceContext |
bindings
Namespace - prefix bindings
|
protected Map<EName,List<XMLCatalogImpl.CatalogEntry>> |
data
Key (QName) value meta data
|
protected boolean |
includeEmpty
To marshaling empty fields to remove existing values during merge, default is not to marshal empty elements
|
static EName |
XML_LANG_ATTR
Expanded name of the XML language attribute
xml:lang. |
static String |
XSI_NS_PREFIX
Namespace prefix for XML schema instance.
|
static EName |
XSI_TYPE_ATTR
Expanded name of the XSI type attribute.
|
checksum, description, elementType, flavor, id, mediaPackage, mimeType, reference, size, tags, uri| Modifier | Constructor and Description |
|---|---|
protected |
XMLCatalogImpl()
Create an empty catalog and register the
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
namespace. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addBinding(XmlNamespaceBinding binding) |
protected void |
addElement(EName element,
String value)
Adds the element to the metadata collection.
|
protected void |
addElement(EName element,
String value,
Attributes attributes)
Adds an element with attributes to the catalog.
|
protected void |
addLocalizedElement(EName element,
String value,
String language)
Adds the element with the
xml:lang attribute to the metadata collection. |
protected void |
addTypedElement(EName element,
String value,
EName type)
Adds the element with the
xsi:type attribute to the metadata collection. |
protected void |
addTypedLocalizedElement(EName element,
String value,
String language,
EName type)
Adds an element with the
xml:lang and xsi:type attributes to the metadata collection. |
protected void |
clear()
Clears the catalog.
|
protected boolean |
equal(Object a,
Object b)
Tests two objects for equality.
|
protected XmlNamespaceContext |
getBindings() |
protected List<XMLCatalogImpl.CatalogEntry> |
getEntriesSorted() |
protected XMLCatalogImpl.CatalogEntry |
getFirstLocalizedValue(EName element,
String language)
Returns the first value that is associated with the specified name and language.
|
protected XMLCatalogImpl.CatalogEntry |
getFirstTypedValue(EName element,
String type)
Returns the first value that is associated with the specified name and language.
|
protected XMLCatalogImpl.CatalogEntry |
getFirstValue(EName element)
Returns the first value that is associated with the specified name.
|
protected XMLCatalogImpl.CatalogEntry |
getFirstValue(EName element,
EName attributeEName,
String attributeValue)
Returns the first element that is associated with the specified name and attribute.
|
protected List<XMLCatalogImpl.CatalogEntry> |
getLocalizedValuesAsList(EName element,
String language)
Returns the values that are associated with the specified key.
|
protected String |
getPrefix(String namespaceURI)
Get a prefix from
bindings but throw a NamespaceBindingException if none found. |
protected XMLCatalogImpl.CatalogEntry[] |
getValues(EName element)
Returns the values that are associated with the specified key.
|
protected List<XMLCatalogImpl.CatalogEntry> |
getValuesAsList(EName element)
Returns the values that are associated with the specified key.
|
void |
includeEmpty(boolean includeEmpty)
Marshal elements with empty values to support
remove existing values during catalog merge.
|
protected Document |
newDocument()
Creates an xml document root and returns it.
|
protected void |
removeElement(EName element)
Completely removes an element.
|
protected void |
removeLocalizedValues(EName element,
String language)
Removes all entries in a certain language from an element.
|
protected void |
saveToXml(Node document,
String docType,
OutputStream out)
Serializes the given xml document to the associated file.
|
protected EName |
toEName(String qName)
Transform a qualified name to an expanded name, based on the registered binding.
|
protected EName |
toEName(String prefix,
String localName)
Transform an qualified name consisting of prefix and local part to an expanded name, based on the registered
binding.
|
Node |
toManifest(Document document,
MediaPackageSerializer serializer)
This method returns an XML serialization of the object to be stored in the media package manifest.
|
protected String |
toQName(EName eName)
Transform an expanded name to a qualified name based on the registered binding.
|
void |
toXml(OutputStream out,
boolean format)
Writes an xml representation of this Catalog to a stream.
|
String |
toXmlString()
Writes an xml representation of this Catalog to a string.
|
fromFile, fromURI, newInstanceaddTag, clearReference, clearTags, clone, compareTo, containsTag, containsTag, equals, getChecksum, getElementDescription, getElementType, getFlavor, getIdentifier, getMediaPackage, getMimeType, getReference, getSize, getTags, getURI, hashCode, referTo, referTo, referTo, removeTag, setChecksum, setElementDescription, setFlavor, setIdentifier, setMimeType, setReference, setSize, setURI, toString, verifyfinalize, getClass, notify, notifyAll, wait, wait, waittoJson, toXmladdTag, clearReference, clearTags, clone, containsTag, containsTag, getChecksum, getElementDescription, getElementType, getFlavor, getIdentifier, getMediaPackage, getMimeType, getReference, getSize, getTags, getURI, referTo, referTo, referTo, removeTag, setChecksum, setElementDescription, setFlavor, setIdentifier, setMimeType, setReference, setSize, setURI, verifycompareTopublic static final EName XML_LANG_ATTR
xml:lang.public static final String XSI_NS_PREFIX
protected boolean includeEmpty
public static final EName XSI_TYPE_ATTR
See http://www.w3.org/TR/xmlschema-1/#xsi_type for the definition.
protected final Map<EName,List<XMLCatalogImpl.CatalogEntry>> data
protected XmlNamespaceContext bindings
protected XMLCatalogImpl()
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
namespace.protected void addBinding(XmlNamespaceBinding binding)
protected XmlNamespaceContext getBindings()
protected void clear()
protected void addElement(EName element, String value)
element - the expanded name of the elementvalue - the valueprotected void addLocalizedElement(EName element, String value, String language)
xml:lang attribute to the metadata collection.element - the expanded name of the elementvalue - the valuelanguage - the language identifier (two letter ISO 639)protected void addTypedElement(EName element, String value, EName type)
xsi:type attribute to the metadata collection.value - the valuetype - the element typeprotected void addTypedLocalizedElement(EName element, String value, String language, EName type)
xml:lang and xsi:type attributes to the metadata collection.element - the expanded name of the elementvalue - the valuelanguage - the language identifier (two letter ISO 639)type - the element typeprotected void addElement(EName element, String value, Attributes attributes)
element - the expanded name of the elementvalue - the element's valueattributes - the attributes. May be nullprotected void removeElement(EName element)
element - the expanded name of the elementprotected void removeLocalizedValues(EName element, String language)
element - the expanded name of the elementlanguage - the language code (two letter ISO 639) or null to only remove entries without an
xml:lang attributeprotected XMLCatalogImpl.CatalogEntry[] getValues(EName element)
element - the expanded name of the elementprotected List<XMLCatalogImpl.CatalogEntry> getEntriesSorted()
protected List<XMLCatalogImpl.CatalogEntry> getValuesAsList(EName element)
element - the expanded name of the elementprotected List<XMLCatalogImpl.CatalogEntry> getLocalizedValuesAsList(EName element, String language)
element - the expandend name of the elementlanguage - a language code or null to get values without xml:lang attributeprotected XMLCatalogImpl.CatalogEntry getFirstValue(EName element)
element - the expanded name of the elementprotected XMLCatalogImpl.CatalogEntry getFirstValue(EName element, EName attributeEName, String attributeValue)
element - the expanded name of the elementattributeEName - the expanded attribute nameattributeValue - the attribute valueprotected XMLCatalogImpl.CatalogEntry getFirstLocalizedValue(EName element, String language)
element - the expanded name of the elementlanguage - the language identifier or null to get only elements without xml:lang attributeprotected XMLCatalogImpl.CatalogEntry getFirstTypedValue(EName element, String type)
element - the expanded name of the elementtype - the xsi:type valueprotected Document newDocument() throws ParserConfigurationException
ParserConfigurationException - If the xml parser environment is not correctly configuredprotected void saveToXml(Node document, String docType, OutputStream out) throws TransformerException, IOException
document - the documentdocType - the document type definition (dtd)TransformerException - if serialization failsIOExceptionpublic Node toManifest(Document document, MediaPackageSerializer serializer) throws MediaPackageException
ManifestContributor
For creating MediaPackageElements from a manifest, please use
MediaPackageElementBuilder.elementFromManifest(org.w3c.dom.Node, MediaPackageSerializer). All other objects
shall provide their own implementation specific reconstruction mechanism.
toManifest in interface ManifestContributortoManifest in class AbstractMediaPackageElementdocument - the parentserializer - the media package serializerMediaPackageException - if the mediapackage can't be serializedAbstractMediaPackageElement.toManifest(org.w3c.dom.Document,
org.opencastproject.mediapackage.MediaPackageSerializer)protected String getPrefix(String namespaceURI)
bindings but throw a NamespaceBindingException if none found.public void includeEmpty(boolean includeEmpty)
XMLCatalogincludeEmpty in interface XMLCatalogXMLCatalog.includeEmpty(boolean)protected String toQName(EName eName)
eName - the expanded name to transformdcterms:titleNamespaceBindingException - if the namespace name is not bound to a prefixprotected EName toEName(String prefix, String localName)
prefix - the prefixlocalName - the local partNamespaceBindingException - if the namespace name is not bound to a prefixprotected EName toEName(String qName)
qName - the qualified name, e.g. dcterms:title or titleNamespaceBindingException - if the namespace name is not bound to a prefixpublic void toXml(OutputStream out, boolean format) throws IOException
toXml in interface XMLCatalogout - The output streamformat - Whether to format the output for readability, or not (false gives better performance)IOExceptionXMLCatalog.toXml(java.io.OutputStream, boolean)public String toXmlString() throws IOException
toXmlString in interface XMLCatalogIOExceptionXMLCatalog.toXmlString()Copyright © 2009–2020 Opencast Project. All rights reserved.