Class XMPSchemaRegistryImpl
- java.lang.Object
-
- com.itextpdf.xmp.impl.XMPSchemaRegistryImpl
-
- All Implemented Interfaces:
XMPConst,XMPSchemaRegistry
public final class XMPSchemaRegistryImpl extends java.lang.Object implements XMPSchemaRegistry, XMPConst
The schema registry handles the namespaces, aliases and global options for the XMP Toolkit. There is only one single instance used by the toolkit.- Since:
- 27.01.2006
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.MapaliasMapa map of all registered aliases.private java.util.MapnamespaceToPrefixMapa map from a namespace URI to its registered prefixprivate java.util.regex.PatternpThe pattern that must not be contained in simple propertiesprivate java.util.MapprefixToNamespaceMapa map from a prefix to the associated namespace URI-
Fields inherited from interface com.itextpdf.xmp.XMPConst
ARRAY_ITEM_NAME, ARRAY_LAST_ITEM, FALSESTR, NS_ADOBESTOCKPHOTO, NS_ASF, NS_BWF, NS_CAMERARAW, NS_CREATOR_ATOM, NS_DC, NS_DC_DEPRECATED, NS_DICOM, NS_DM, NS_EXIF, NS_EXIF_AUX, NS_EXIFX, NS_IPTCCORE, NS_IPTCEXT, NS_IX, NS_JP2K, NS_JPEG, NS_PDF, NS_PDFA_EXTENSION, NS_PDFA_FIELD, NS_PDFA_ID, NS_PDFA_PROPERTY, NS_PDFA_SCHEMA, NS_PDFA_TYPE, NS_PDFUA_ID, NS_PDFX, NS_PDFX_ID, NS_PHOTOSHOP, NS_PLUS, NS_PNG, NS_PSALBUM, NS_RDF, NS_RIFFINFO, NS_SCRIPT, NS_SWF, NS_TIFF, NS_TRANSIENT, NS_TXMP, NS_WAV, NS_X, NS_XML, NS_XMP, NS_XMP_BJ, NS_XMP_MM, NS_XMP_NOTE, NS_XMP_RIGHTS, RDF_TYPE, TAG_XAPMETA, TAG_XMPMETA, TRUESTR, TYPE_DIMENSIONS, TYPE_FONT, TYPE_GRAPHICS, TYPE_IDENTIFIERQUAL, TYPE_IMAGE, TYPE_MANIFESTITEM, TYPE_PAGEDFILE, TYPE_RESOURCEEVENT, TYPE_RESOURCEREF, TYPE_ST_JOB, TYPE_ST_VERSION, TYPE_TEXT, X_DEFAULT, XML_LANG, XMP_PI
-
-
Constructor Summary
Constructors Constructor Description XMPSchemaRegistryImpl()Performs the initialisation of the registry with the default namespaces, aliases and global options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteNamespace(java.lang.String namespaceURI)Deletes a namespace from the registry.XMPAliasInfofindAlias(java.lang.String qname)Searches for registered aliases.XMPAliasInfo[]findAliases(java.lang.String aliasNS)Collects all aliases that are contained in the provided namespace.java.util.MapgetAliases()java.lang.StringgetNamespacePrefix(java.lang.String namespaceURI)Obtain the prefix for a registered namespace URI.java.util.MapgetNamespaces()java.lang.StringgetNamespaceURI(java.lang.String namespacePrefix)Obtain the URI for a registered namespace prefix.java.util.MapgetPrefixes()(package private) voidregisterAlias(java.lang.String aliasNS, java.lang.String aliasProp, java.lang.String actualNS, java.lang.String actualProp, AliasOptions aliasForm)Associates an alias name with an actual name.java.lang.StringregisterNamespace(java.lang.String namespaceURI, java.lang.String suggestedPrefix)Register a namespace URI with a suggested prefix.private voidregisterStandardAliases()Register the standard aliases.private voidregisterStandardNamespaces()Register the standard namespaces of schemas and types that are included in the XMP Specification and some other Adobe private namespaces.XMPAliasInforesolveAlias(java.lang.String aliasNS, java.lang.String aliasProp)Determines if a name is an alias, and what it is aliased to.
-
-
-
Field Detail
-
namespaceToPrefixMap
private java.util.Map namespaceToPrefixMap
a map from a namespace URI to its registered prefix
-
prefixToNamespaceMap
private java.util.Map prefixToNamespaceMap
a map from a prefix to the associated namespace URI
-
aliasMap
private java.util.Map aliasMap
a map of all registered aliases. The map is a relationship from a qname to anXMPAliasInfo-object.
-
p
private java.util.regex.Pattern p
The pattern that must not be contained in simple properties
-
-
Method Detail
-
registerNamespace
public java.lang.String registerNamespace(java.lang.String namespaceURI, java.lang.String suggestedPrefix) throws XMPExceptionDescription copied from interface:XMPSchemaRegistryRegister a namespace URI with a suggested prefix. It is not an error if the URI is already registered, no matter what the prefix is. If the URI is not registered but the suggested prefix is in use, a unique prefix is created from the suggested one. The actual registeed prefix is always returned. The function result tells if the registered prefix is the suggested one.Note: No checking is presently done on either the URI or the prefix.
- Specified by:
registerNamespacein interfaceXMPSchemaRegistry- Parameters:
namespaceURI- The URI for the namespace. Must be a valid XML URI.suggestedPrefix- The suggested prefix to be used if the URI is not yet registered. Must be a valid XML name.- Returns:
- Returns the registered prefix for this URI, is equal to the suggestedPrefix if the namespace hasn't been registered before, otherwise the existing prefix.
- Throws:
XMPException- If the parameters are not accordingly set- See Also:
XMPSchemaRegistry.registerNamespace(String, String)
-
deleteNamespace
public void deleteNamespace(java.lang.String namespaceURI)
Description copied from interface:XMPSchemaRegistryDeletes a namespace from the registry.Does nothing if the URI is not registered, or if the namespaceURI parameter is null or the empty string.
Note: Not yet implemented.
- Specified by:
deleteNamespacein interfaceXMPSchemaRegistry- Parameters:
namespaceURI- The URI for the namespace.- See Also:
XMPSchemaRegistry.deleteNamespace(String)
-
getNamespacePrefix
public java.lang.String getNamespacePrefix(java.lang.String namespaceURI)
Description copied from interface:XMPSchemaRegistryObtain the prefix for a registered namespace URI.It is not an error if the namespace URI is not registered.
- Specified by:
getNamespacePrefixin interfaceXMPSchemaRegistry- Parameters:
namespaceURI- The URI for the namespace. Must not be null or the empty string.- Returns:
- Returns the prefix registered for this namespace URI or null.
- See Also:
XMPSchemaRegistry.getNamespacePrefix(String)
-
getNamespaceURI
public java.lang.String getNamespaceURI(java.lang.String namespacePrefix)
Description copied from interface:XMPSchemaRegistryObtain the URI for a registered namespace prefix.It is not an error if the namespace prefix is not registered.
- Specified by:
getNamespaceURIin interfaceXMPSchemaRegistry- Parameters:
namespacePrefix- The prefix for the namespace. Must not be null or the empty string.- Returns:
- Returns the URI registered for this prefix or null.
- See Also:
XMPSchemaRegistry.getNamespaceURI(String)
-
getNamespaces
public java.util.Map getNamespaces()
- Specified by:
getNamespacesin interfaceXMPSchemaRegistry- Returns:
- Returns the registered prefix/namespace-pairs as map, where the keys are the namespaces and the values are the prefixes.
- See Also:
XMPSchemaRegistry.getNamespaces()
-
getPrefixes
public java.util.Map getPrefixes()
- Specified by:
getPrefixesin interfaceXMPSchemaRegistry- Returns:
- Returns the registered namespace/prefix-pairs as map, where the keys are the prefixes and the values are the namespaces.
- See Also:
XMPSchemaRegistry.getPrefixes()
-
registerStandardNamespaces
private void registerStandardNamespaces() throws XMPExceptionRegister the standard namespaces of schemas and types that are included in the XMP Specification and some other Adobe private namespaces. Note: This method is not lock because only called by the constructor.- Throws:
XMPException- Forwards processing exceptions
-
resolveAlias
public XMPAliasInfo resolveAlias(java.lang.String aliasNS, java.lang.String aliasProp)
Description copied from interface:XMPSchemaRegistryDetermines if a name is an alias, and what it is aliased to.- Specified by:
resolveAliasin interfaceXMPSchemaRegistry- Parameters:
aliasNS- The namespace URI of the alias. Must not benullor the empty string.aliasProp- The name of the alias. May be an arbitrary path expression path, must not benullor the empty string.- Returns:
- Returns the
XMPAliasInfofor the given alias namespace and property ornullif there is no such alias. - See Also:
XMPSchemaRegistry.resolveAlias(String, String)
-
findAlias
public XMPAliasInfo findAlias(java.lang.String qname)
Description copied from interface:XMPSchemaRegistrySearches for registered aliases.- Specified by:
findAliasin interfaceXMPSchemaRegistry- Parameters:
qname- an XML conform qname- Returns:
- Returns if an alias definition for the given qname to another schema and property is registered.
- See Also:
XMPSchemaRegistry.findAlias(java.lang.String)
-
findAliases
public XMPAliasInfo[] findAliases(java.lang.String aliasNS)
Description copied from interface:XMPSchemaRegistryCollects all aliases that are contained in the provided namespace. If nothing is found, an empty array is returned.- Specified by:
findAliasesin interfaceXMPSchemaRegistry- Parameters:
aliasNS- a schema namespace URI- Returns:
- Returns all alias infos from aliases that are contained in the provided namespace.
- See Also:
XMPSchemaRegistry.findAliases(String)
-
registerAlias
void registerAlias(java.lang.String aliasNS, java.lang.String aliasProp, java.lang.String actualNS, java.lang.String actualProp, AliasOptions aliasForm) throws XMPExceptionAssociates an alias name with an actual name.Define a alias mapping from one namespace/property to another. Both property names must be simple names. An alias can be a direct mapping, where the alias and actual have the same data type. It is also possible to map a simple alias to an item in an array. This can either be to the first item in the array, or to the 'x-default' item in an alt-text array. Multiple alias names may map to the same actual, as long as the forms match. It is a no-op to reregister an alias in an identical fashion. Note: This method is not locking because only called by registerStandardAliases which is only called by the constructor. Note2: The method is only package-private so that it can be tested with unittests
- Parameters:
aliasNS- The namespace URI for the alias. Must not be null or the empty string.aliasProp- The name of the alias. Must be a simple name, not null or the empty string and not a general path expression.actualNS- The namespace URI for the actual. Must not be null or the empty string.actualProp- The name of the actual. Must be a simple name, not null or the empty string and not a general path expression.aliasForm- Provides options for aliases for simple aliases to array items. This is needed to know what kind of array to create if set for the first time via the simple alias. PassXMP_NoOptions, the default value, for all direct aliases regardless of whether the actual data type is an array or not (seeAliasOptions).- Throws:
XMPException- for inconsistant aliases.
-
getAliases
public java.util.Map getAliases()
- Specified by:
getAliasesin interfaceXMPSchemaRegistry- Returns:
- Returns the registered aliases as map, where the key is the "qname" (prefix and name)
and the value an
XMPAliasInfo-object. - See Also:
XMPSchemaRegistry.getAliases()
-
registerStandardAliases
private void registerStandardAliases() throws XMPExceptionRegister the standard aliases. Note: This method is not lock because only called by the constructor.- Throws:
XMPException- If the registrations of at least one alias fails.
-
-