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.schema.impl;
017:
018: import java.net.URI;
019:
020: import org.geotools.xml.schema.All;
021: import org.geotools.xml.schema.Element;
022:
023: /**
024: *
025: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/xml/src/main/java/org/geotools/xml/schema/impl/AllGT.java $
026: */
027: public class AllGT implements All {
028:
029: private Element[] elements;
030: private String id;
031: private int max;
032: private int min;
033:
034: public AllGT(Element[] elements) {
035: this .elements = elements;
036: max = min = 1;
037: }
038:
039: public AllGT(String id, Element[] elements, int min, int max) {
040: this .id = id;
041: this .elements = elements;
042: this .min = min;
043: this .max = max;
044: }
045:
046: /* (non-Javadoc)
047: * @see org.geotools.xml.schema.All#getElements()
048: */
049: public Element[] getElements() {
050: return elements;
051: }
052:
053: /* (non-Javadoc)
054: * @see org.geotools.xml.schema.All#getId()
055: */
056: public String getId() {
057: return id;
058: }
059:
060: /* (non-Javadoc)
061: * @see org.geotools.xml.schema.ElementGrouping#getMaxOccurs()
062: */
063: public int getMaxOccurs() {
064: return max;
065: }
066:
067: /* (non-Javadoc)
068: * @see org.geotools.xml.schema.ElementGrouping#getMinOccurs()
069: */
070: public int getMinOccurs() {
071: return min;
072: }
073:
074: /* (non-Javadoc)
075: * @see org.geotools.xml.schema.ElementGrouping#getGrouping()
076: */
077: public int getGrouping() {
078: return ALL;
079: }
080:
081: /* (non-Javadoc)
082: * @see org.geotools.xml.schema.ElementGrouping#findChildElement(java.lang.String)
083: */
084: public Element findChildElement(String name) {
085: if (elements != null) {
086: for (int i = 0; i < elements.length; i++) {
087: Element e = elements[i].findChildElement(name);
088:
089: if (e != null) {
090: return e;
091: }
092: }
093: }
094:
095: return null;
096: }
097:
098: public Element findChildElement(String localName, URI namespaceURI) {
099: if (elements != null) {
100: for (int i = 0; i < elements.length; i++) {
101: Element e = elements[i].findChildElement(localName,
102: namespaceURI);
103:
104: if (e != null) {
105: return e;
106: }
107: }
108: }
109:
110: return null;
111: }
112:
113: }
|