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.Collections;
046: import java.util.List;
047: import org.netbeans.modules.xml.axi.datatype.Datatype.Facet;
048: import org.netbeans.modules.xml.schema.model.Whitespace;
049:
050: /**
051: * This class represents Base for all time types.
052: *
053: * @author Ayub Khan
054: */
055: public abstract class TimeBase extends Datatype {
056:
057: static List<Facet> applicableFacets;
058:
059: private Datatype.Kind kind;
060:
061: protected List<String> patterns;
062:
063: protected List<String> enumerations;
064:
065: protected List<Whitespace.Treatment> whitespaces;
066:
067: protected List<String> maxInclusives;
068:
069: protected List<String> maxExclusives;
070:
071: protected List<String> minInclusives;
072:
073: protected List<String> minExclusives;
074:
075: private boolean hasFacets;
076:
077: private boolean isList;
078:
079: /** Creates a new instance of StringBase */
080: public TimeBase(Kind kind) {
081: this .kind = kind;
082: }
083:
084: public Kind getKind() {
085: return kind;
086: }
087:
088: public synchronized List<Facet> getApplicableFacets() {
089: if (applicableFacets == null) {
090: List<Facet> facets = new ArrayList<Facet>();
091: facets.add(Facet.PATTERN);
092: facets.add(Facet.ENUMERATION);
093: facets.add(Facet.WHITESPACE);
094: facets.add(Facet.MAXINCLUSIVE);
095: facets.add(Facet.MAXEXCLUSIVE);
096: facets.add(Facet.MININCLUSIVE);
097: facets.add(Facet.MINEXCLUSIVE);
098: applicableFacets = Collections.unmodifiableList(facets);
099: }
100: return applicableFacets;
101: }
102:
103: public boolean hasFacets() {
104: return hasFacets;
105: }
106:
107: public boolean isList() {
108: return isList;
109: }
110:
111: public void setIsList(boolean isList) {
112: this .isList = isList;
113: }
114:
115: /*
116: * returns pattern value (this corresponds to the value of pattern facet in schema)
117: *
118: * @return pattern
119: */
120: public List<String> getPatterns() {
121: return patterns;
122: }
123:
124: /*
125: * returns enumeration values (this corresponds to the values of enumeration facets in schema)
126: *
127: * @return enumeration
128: */
129: public List<String> getEnumerations() {
130: return enumerations;
131: }
132:
133: /*
134: * returns whitespace value (this corresponds to the value of whitespace facet in schema)
135: *
136: * @return whitespaces
137: */
138: public List<Whitespace.Treatment> getWhiteSpaces() {
139: return whitespaces;
140: }
141:
142: /*
143: * returns maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
144: *
145: * @return maxInclusive
146: */
147: public List<String> getMaxInclusives() {
148: return maxInclusives;
149: }
150:
151: /*
152: * returns maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
153: *
154: * @return maxExclusive
155: */
156: public List<String> getMaxExclusives() {
157: return maxExclusives;
158: }
159:
160: /*
161: * returns minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
162: *
163: * @return minInclusive
164: */
165: public List<String> getMinInclusives() {
166: return minInclusives;
167: }
168:
169: /*
170: * returns minExclusive value (this corresponds to the value of minExclusive facet in schema)
171: *
172: * @return minExclusive
173: */
174: public List<String> getMinExclusives() {
175: return minExclusives;
176: }
177:
178: /*
179: * set pattern value (this corresponds to the value of pattern facet in schema)
180: *
181: * @param pattern
182: */
183: public void addPattern(String pattern) {
184: if (patterns == null) {
185: patterns = new ArrayList<String>(1);
186: hasFacets = true;
187: }
188: this .patterns.add(pattern);
189: }
190:
191: /*
192: * set enumeration values (this corresponds to the values of enumeration facets in schema)
193: *
194: * @param enumeration
195: */
196: public void addEnumeration(String enumeration) {
197: if (enumerations == null) {
198: enumerations = new ArrayList<String>(1);
199: hasFacets = true;
200: }
201: this .enumerations.add(enumeration);
202: }
203:
204: /*
205: * set whitespace value (this corresponds to the value of whitespace facet in schema)
206: *
207: * @param whitespace
208: */
209: public void addWhitespace(Whitespace.Treatment whitespace) {
210: if (whitespaces == null) {
211: whitespaces = new ArrayList<Whitespace.Treatment>(1);
212: hasFacets = true;
213: }
214: this .whitespaces.add(whitespace);
215: }
216:
217: /*
218: * set maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
219: *
220: * @param maxInclusive
221: */
222: public void addMaxInclusive(String maxInclusive) {
223: if (maxInclusives == null) {
224: maxInclusives = new ArrayList<String>(1);
225: hasFacets = true;
226: }
227: this .maxInclusives.add(maxInclusive);
228: }
229:
230: /*
231: * set maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
232: *
233: * @param maxExclusive
234: */
235: public void addMaxExclusive(String maxExclusive) {
236: if (maxExclusives == null) {
237: maxExclusives = new ArrayList<String>(1);
238: hasFacets = true;
239: }
240: this .maxExclusives.add(maxExclusive);
241: }
242:
243: /*
244: * set minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
245: *
246: * @param minInclusive
247: */
248: public void addMinInclusive(String minInclusive) {
249: if (minInclusives == null) {
250: minInclusives = new ArrayList<String>(1);
251: hasFacets = true;
252: }
253: this .minInclusives.add(minInclusive);
254: }
255:
256: /*
257: * set minExclusive value (this corresponds to the value of minExclusive facet in schema)
258: *
259: * @param minExclusive
260: */
261: public void addMinExclusive(String minExclusive) {
262: if (minExclusives == null) {
263: minExclusives = new ArrayList<String>(1);
264: hasFacets = true;
265: }
266: this .minExclusives.add(minExclusive);
267: }
268:
269: /*
270: * set pattern value (this corresponds to the value of pattern facet in schema)
271: *
272: * @param pattern
273: */
274: public void removePattern(String pattern) {
275: if (patterns != null)
276: patterns.remove(pattern);
277: }
278:
279: /*
280: * set enumeration values (this corresponds to the values of enumeration facets in schema)
281: *
282: * @param enumeration
283: */
284: public void removeEnumeration(String enumeration) {
285: if (enumerations != null)
286: enumerations.remove(enumeration);
287: }
288:
289: /*
290: * set whitespace value (this corresponds to the value of whitespace facet in schema)
291: *
292: * @param whitespace
293: */
294: public void removeWhitespace(Whitespace.Treatment whitespace) {
295: if (whitespaces != null)
296: whitespaces.remove(whitespace);
297: }
298:
299: /*
300: * set maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
301: *
302: * @param maxInclusive
303: */
304: public void removeMaxInclusive(String maxInclusive) {
305: if (maxInclusives != null)
306: maxInclusives.remove(maxInclusive);
307: }
308:
309: /*
310: * set maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
311: *
312: * @param maxExclusive
313: */
314: public void removeMaxExclusive(String maxExclusive) {
315: if (maxExclusives != null)
316: maxExclusives.remove(maxExclusive);
317: }
318:
319: /*
320: * set minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
321: *
322: * @param minInclusive
323: */
324: public void removeMinInclusive(String minInclusive) {
325: if (minInclusives != null)
326: minInclusives.remove(minInclusive);
327: }
328:
329: /*
330: * set minExclusive value (this corresponds to the value of minExclusive facet in schema)
331: *
332: * @param minExclusive
333: */
334: public void removeMinExclusive(String minExclusive) {
335: if (minExclusives != null)
336: minExclusives.remove(minExclusive);
337: }
338: }
|