01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id: XMPSchemaRegistry.java 426584 2006-07-28 16:01:47Z jeremias $ */
19:
20: package org.apache.xmlgraphics.xmp;
21:
22: import java.util.Map;
23:
24: import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
25: import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
26: import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema;
27: import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAOldXMPSchema;
28: import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAXMPSchema;
29:
30: /**
31: * This class is a registry of XMP schemas. It's implemented as a singleton.
32: */
33: public class XMPSchemaRegistry {
34:
35: private static XMPSchemaRegistry instance = null;
36:
37: private Map schemas = new java.util.HashMap();
38:
39: private XMPSchemaRegistry() {
40: init();
41: }
42:
43: /** @return the singleton instance of the XMP schema registry. */
44: public static XMPSchemaRegistry getInstance() {
45: if (instance == null) {
46: instance = new XMPSchemaRegistry();
47: }
48: return instance;
49: }
50:
51: private void init() {
52: addSchema(new DublinCoreSchema());
53: addSchema(new PDFAXMPSchema());
54: addSchema(new PDFAOldXMPSchema());
55: addSchema(new XMPBasicSchema());
56: addSchema(new AdobePDFSchema());
57: }
58:
59: /**
60: * Adds an XMP schema to the registry.
61: * @param schema the XMP schema
62: */
63: public void addSchema(XMPSchema schema) {
64: schemas.put(schema.getNamespace(), schema);
65: }
66:
67: /**
68: * Returns the XMP schema object for a given namespace.
69: * @param namespace the namespace URI
70: * @return the XMP schema or null if none is available
71: */
72: public XMPSchema getSchema(String namespace) {
73: return (XMPSchema) schemas.get(namespace);
74: }
75:
76: }
|