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