KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > axi > datatype > TimeBase


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.axi.datatype;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.List JavaDoc;
25 import org.netbeans.modules.xml.axi.datatype.Datatype.Facet;
26 import org.netbeans.modules.xml.schema.model.Whitespace;
27
28 /**
29  * This class represents Base for all time types.
30  *
31  * @author Ayub Khan
32  */

33 public abstract class TimeBase extends Datatype {
34     
35     static List JavaDoc<Facet> applicableFacets;
36     
37     private Datatype.Kind kind;
38     
39     protected List JavaDoc<String JavaDoc> patterns;
40     
41     protected List JavaDoc<String JavaDoc> enumerations;
42     
43     protected List JavaDoc<Whitespace.Treatment> whitespaces;
44     
45     protected List JavaDoc<String JavaDoc> maxInclusives;
46     
47     protected List JavaDoc<String JavaDoc> maxExclusives;
48     
49     protected List JavaDoc<String JavaDoc> minInclusives;
50     
51     protected List JavaDoc<String JavaDoc> minExclusives;
52     
53     private boolean hasFacets;
54     
55     private boolean isList;
56     
57     /** Creates a new instance of StringBase */
58     public TimeBase(Kind kind) {
59         this.kind = kind;
60     }
61     
62     public Kind getKind() {
63         return kind;
64     }
65     
66     public synchronized List JavaDoc<Facet> getApplicableFacets() {
67         if(applicableFacets == null) {
68             List JavaDoc<Facet> facets = new ArrayList JavaDoc<Facet>();
69             facets.add(Facet.PATTERN);
70             facets.add(Facet.ENUMERATION);
71             facets.add(Facet.WHITESPACE);
72             facets.add(Facet.MAXINCLUSIVE);
73             facets.add(Facet.MAXEXCLUSIVE);
74             facets.add(Facet.MININCLUSIVE);
75             facets.add(Facet.MINEXCLUSIVE);
76             applicableFacets = Collections.unmodifiableList(facets);
77         }
78         return applicableFacets;
79     }
80     
81     public boolean hasFacets() {
82         return hasFacets;
83     }
84     
85     public boolean isList() {
86         return isList;
87     }
88     
89     public void setIsList(boolean isList) {
90         this.isList = isList;
91     }
92     
93     /*
94      * returns pattern value (this corresponds to the value of pattern facet in schema)
95      *
96      * @return pattern
97      */

98     public List JavaDoc<String JavaDoc> getPatterns() {
99         return patterns;
100     }
101     
102     /*
103      * returns enumeration values (this corresponds to the values of enumeration facets in schema)
104      *
105      * @return enumeration
106      */

107     public List JavaDoc<String JavaDoc> getEnumerations() {
108         return enumerations;
109     }
110     
111     /*
112      * returns whitespace value (this corresponds to the value of whitespace facet in schema)
113      *
114      * @return whitespaces
115      */

116     public List JavaDoc<Whitespace.Treatment> getWhiteSpaces() {
117         return whitespaces;
118     }
119     
120     /*
121      * returns maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
122      *
123      * @return maxInclusive
124      */

125     public List JavaDoc<String JavaDoc> getMaxInclusives() {
126         return maxInclusives;
127     }
128     
129     /*
130      * returns maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
131      *
132      * @return maxExclusive
133      */

134     public List JavaDoc<String JavaDoc> getMaxExclusives() {
135         return maxExclusives;
136     }
137     
138     /*
139      * returns minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
140      *
141      * @return minInclusive
142      */

143     public List JavaDoc<String JavaDoc> getMinInclusives() {
144         return minInclusives;
145     }
146     
147     /*
148      * returns minExclusive value (this corresponds to the value of minExclusive facet in schema)
149      *
150      * @return minExclusive
151      */

152     public List JavaDoc<String JavaDoc> getMinExclusives() {
153         return minExclusives;
154     }
155     
156     /*
157      * set pattern value (this corresponds to the value of pattern facet in schema)
158      *
159      * @param pattern
160      */

161     public void addPattern(String JavaDoc pattern) {
162         if(patterns == null) {
163             patterns = new ArrayList JavaDoc<String JavaDoc>(1);
164             hasFacets = true;
165         }
166         this.patterns.add(pattern);
167     }
168     
169     /*
170      * set enumeration values (this corresponds to the values of enumeration facets in schema)
171      *
172      * @param enumeration
173      */

174     public void addEnumeration(String JavaDoc enumeration) {
175         if(enumerations == null) {
176             enumerations = new ArrayList JavaDoc<String JavaDoc>(1);
177             hasFacets = true;
178         }
179         this.enumerations.add(enumeration);
180     }
181     
182     /*
183      * set whitespace value (this corresponds to the value of whitespace facet in schema)
184      *
185      * @param whitespace
186      */

187     public void addWhitespace(Whitespace.Treatment whitespace) {
188         if(whitespaces == null) {
189             whitespaces = new ArrayList JavaDoc<Whitespace.Treatment>(1);
190             hasFacets = true;
191         }
192         this.whitespaces.add(whitespace);
193     }
194     
195     /*
196      * set maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
197      *
198      * @param maxInclusive
199      */

200     public void addMaxInclusive(String JavaDoc maxInclusive) {
201         if(maxInclusives == null) {
202             maxInclusives = new ArrayList JavaDoc<String JavaDoc>(1);
203             hasFacets = true;
204         }
205         this.maxInclusives.add(maxInclusive);
206     }
207     
208     /*
209      * set maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
210      *
211      * @param maxExclusive
212      */

213     public void addMaxExclusive(String JavaDoc maxExclusive) {
214         if(maxExclusives == null) {
215             maxExclusives = new ArrayList JavaDoc<String JavaDoc>(1);
216             hasFacets = true;
217         }
218         this.maxExclusives.add(maxExclusive);
219     }
220     
221     /*
222      * set minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
223      *
224      * @param minInclusive
225      */

226     public void addMinInclusive(String JavaDoc minInclusive) {
227         if(minInclusives == null) {
228             minInclusives = new ArrayList JavaDoc<String JavaDoc>(1);
229             hasFacets = true;
230         }
231         this.minInclusives.add(minInclusive);
232     }
233     
234     /*
235      * set minExclusive value (this corresponds to the value of minExclusive facet in schema)
236      *
237      * @param minExclusive
238      */

239     public void addMinExclusive(String JavaDoc minExclusive) {
240         if(minExclusives == null) {
241             minExclusives = new ArrayList JavaDoc<String JavaDoc>(1);
242             hasFacets = true;
243         }
244         this.minExclusives.add(minExclusive);
245     }
246     
247     /*
248      * set pattern value (this corresponds to the value of pattern facet in schema)
249      *
250      * @param pattern
251      */

252     public void removePattern(String JavaDoc pattern) {
253         if(patterns != null)
254             patterns.remove(pattern);
255     }
256     
257     /*
258      * set enumeration values (this corresponds to the values of enumeration facets in schema)
259      *
260      * @param enumeration
261      */

262     public void removeEnumeration(String JavaDoc enumeration) {
263         if(enumerations != null)
264             enumerations.remove(enumeration);
265     }
266     
267     /*
268      * set whitespace value (this corresponds to the value of whitespace facet in schema)
269      *
270      * @param whitespace
271      */

272     public void removeWhitespace(Whitespace.Treatment whitespace) {
273         if(whitespaces != null)
274             whitespaces.remove(whitespace);
275     }
276     
277     /*
278      * set maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
279      *
280      * @param maxInclusive
281      */

282     public void removeMaxInclusive(String JavaDoc maxInclusive) {
283         if(maxInclusives != null)
284             maxInclusives.remove(maxInclusive);
285     }
286     
287     /*
288      * set maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
289      *
290      * @param maxExclusive
291      */

292     public void removeMaxExclusive(String JavaDoc maxExclusive) {
293         if(maxExclusives != null)
294             maxExclusives.remove(maxExclusive);
295     }
296     
297     /*
298      * set minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
299      *
300      * @param minInclusive
301      */

302     public void removeMinInclusive(String JavaDoc minInclusive) {
303         if(minInclusives != null)
304             minInclusives.remove(minInclusive);
305     }
306     
307     /*
308      * set minExclusive value (this corresponds to the value of minExclusive facet in schema)
309      *
310      * @param minExclusive
311      */

312     public void removeMinExclusive(String JavaDoc minExclusive) {
313         if(minExclusives != null)
314             minExclusives.remove(minExclusive);
315     }
316 }
317
Popular Tags