01: /*
02: * SchemaHolderImpl.java
03: *
04: * Created on October 9, 2006, 5:13 PM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.netbeans.modules.e2e.schema;
11:
12: import java.util.Collections;
13: import java.util.HashMap;
14: import java.util.HashSet;
15: import java.util.Map;
16: import java.util.Set;
17: import javax.xml.namespace.QName;
18: import org.netbeans.modules.e2e.api.schema.Element;
19: import org.netbeans.modules.e2e.api.schema.SchemaConstruct;
20: import org.netbeans.modules.e2e.api.schema.SchemaHolder;
21: import org.netbeans.modules.e2e.api.schema.Type;
22:
23: /**
24: *
25: * @author Michal Skvor
26: */
27: public class SchemaHolderImpl implements SchemaHolder {
28:
29: private Map<QName, Element> elements;
30: private Map<QName, Type> types;
31:
32: private Map<QName, SchemaConstruct> schemaConstructs;
33:
34: public SchemaHolderImpl() {
35: elements = new HashMap();
36: types = new HashMap();
37: }
38:
39: public void addSchemaType(Type type) {
40: types.put(type.getName(), type);
41: }
42:
43: public Type getSchemaType(QName name) {
44: return types.get(name);
45: }
46:
47: public Set<Type> getSchemaTypes() {
48: return new HashSet(types.values());
49: }
50:
51: public void addSchemaElement(Element element) {
52: elements.put(element.getName(), element);
53: }
54:
55: public Element getSchemaElement(QName name) {
56: return elements.get(name);
57: }
58:
59: public Set<Element> getSchemaElements() {
60: return new HashSet(elements.values());
61: }
62:
63: public void importSchema(SchemaHolder schemaHolder) {
64: for (Element element : schemaHolder.getSchemaElements()) {
65: addSchemaElement(element);
66: }
67:
68: for (Type type : schemaHolder.getSchemaTypes()) {
69: addSchemaType(type);
70: }
71: }
72:
73: }
|