Debian Codegraph @

src/com/adobe/internal/xmp/XMPSchemaRegistry.java

raw symbols SCIP
1 // =================================================================================================
2 // ADOBE SYSTEMS INCORPORATED
3 // Copyright 2006 Adobe Systems Incorporated
4 // All Rights Reserved
5 //
6 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
7 // of the Adobe license agreement accompanying it.
8 // =================================================================================================
9
10 package com.adobe.internal.xmp;
11
12 import java.util.Map;
13
14 import com.adobe.internal.xmp.properties.XMPAliasInfo;
15
16 /**
17 * The schema registry keeps track of all namespaces and aliases used in the XMP
18 * metadata. At initialisation time, the default namespaces and default aliases
19 * are automatically registered. <b>Namespaces</b> must be registered before
20 * used in namespace URI parameters or path expressions. Within the XMP Toolkit
21 * the registered namespace URIs and prefixes must be unique. Additional
22 * namespaces encountered when parsing RDF are automatically registered. The
23 * namespace URI should always end in an XML name separator such as '/' or '#'.
24 * This is because some forms of RDF shorthand catenate a namespace URI with an
25 * element name to form a new URI.
26 * <p>
27 * <b>Aliases</b> in XMP serve the same purpose as Windows file shortcuts,
28 * Macintosh file aliases, or UNIX file symbolic links. The aliases are simply
29 * multiple names for the same property. One distinction of XMP aliases is that
30 * they are ordered, there is an alias name pointing to an actual name. The
31 * primary significance of the actual name is that it is the preferred name for
32 * output, generally the most widely recognized name.
33 * <p>
34 * The names that can be aliased in XMP are restricted. The alias must be a top
35 * level property name, not a field within a structure or an element within an
36 * array. The actual may be a top level property name, the first element within
37 * a top level array, or the default element in an alt-text array. This does not
38 * mean the alias can only be a simple property. It is OK to alias a top level
39 * structure or array to an identical top level structure or array, or to the
40 * first item of an array of structures.
41 *
42 * @author Stefan Makswit
43 * @version $Revision$
44 * @since 27.01.2006
45 */
46 public interface XMPSchemaRegistry
47 {
48 // ---------------------------------------------------------------------------------------------
49 // Namespace Functions
50
51 /**
52 * Register a namespace URI with a suggested prefix. It is not an error if
53 * the URI is already registered, no matter what the prefix is. If the URI
54 * is not registered but the suggested prefix is in use, a unique prefix is
55 * created from the suggested one. The actual registeed prefix is always
56 * returned. The function result tells if the registered prefix is the
57 * suggested one.
58 * <p>
59 * Note: No checking is presently done on either the URI or the prefix.
60 *
61 * @param namespaceURI
62 * The URI for the namespace. Must be a valid XML URI.
63 * @param suggestedPrefix
64 * The suggested prefix to be used if the URI is not yet
65 * registered. Must be a valid XML name.
66 * @return Returns the registered prefix for this URI, is equal to the
67 * suggestedPrefix if the namespace hasn't been registered before,
68 * otherwise the existing prefix.
69 * @throws XMPException If the parameters are not accordingly set
70 */
71 String registerNamespace(String namespaceURI, String suggestedPrefix) throws XMPException;
72
73
74 /**
75 * Obtain the prefix for a registered namespace URI.
76 * <p>
77 * It is not an error if the namespace URI is not registered.
78 *
79 * @param namespaceURI
80 * The URI for the namespace. Must not be null or the empty
81 * string.
82 * @return Returns the prefix registered for this namespace URI or null.
83 */
84 String getNamespacePrefix(String namespaceURI);
85
86
87 /**
88 * Obtain the URI for a registered namespace prefix.
89 * <p>
90 * It is not an error if the namespace prefix is not registered.
91 *
92 * @param namespacePrefix
93 * The prefix for the namespace. Must not be null or the empty
94 * string.
95 * @return Returns the URI registered for this prefix or null.
96 */
97 String getNamespaceURI(String namespacePrefix);
98
99
100 /**
101 * @return Returns the registered prefix/namespace-pairs as map, where the keys are the
102 * namespaces and the values are the prefixes.
103 */
104 Map getNamespaces();
105
106
107 /**
108 * @return Returns the registered namespace/prefix-pairs as map, where the keys are the
109 * prefixes and the values are the namespaces.
110 */
111 Map getPrefixes();
112
113
114 /**
115 * Deletes a namespace from the registry.
116 * <p>
117 * Does nothing if the URI is not registered, or if the namespaceURI
118 * parameter is null or the empty string.
119 * <p>
120 * Note: Not yet implemented.
121 *
122 * @param namespaceURI
123 * The URI for the namespace.
124 */
125 void deleteNamespace(String namespaceURI);
126
127
128
129
130
131 // ---------------------------------------------------------------------------------------------
132 // Alias Functions
133
134
135 /**
136 * Determines if a name is an alias, and what it is aliased to.
137 *
138 * @param aliasNS
139 * The namespace URI of the alias. Must not be <code>null</code> or the empty
140 * string.
141 * @param aliasProp
142 * The name of the alias. May be an arbitrary path expression
143 * path, must not be <code>null</code> or the empty string.
144 * @return Returns the <code>XMPAliasInfo</code> for the given alias namespace and property or
145 * <code>null</code> if there is no such alias.
146 */
147 XMPAliasInfo resolveAlias(String aliasNS, String aliasProp);
148
149
150 /**
151 * Collects all aliases that are contained in the provided namespace.
152 * If nothing is found, an empty array is returned.
153 *
154 * @param aliasNS a schema namespace URI
155 * @return Returns all alias infos from aliases that are contained in the provided namespace.
156 */
157 XMPAliasInfo[] findAliases(String aliasNS);
158
159
160 /**
161 * Searches for registered aliases.
162 *
163 * @param qname
164 * an XML conform qname
165 * @return Returns if an alias definition for the given qname to another
166 * schema and property is registered.
167 */
168 XMPAliasInfo findAlias(String qname);
169
170
171 /**
172 * @return Returns the registered aliases as map, where the key is the "qname" (prefix and name)
173 * and the value an <code>XMPAliasInfo</code>-object.
174 */
175 Map getAliases();
176
177
178 }