001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.xml;
017:
018: import java.io.BufferedReader;
019: import java.io.IOException;
020: import java.io.InputStream;
021: import java.io.InputStreamReader;
022: import java.lang.reflect.InvocationTargetException;
023: import java.net.URI;
024: import java.net.URL;
025: import java.util.Collections;
026: import java.util.Enumeration;
027: import java.util.HashMap;
028: import java.util.HashSet;
029: import java.util.Iterator;
030: import java.util.LinkedList;
031: import java.util.List;
032: import java.util.Map;
033: import java.util.Set;
034: import java.util.logging.Level;
035:
036: import javax.xml.parsers.ParserConfigurationException;
037: import javax.xml.parsers.SAXParser;
038: import javax.xml.parsers.SAXParserFactory;
039:
040: import org.geotools.factory.FactoryRegistry;
041: import org.geotools.referencing.ReferencingFactoryFinder;
042: import org.geotools.xml.schema.Attribute;
043: import org.geotools.xml.schema.AttributeGroup;
044: import org.geotools.xml.schema.ComplexType;
045: import org.geotools.xml.schema.Element;
046: import org.geotools.xml.schema.Group;
047: import org.geotools.xml.schema.Schema;
048: import org.geotools.xml.schema.SimpleType;
049: import org.xml.sax.SAXException;
050:
051: /**
052: * SchemaFactory purpose.
053: *
054: * <p>
055: * This is the main entry point into the XSI parsing routines.
056: * </p>
057: *
058: * <p>
059: * Example Use:
060: * <pre><code>
061: *
062: *
063: *
064: * Schema x = SchemaFactory.getInstance("MyTargetNameSpace",new URI("MyNameSpaceURI");
065: *
066: *
067: *
068: * </code></pre>
069: * </p>
070: *
071: * @author dzwiers, Refractions Research, Inc. http://www.refractions.net
072: * @author $Author:$ (last modification)
073: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/xml/src/main/java/org/geotools/xml/SchemaFactory.java $
074: * @version $Id: SchemaFactory.java 26549 2007-08-14 18:00:35Z aaime $
075: */
076: public class SchemaFactory {
077: protected static SchemaFactory is = new SchemaFactory();
078:
079: /*
080: * Holds onto instances when they are created ... my version of object
081: * pooling Q: is there a better way? might suck up too much memory ... A:
082: * not really, but the JVM might be better ... use the class to make
083: * instances
084: */
085: private Map schemas = loadSchemas();
086:
087: /*
088: * The SAX parser to use if one is required ... isn't loaded until first
089: * use.
090: */
091: private SAXParser parser;
092:
093: protected static SchemaFactory getInstance() {
094: return is;
095: }
096:
097: /*
098: */
099: private Map loadSchemas() {
100: schemas = new HashMap();
101:
102: ClassLoader[] cls = findLoaders();
103: String serviceId = "META-INF/services/"
104: + Schema.class.getName();
105:
106: for (int i = 0; i < cls.length; i++) {
107: try {
108: Enumeration e = cls[i].getResources(serviceId);
109:
110: while (e.hasMoreElements()) {
111: URL res = (URL) e.nextElement();
112: BufferedReader rd = new BufferedReader(
113: new InputStreamReader(res.openStream(),
114: "UTF-8"));
115:
116: while (rd.ready()) {
117: String factoryClassName = rd.readLine().trim();
118:
119: try {
120: Schema s = (Schema) cls[i].loadClass(
121: factoryClassName)
122: .getDeclaredMethod("getInstance",
123: new Class[0]).invoke(null,
124: new Object[0]);
125: schemas.put(s.getTargetNamespace(), s);
126: } catch (IllegalArgumentException e1) {
127: XSISAXHandler.logger.warning(e1.toString());
128: } catch (SecurityException e1) {
129: XSISAXHandler.logger.warning(e1.toString());
130: } catch (IllegalAccessException e1) {
131: XSISAXHandler.logger.warning(e1.toString());
132: } catch (InvocationTargetException e1) {
133: XSISAXHandler.logger.warning(e1.toString());
134: } catch (NoSuchMethodException e1) {
135: XSISAXHandler.logger.warning(e1.toString());
136: } catch (ClassNotFoundException e1) {
137: XSISAXHandler.logger.warning(e1.toString());
138: }
139: }
140:
141: rd.close();
142: }
143: } catch (IOException e) {
144: XSISAXHandler.logger.warning(e.toString());
145: }
146: }
147:
148: return schemas;
149: }
150:
151: // stolen from FactoryFinder.findLoaders
152: private ClassLoader[] findLoaders() {
153: // lets get a class loader. By using the Thread's class loader, we allow
154: // for more flexability.
155: ClassLoader contextLoader = null;
156:
157: try {
158: contextLoader = Thread.currentThread()
159: .getContextClassLoader();
160: } catch (SecurityException se) {
161: // do nothing
162: }
163:
164: ClassLoader systemLoader = ReferencingFactoryFinder.class
165: .getClassLoader();
166:
167: ClassLoader[] classLoaders;
168:
169: if ((contextLoader == null) || (contextLoader == systemLoader)) {
170: classLoaders = new ClassLoader[1];
171: classLoaders[0] = systemLoader;
172: } else {
173: classLoaders = new ClassLoader[2];
174: classLoaders[0] = contextLoader;
175: classLoaders[1] = systemLoader;
176: }
177:
178: return classLoaders;
179: }
180:
181: /**
182: * Returns an instance of the desired class. There is no provision for: a)
183: * same instances each call b) different instances each call c) this
184: * factory being thread safe
185: *
186: * @param targetNamespace
187: * @param desiredSchema URI the uri of which you want a schema instance.
188: *
189: * @return Schema an instance of the desired schema.
190: *
191: * @throws SAXException
192: */
193: public static Schema getInstance(URI targetNamespace,
194: URI desiredSchema) throws SAXException {
195: return getInstance(targetNamespace, desiredSchema,
196: Level.WARNING);
197: }
198:
199: public static Schema getInstance(URI targetNamespace,
200: InputStream is1) throws SAXException {
201: return getInstance(targetNamespace, is1, Level.WARNING);
202: }
203:
204: /**
205: * Returns an instance of the targetNamespace if it can be found ... null
206: * otherwise. targetNamespaces which can be found are either hard-coded
207: * namespaces (SchemaFactory.properties), have already been parsed or were
208: * registered.
209: *
210: * @param targetNamespace
211: *
212: *
213: * @see #registerSchema(Strin,Schema)
214: */
215: public synchronized static Schema getInstance(URI targetNamespace) {
216: return getInstance().getRealInstance(targetNamespace);
217: }
218:
219: //TODO cache this on schema registry
220: public synchronized static Schema[] getSchemas(String prefix) {
221: if (prefix == null)
222: return null;
223: SchemaFactory sf = getInstance();
224: Iterator i = sf.schemas.values().iterator();
225: List l = new LinkedList();
226: while (i.hasNext()) {
227: Schema s = (Schema) i.next();
228: if (prefix.equals(s.getPrefix()))
229: l.add(s);
230: }
231: return (Schema[]) l.toArray(new Schema[l.size()]);
232: }
233:
234: private synchronized Schema getRealInstance(URI targetNamespace) {
235: Schema r = (Schema) schemas.get(targetNamespace);
236:
237: if (r != null) {
238: return r;
239: }
240:
241: // if (mappings.containsKey(targetNamespace)) {
242: // ClassLoader cl = SchemaFactory.class.getClassLoader();
243: //
244: // try {
245: // Class c = cl.loadClass((String) mappings.get(targetNamespace));
246: // r = (Schema) c.getConstructor(new Class[0]).newInstance(new Object[0]);
247: // schemas.put(targetNamespace, r);
248: //
249: // return r;
250: // } catch (Exception e) {
251: // return null;
252: // }
253: // }
254: return null;
255: }
256:
257: /**
258: * Returns an instance of the desired class. There is no provision for: a)
259: * same instances each call b) different instances each call c) this
260: * factory being thread safe
261: *
262: * @param targetNamespace The targetNamespace to search for.
263: * @param desiredSchema URI the uri of which you want a schema instance.
264: * @param level Level
265: *
266: * @return Schema an instance of the desired schema.
267: *
268: * @throws SAXException When something goes wrong
269: */
270: public synchronized static Schema getInstance(URI targetNamespace,
271: URI desiredSchema, Level level) throws SAXException {
272: return getInstance().getRealInstance(targetNamespace,
273: desiredSchema, level);
274: }
275:
276: private synchronized Schema getRealInstance(URI targetNamespace2,
277: URI desiredSchema, Level level) throws SAXException {
278: URI targetNamespace = targetNamespace2;
279: if ((targetNamespace == null)
280: || (schemas.get(targetNamespace) == null)) {
281: setParser();
282:
283: XSISAXHandler contentHandler = getSAXHandler(desiredSchema);
284: XSISAXHandler.setLogLevel(level);
285:
286: try {
287: parser.parse(desiredSchema.toString(), contentHandler);
288: } catch (IOException e) {
289: // TODO error handler should be notified of a connectionexception: operation timed out.
290: throw new SAXException(e);
291: }
292:
293: Schema schema = contentHandler.getSchema();
294: if ((targetNamespace == null) || "".equals(targetNamespace)) {
295: targetNamespace = schema.getTargetNamespace();
296: }
297:
298: if (schemas.get(targetNamespace) != null) {
299: schema = merge(schema, (Schema) schemas
300: .get(targetNamespace));
301: }
302: schemas.put(targetNamespace, schema);
303: return schema;
304: } else {
305: if (!((Schema) schemas.get(targetNamespace))
306: .includesURI(desiredSchema)) {
307: Schema sh = (Schema) schemas.get(targetNamespace);
308: setParser();
309:
310: XSISAXHandler contentHandler = getSAXHandler(desiredSchema);
311: XSISAXHandler.setLogLevel(level);
312:
313: try {
314: parser.parse(desiredSchema.toString(),
315: contentHandler);
316: } catch (IOException e) {
317: throw new SAXException(e);
318: }
319:
320: sh = merge(sh, contentHandler.getSchema());
321: schemas.put(targetNamespace, sh); // over-write
322: }
323: }
324:
325: return (Schema) schemas.get(targetNamespace);
326: }
327:
328: protected XSISAXHandler getSAXHandler(URI uri) {
329: return new XSISAXHandler(uri);
330: }
331:
332: public static synchronized Schema getInstance(URI targetNamespace,
333: InputStream is1, Level level) throws SAXException {
334: return getInstance().getRealInstance(targetNamespace, is1,
335: level);
336: }
337:
338: private synchronized Schema getRealInstance(URI targetNamespace2,
339: InputStream is1, Level level) throws SAXException {
340: URI targetNamespace = targetNamespace2;
341:
342: if ((targetNamespace == null)
343: || (schemas.get(targetNamespace) == null)) {
344: XSISAXHandler contentHandler = parseSchema(is1, level);
345:
346: if ((targetNamespace == null) || "".equals(targetNamespace)) {
347: targetNamespace = contentHandler.getSchema()
348: .getTargetNamespace();
349: }
350:
351: Schema schema = contentHandler.getSchema();
352: if (schemas.get(targetNamespace) != null) {
353: schema = merge(schema, (Schema) schemas
354: .get(targetNamespace));
355: }
356:
357: schemas.put(targetNamespace, schema);
358:
359: } else {
360: Schema sh = (Schema) schemas.get(targetNamespace);
361: XSISAXHandler contentHandler = parseSchema(is1, level);
362:
363: sh = merge(sh, contentHandler.getSchema());
364: schemas.put(targetNamespace, sh); // over-write
365: }
366: return (Schema) schemas.get(targetNamespace);
367: }
368:
369: private XSISAXHandler parseSchema(InputStream is1, Level level)
370: throws SAXException {
371: setParser();
372:
373: XSISAXHandler contentHandler = getSAXHandler(null);
374: XSISAXHandler.setLogLevel(level);
375:
376: try {
377: parser.parse(is1, contentHandler);
378: } catch (IOException e) {
379: throw new SAXException(e);
380: }
381: return contentHandler;
382: }
383:
384: /*
385: * Creates a new Schema from merging the two schemas passed in. for instance
386: * information, such as id, or version, s1 takes precedence.
387: */
388: private Schema merge(Schema s1, Schema s2) throws SAXException {
389: return new MergedSchema(s1, s2);
390: }
391:
392: /**
393: * Registers a Schema instance with the factory. A clone is NOT created
394: * within this method. The Schema passed in is associated with the
395: * specified targetNamespace. The Schema is not tested to ensure the
396: * intended targetNamespace (schema.getTargetNamespace()) is equal to
397: * targetNamespace. The ramifications is that you may hack wildly within
398: * the repository, but we aware you may have some 'undocumented features'
399: * as a result (odd Schemas being returned).
400: *
401: * @param targetNamespace
402: * @param schema
403: */
404: public static void registerSchema(URI targetNamespace, Schema schema) {
405: getInstance().registerRealSchema(targetNamespace, schema);
406: }
407:
408: private void registerRealSchema(URI targetNamespace, Schema schema) {
409: schemas.put(targetNamespace, schema);
410: }
411:
412: /*
413: * convinience method to create an instance of a SAXParser if it is null.
414: */
415: private void setParser() throws SAXException {
416: if (parser == null) {
417: SAXParserFactory spf = SAXParserFactory.newInstance();
418: spf.setNamespaceAware(true);
419: spf.setValidating(false);
420:
421: try {
422: parser = spf.newSAXParser();
423: } catch (ParserConfigurationException e) {
424: throw new SAXException(e);
425: } catch (SAXException e) {
426: throw new SAXException(e);
427: }
428: }
429: }
430:
431: /**
432: * The Schema will contain references to the elements within the two
433: * Schemas provided in the constructor. In most cases this is used to
434: * incorporate additional definitions into a targetNamespace by parsing an
435: * additional schema file.
436: *
437: * @author dzwiers
438: *
439: * @see Schema
440: */
441: private static class MergedSchema implements Schema {
442: /*
443: * This is all fairly self explanatory.
444: *
445: * @see Schema
446: */
447: private AttributeGroup[] attributeGroups;
448: private Attribute[] attributes;
449: private int block;
450: private int finaL;
451: private ComplexType[] complexTypes;
452: private Element[] elements;
453: private Group[] groups;
454: private String id;
455: private String version;
456: private String prefix;
457: private URI targetNamespace;
458: private Schema[] imports;
459: private SimpleType[] simpleTypes;
460: private boolean aForm;
461: private boolean eForm;
462: private URI uri;
463:
464: /**
465: * This completes the merge of two schemas, s1 and s2. When there is a
466: * conflict in data between the two schemas, s1 is assumed to be
467: * correct.
468: *
469: * @param s1 Schema (Tie Winner)
470: * @param s2 Schema (Tie Loser)
471: *
472: * @throws SAXException When some thing bad happens (for example
473: * merging two targetNamespaces)
474: */
475: public MergedSchema(Schema s1, Schema s2) throws SAXException {
476: if ((s1.getId() == null) || s1.getId().equals("")) {
477: id = s2.getId();
478: } else {
479: id = s1.getId();
480: }
481:
482: if ((s1.getVersion() == null) || s1.getVersion().equals("")) {
483: version = s2.getVersion();
484: } else {
485: version = s1.getVersion();
486: }
487:
488: if ((s1.getTargetNamespace() == null)
489: || s1.getTargetNamespace().equals("")) {
490: targetNamespace = s2.getTargetNamespace();
491: } else {
492: if ((s2.getTargetNamespace() != null)
493: && !s1.getTargetNamespace().equals(
494: s2.getTargetNamespace())) {
495: throw new SAXException(
496: "cannot merge two target namespaces. "
497: + s1.getTargetNamespace() + " "
498: + s2.getTargetNamespace());
499: }
500:
501: targetNamespace = s1.getTargetNamespace();
502: }
503:
504: aForm = s1.isAttributeFormDefault()
505: || s2.isAttributeFormDefault();
506: eForm = s1.isElementFormDefault()
507: || s2.isElementFormDefault();
508:
509: HashMap m = new HashMap();
510:
511: AttributeGroup[] ag1 = s1.getAttributeGroups();
512:
513: if (ag1 == null) {
514: ag1 = new AttributeGroup[0];
515: }
516:
517: AttributeGroup[] ag2 = s2.getAttributeGroups();
518:
519: if (ag2 == null) {
520: ag2 = new AttributeGroup[0];
521: }
522:
523: for (int i = 0; i < ag1.length; i++)
524: m.put(ag1[i].getName(), ag1[i]);
525:
526: for (int i = 0; i < ag2.length; i++)
527: if (!m.containsKey(ag2[i].getName())) {
528: m.put(ag2[i].getName(), ag2[i]);
529: }
530:
531: attributeGroups = new AttributeGroup[m.size()];
532:
533: Object[] obj = m.values().toArray();
534:
535: for (int i = 0; i < obj.length; i++)
536: attributeGroups[i] = (AttributeGroup) (obj[i]);
537:
538: m = new HashMap();
539:
540: Attribute[] a1 = s1.getAttributes();
541:
542: if (a1 == null) {
543: a1 = new Attribute[0];
544: }
545:
546: Attribute[] a2 = s2.getAttributes();
547:
548: if (a2 == null) {
549: a2 = new Attribute[0];
550: }
551:
552: for (int i = 0; i < a1.length; i++)
553: m.put(a1[i].getName(), a1[i]);
554:
555: for (int i = 0; i < a2.length; i++)
556: if (!m.containsKey(a2[i].getName())) {
557: m.put(a2[i].getName(), a2[i]);
558: }
559:
560: attributes = new Attribute[m.size()];
561: obj = m.values().toArray();
562:
563: for (int i = 0; i < obj.length; i++)
564: attributes[i] = (Attribute) (obj[i]);
565:
566: block = s1.getBlockDefault() | s2.getBlockDefault();
567: finaL = s1.getFinalDefault() | s2.getFinalDefault();
568:
569: m = new HashMap();
570:
571: ComplexType[] c1 = s1.getComplexTypes();
572:
573: if (c1 == null) {
574: c1 = new ComplexType[0];
575: }
576:
577: ComplexType[] c2 = s2.getComplexTypes();
578:
579: if (c2 == null) {
580: c2 = new ComplexType[0];
581: }
582:
583: for (int i = 0; i < c1.length; i++)
584: m.put(c1[i].getName(), c1[i]);
585:
586: for (int i = 0; i < c2.length; i++)
587: if (!m.containsKey(c2[i].getName())) {
588: m.put(c2[i].getName(), c2[i]);
589: }
590:
591: complexTypes = new ComplexType[m.size()];
592: obj = m.values().toArray();
593:
594: for (int i = 0; i < obj.length; i++)
595: complexTypes[i] = (ComplexType) (obj[i]);
596:
597: m = new HashMap();
598:
599: SimpleType[] ss1 = s1.getSimpleTypes();
600:
601: if (ss1 == null) {
602: ss1 = new SimpleType[0];
603: }
604:
605: SimpleType[] ss2 = s2.getSimpleTypes();
606:
607: if (ss2 == null) {
608: ss2 = new SimpleType[0];
609: }
610:
611: for (int i = 0; i < ss1.length; i++)
612: m.put(ss1[i].getName(), ss1[i]);
613:
614: for (int i = 0; i < ss2.length; i++)
615: if (!m.containsKey(ss2[i].getName())) {
616: m.put(ss2[i].getName(), ss2[i]);
617: }
618:
619: simpleTypes = new SimpleType[m.size()];
620: obj = m.values().toArray();
621:
622: for (int i = 0; i < obj.length; i++)
623: simpleTypes[i] = (SimpleType) (obj[i]);
624:
625: m = new HashMap();
626:
627: Element[] e1 = s1.getElements();
628:
629: if (e1 == null) {
630: e1 = new Element[0];
631: }
632:
633: Element[] e2 = s2.getElements();
634:
635: if (e2 == null) {
636: e2 = new Element[0];
637: }
638:
639: for (int i = 0; i < e1.length; i++)
640: m.put(e1[i].getName(), e1[i]);
641:
642: for (int i = 0; i < e2.length; i++)
643: if (!m.containsKey(e2[i].getName())) {
644: m.put(e2[i].getName(), e2[i]);
645: }
646:
647: elements = new Element[m.size()];
648: obj = m.values().toArray();
649:
650: for (int i = 0; i < obj.length; i++)
651: elements[i] = (Element) (obj[i]);
652:
653: m = new HashMap();
654:
655: Group[] g1 = s1.getGroups();
656:
657: if (g1 == null) {
658: g1 = new Group[0];
659: }
660:
661: Group[] g2 = s2.getGroups();
662:
663: if (g2 == null) {
664: g2 = new Group[0];
665: }
666:
667: for (int i = 0; i < g1.length; i++)
668: m.put(g1[i].getName(), g1[i]);
669:
670: for (int i = 0; i < g2.length; i++)
671: if (!m.containsKey(g2[i].getName())) {
672: m.put(g2[i].getName(), g2[i]);
673: }
674:
675: groups = new Group[m.size()];
676: obj = m.values().toArray();
677:
678: for (int i = 0; i < obj.length; i++)
679: groups[i] = (Group) (obj[i]);
680:
681: m = new HashMap();
682:
683: Schema[] i1 = s1.getImports();
684:
685: if (i1 == null) {
686: i1 = new Schema[0];
687: }
688:
689: Schema[] i2 = s2.getImports();
690:
691: if (i2 == null) {
692: i2 = new Schema[0];
693: }
694:
695: for (int i = 0; i < i1.length; i++)
696: m.put(i1[i].getTargetNamespace(), i1[i]);
697:
698: for (int i = 0; i < i2.length; i++)
699: if (!m.containsKey(i2[i].getTargetNamespace())) {
700: m.put(i2[i].getTargetNamespace(), i2[i]);
701: }
702:
703: imports = new Schema[m.size()];
704: obj = m.values().toArray();
705:
706: for (int i = 0; i < obj.length; i++)
707: imports[i] = (Schema) (obj[i]);
708:
709: URI u1 = s1.getURI();
710:
711: URI u2 = s2.getURI();
712:
713: if (u1 == null) {
714: uri = u2;
715: } else {
716: if (u2 == null) {
717: uri = u1;
718: } else {
719: uri = u2.relativize(u1);
720: }
721: }
722:
723: if ((s1.getPrefix() == null) || s1.getPrefix().equals("")) {
724: prefix = s2.getPrefix();
725: } else {
726: prefix = s1.getPrefix();
727: }
728: }
729:
730: /**
731: * @see schema.Schema#getAttributeGroups()
732: */
733: public AttributeGroup[] getAttributeGroups() {
734: return attributeGroups;
735: }
736:
737: /**
738: * @see schema.Schema#getAttributes()
739: */
740: public Attribute[] getAttributes() {
741: return attributes;
742: }
743:
744: /**
745: * @see schema.Schema#getBlockDefault()
746: */
747: public int getBlockDefault() {
748: return block;
749: }
750:
751: /**
752: * @see schema.Schema#getComplexTypes()
753: */
754: public ComplexType[] getComplexTypes() {
755: return complexTypes;
756: }
757:
758: /**
759: * @see schema.Schema#getElements()
760: */
761: public Element[] getElements() {
762: return elements;
763: }
764:
765: /**
766: * @see schema.Schema#getFinalDefault()
767: */
768: public int getFinalDefault() {
769: return finaL;
770: }
771:
772: /**
773: * @see schema.Schema#getGroups()
774: */
775: public Group[] getGroups() {
776: return groups;
777: }
778:
779: /**
780: * @see schema.Schema#getId()
781: */
782: public String getId() {
783: return id;
784: }
785:
786: /**
787: * @see schema.Schema#getImports()
788: */
789: public Schema[] getImports() {
790: return imports;
791: }
792:
793: /**
794: * @see schema.Schema#getSimpleTypes()
795: */
796: public SimpleType[] getSimpleTypes() {
797: return simpleTypes;
798: }
799:
800: /**
801: * @see schema.Schema#getTargetNamespace()
802: */
803: public URI getTargetNamespace() {
804: return targetNamespace;
805: }
806:
807: /**
808: * @see schema.Schema#getVersion()
809: */
810: public String getVersion() {
811: return version;
812: }
813:
814: /**
815: * @see schema.Schema#includesURI(java.net.URI)
816: */
817: public boolean includesURI(URI uri1) {
818: if (uri1 == null || this .uri == null) {
819: return false;
820: }
821:
822: return this .uri.equals(uri1);
823: }
824:
825: /**
826: * @see schema.Schema#isAttributeFormDefault()
827: */
828: public boolean isAttributeFormDefault() {
829: return aForm;
830: }
831:
832: /**
833: * @see schema.Schema#isElementFormDefault()
834: */
835: public boolean isElementFormDefault() {
836: return eForm;
837: }
838:
839: /**
840: * @see schema.Schema#getURIs()
841: */
842: public URI getURI() {
843: return uri;
844: }
845:
846: public String getPrefix() {
847: return prefix;
848: }
849:
850: /**
851: * Returns the implementation hints. The default implementation returns en empty map.
852: */
853: public Map getImplementationHints() {
854: return Collections.EMPTY_MAP;
855: }
856: }
857:
858: }
|