comparison WebServiceToolWorkflow/lib/SAWADLParser/src/edu/uga/cs/lsdis/meteors/wadls/extensions/schema/SchemaImpl.java @ 0:d5cd409b8a18 default tip

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author ganjoo
date Tue, 07 Jun 2011 18:00:50 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d5cd409b8a18
1 /*
2 * (c) Copyright IBM Corp 2004, 2005
3 */
4
5 package edu.uga.cs.lsdis.meteors.wadls.extensions.schema;
6
7 import java.util.HashMap;
8 import java.util.List;
9 import java.util.Map;
10 import java.util.Vector;
11
12 import javax.wadls.extensions.schema.Schema;
13 import javax.wadls.extensions.schema.SchemaImport;
14 import javax.wadls.extensions.schema.SchemaReference;
15 import javax.xml.namespace.QName;
16
17 import org.w3c.dom.Element;
18
19 /**
20 * This class is used to wrap schema elements. It holds the DOM Element to the
21 * <code>&lt;schema&gt;</code> element.
22 *
23 * @see SchemaSerializer
24 * @see SchemaDeserializer
25 *
26 * @author Jeremy Hughes <hughesj@uk.ibm.com>
27 */
28 public class SchemaImpl implements Schema
29 {
30 protected QName elementType = null;
31 // Uses the wrapper type so we can tell if it was set or not.
32 protected Boolean required = null;
33 protected Element element = null;
34
35 public static final long serialVersionUID = 1;
36
37 /*
38 * imports is a Map of Lists with key of the import's namespace URI. Each List
39 * contains the SchemaImport objects for that namespace. There can be more
40 * than one SchemaImport in a List - one for each schemaLocation attribute
41 * setting.
42 */
43 private Map imports = new HashMap();
44
45 /*
46 * includes is a List of Include objects for the targetNamespace of the
47 * enclosing schema. There is one Include in the List for each <include>
48 * element in the XML Schema.
49 */
50 private List includes = new Vector();
51
52 /*
53 * redefines is a list of Redefine obejcts for the targetNamespace of the
54 * enclosing schema. There is one Redefine in the List for each <redefine>
55 * element in the XML Schema.
56 */
57 private List redefines = new Vector();
58
59 private String documentBaseURI = null;
60
61 /**
62 * Get a map of lists containing all the imports defined here. The map's keys
63 * are Strings representing the namespace URIs, and the map's values are
64 * lists. There is one list for each namespace URI for which imports have been
65 * defined.
66 *
67 * @return a Map of Lists of Import instances keyed off the import's namespace
68 */
69 public Map getImports()
70 {
71 return this.imports;
72 }
73
74 /**
75 * Create a new schema import.
76 *
77 * @return the newly created schema import
78 */
79 public SchemaImport createImport()
80 {
81 return new SchemaImportImpl();
82 }
83
84 /**
85 * Add an import to this LightWeightSchema
86 *
87 * @param importSchema the import to be added
88 */
89 public void addImport(SchemaImport importSchema)
90 {
91 String namespaceURI = importSchema.getNamespaceURI();
92 List importList = (List) this.imports.get(namespaceURI);
93
94 if (importList == null)
95 {
96 importList = new Vector();
97
98 this.imports.put(namespaceURI, importList);
99 }
100
101 importList.add(importSchema);
102 }
103
104 /**
105 * Get list of includes defined here.
106 *
107 * @return a List of SchemaReference instances representing the schema
108 * includes.
109 */
110
111 public List getIncludes()
112 {
113 return this.includes;
114 }
115
116 public SchemaReference createInclude()
117 {
118 return new SchemaReferenceImpl();
119 }
120
121 public void addInclude(SchemaReference includeSchema)
122 {
123 this.includes.add(includeSchema);
124 }
125
126 public List getRedefines()
127 {
128 return this.redefines;
129 }
130
131 public SchemaReference createRedefine()
132 {
133 return new SchemaReferenceImpl();
134 }
135
136 public void addRedefine(SchemaReference redefineSchema)
137 {
138 this.redefines.add(redefineSchema);
139 }
140
141 public String toString()
142 {
143 StringBuffer strBuf = new StringBuffer();
144
145 strBuf.append("SchemaExtensibilityElement (" + this.elementType + "):");
146 strBuf.append("\nrequired=" + this.required);
147
148 if (this.element != null)
149 {
150 strBuf.append("\nelement=" + this.element);
151 }
152
153 return strBuf.toString();
154 }
155
156 /**
157 * Set the type of this extensibility element.
158 *
159 * @param elementType the type
160 */
161 public void setElementType(QName elementType)
162 {
163 this.elementType = elementType;
164 }
165
166 /**
167 * Get the type of this extensibility element.
168 *
169 * @return the extensibility element's type
170 */
171 public QName getElementType()
172 {
173 return elementType;
174 }
175
176 /**
177 * Set whether or not the semantics of this extension
178 * are required. Relates to the wsdl:required attribute.
179 */
180 public void setRequired(Boolean required)
181 {
182 this.required = required;
183 }
184
185 /**
186 * Get whether or not the semantics of this extension
187 * are required. Relates to the wsdl:required attribute.
188 */
189 public Boolean getRequired()
190 {
191 return required;
192 }
193
194 /**
195 * Set the DOM Element that represents this schema element.
196 *
197 * @param element the DOM element representing this schema
198 */
199 public void setElement(Element element)
200 {
201 this.element = element;
202 }
203
204 /**
205 * Get the DOM Element that represents this schema element.
206 *
207 * @return the DOM element representing this schema
208 */
209 public Element getElement()
210 {
211 return element;
212 }
213
214 /**
215 * Set the document base URI of this schema definition. Can be used to
216 * represent the origin of the schema, and can be exploited when resolving
217 * relative URIs (e.g. in &lt;import&gt;s).
218 *
219 * @param documentBaseURI the document base URI of this schema
220 */
221 public void setDocumentBaseURI(String documentBaseURI)
222 {
223 this.documentBaseURI = documentBaseURI;
224 }
225
226 /**
227 * Get the document base URI of this schema
228 *
229 * @return the document base URI
230 */
231 public String getDocumentBaseURI()
232 {
233 return this.documentBaseURI;
234 }
235 }