001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.axi.datatype;
043:
044: import java.util.ArrayList;
045: import java.util.List;
046: import org.netbeans.modules.xml.schema.model.Whitespace;
047:
048: /**
049: * This class represents QNameType. This is one of those atomic types that can
050: * be used to type an Attribute or leaf Elements in AXI Model
051: *
052: *
053: *
054: * @author Ayub Khan
055: */
056: public class QNameType extends StringBase {
057:
058: protected boolean hasFacets;
059:
060: private List<Integer> lengths;
061:
062: private List<Integer> minLengths;
063:
064: private List<Integer> maxLengths;
065:
066: private List<String> patterns;
067:
068: protected List<String> enumerations;
069:
070: private List<Whitespace.Treatment> whitespaces;
071:
072: /**
073: * Creates a new instance of QNameType
074: */
075: public QNameType() {
076: super (Datatype.Kind.QNAME);
077: }
078:
079: /*
080: * returns length (this corresponds to the value of length facet in schema)
081: *
082: * @return length
083: */
084: public List<Integer> getLengths() {
085: return lengths;
086: }
087:
088: /*
089: * returns minimum length value (this corresponds to the value of minlength facet in schema)
090: *
091: * @return minLength
092: */
093: public List<Integer> getMinLengths() {
094: return minLengths;
095: }
096:
097: /*
098: * returns maximum length value (this corresponds to the value of maxlength facet in schema)
099: *
100: * @return maxLength
101: */
102: public List<Integer> getMaxLengths() {
103: return maxLengths;
104: }
105:
106: /*
107: * returns pattern value (this corresponds to the value of pattern facet in schema)
108: *
109: * @return pattern
110: */
111: public List<String> getPatterns() {
112: return patterns;
113: }
114:
115: /*
116: * returns enumeration values (this corresponds to the values of enumeration facets in schema)
117: *
118: * @return enumeration
119: */
120: public List<String> getEnumerations() {
121: return enumerations;
122: }
123:
124: /*
125: * returns whitespace value (this corresponds to the value of whitespace facet in schema)
126: *
127: * @return whitespaces
128: */
129: public List<Whitespace.Treatment> getWhiteSpaces() {
130: return whitespaces;
131: }
132:
133: /*
134: * set length (this corresponds to the value of length facet in schema)
135: *
136: * @param length
137: */
138: public void addLength(int length) {
139: if (lengths == null) {
140: lengths = new ArrayList<Integer>(1);
141: hasFacets = true;
142: }
143: this .lengths.add(new Integer(length));
144: }
145:
146: /*
147: * set minimum length value (this corresponds to the value of minlength facet in schema)
148: *
149: * @param minLength
150: */
151: public void addMinLength(int minLength) {
152: if (minLengths == null) {
153: minLengths = new ArrayList<Integer>(1);
154: hasFacets = true;
155: }
156: this .minLengths.add(new Integer(minLength));
157: }
158:
159: /*
160: * set maximum length value (this corresponds to the value of maxlength facet in schema)
161: *
162: * @param maxLength
163: */
164: public void addMaxLength(int maxLength) {
165: if (maxLengths == null) {
166: maxLengths = new ArrayList<Integer>(1);
167: hasFacets = true;
168: }
169: this .maxLengths.add(new Integer(maxLength));
170: }
171:
172: /*
173: * set pattern value (this corresponds to the value of pattern facet in schema)
174: *
175: * @param pattern
176: */
177: public void addPattern(String pattern) {
178: if (patterns == null) {
179: patterns = new ArrayList<String>(1);
180: hasFacets = true;
181: }
182: this .patterns.add(pattern);
183: }
184:
185: /*
186: * returns enumeration values (this corresponds to the values of enumeration facets in schema)
187: *
188: * @param enumeration
189: */
190: public void addEnumeration(String enumeration) {
191: if (enumerations == null) {
192: enumerations = new ArrayList<String>(1);
193: hasFacets = true;
194: }
195: this .enumerations.add(enumeration);
196: }
197:
198: /*
199: * set whitespace value (this corresponds to the value of whitespace facet in schema)
200: *
201: * @param whitespace
202: */
203: public void addWhitespace(Whitespace.Treatment whitespace) {
204: if (whitespaces == null) {
205: whitespaces = new ArrayList<Whitespace.Treatment>(1);
206: hasFacets = true;
207: }
208: this .whitespaces.add(whitespace);
209: }
210:
211: /*
212: * set length (this corresponds to the value of length facet in schema)
213: *
214: * @param length
215: */
216: public void removeLength(int length) {
217: if (lengths == null) {
218: lengths = new ArrayList<Integer>(1);
219: hasFacets = true;
220: }
221: this .lengths.remove(new Integer(length));
222: }
223:
224: /*
225: * set minimum length value (this corresponds to the value of minlength facet in schema)
226: *
227: * @param minLength
228: */
229: public void removeMinLength(int minLength) {
230: if (minLengths == null) {
231: minLengths = new ArrayList<Integer>(1);
232: hasFacets = true;
233: }
234: this .minLengths.remove(new Integer(minLength));
235: }
236:
237: /*
238: * set maximum length value (this corresponds to the value of maxlength facet in schema)
239: *
240: * @param maxLength
241: */
242: public void removeMaxLength(int maxLength) {
243: if (maxLengths == null) {
244: maxLengths = new ArrayList<Integer>(1);
245: hasFacets = true;
246: }
247: this .maxLengths.remove(new Integer(maxLength));
248: }
249:
250: /*
251: * set pattern value (this corresponds to the value of pattern facet in schema)
252: *
253: * @param pattern
254: */
255: public void removePattern(String pattern) {
256: if (patterns == null) {
257: patterns = new ArrayList<String>(1);
258: hasFacets = true;
259: }
260: this .patterns.remove(pattern);
261: }
262:
263: /*
264: * returns enumeration values (this corresponds to the values of enumeration facets in schema)
265: *
266: * @param enumeration
267: */
268: public void removeEnumeration(String enumeration) {
269: if (enumerations == null) {
270: enumerations = new ArrayList<String>(1);
271: hasFacets = true;
272: }
273: this .enumerations.remove(enumeration);
274: }
275:
276: /*
277: * set whitespace value (this corresponds to the value of whitespace facet in schema)
278: *
279: * @param whitespace
280: */
281: public void removeWhitespace(Whitespace.Treatment whitespace) {
282: if (whitespaces == null) {
283: whitespaces = new ArrayList<Whitespace.Treatment>(1);
284: hasFacets = true;
285: }
286: this.whitespaces.remove(whitespace);
287: }
288: }
|