KickJava   Java API By Example, From Geeks To Geeks.

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


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.Collections JavaDoc;
23 import java.util.List JavaDoc;
24 import org.netbeans.modules.xml.axi.AXIType;
25 import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
26 import org.netbeans.modules.xml.schema.model.*;
27
28 /**
29  * Class represents a datatype in AXI model, contains a reference its peer in
30  * schema ie., a simpleType (either a primitive datatype or a derived type)
31  *
32  * @author Ayub Khan
33  */

34 public abstract class Datatype implements AXIType {
35     
36     public enum Kind {
37         STRING("string"),
38         NORMALIZED_STRING("normalizedString"),
39         TOKEN("token"),
40         LANGUAGE("language"),
41         NAME("Name"),
42         NMTOKEN("NMTOKEN"),
43         NCNAME("NCName"),
44         NMTOKENS("NMTOKENS"),
45         ID("ID"),
46         IDREF("IDREF"),
47         ENTITY("ENTITY"),
48         IDREFS("IDREFS"),
49         ENTITIES("ENTITIES"),
50         DECIMAL("decimal"),
51         INTEGER("integer"),
52         NON_POSITIVE_INTEGER("nonPositiveInteger"),
53         LONG("long"),
54         NON_NEGATIVE_INTEGER("nonNegativeInteger"),
55         NEGATIVE_INTEGER("negativeInteger"),
56         INT("int"),
57         SHORT("short"),
58         BYTE("byte"),
59         UNSIGNED_LONG("unsignedLong"),
60         UNSIGNED_INT("unsignedInt"),
61         UNSIGNED_SHORT("unsignedShort"),
62         UNSIGNED_BYTE("unsignedByte"),
63         POSITIVE_INTEGER("positiveInteger"),
64         DURATION("duration"),
65         DATE_TIME("dateTime"),
66         TIME("time"),
67         DATE("date"),
68         G_YEAR_MONTH("gYearMonth"),
69         G_YEAR("gYear"),
70         G_MONTH_DAY("gMonthDay"),
71         G_DAY("gDay"),
72         G_MONTH("gMonth"),
73         BOOLEAN("boolean"),
74         BASE64_BINARY("base64Binary"),
75         HEX_BINARY("hexBinary"),
76         FLOAT("float"),
77         DOUBLE("double"),
78         ANYURI("anyURI"),
79         ANYTYPE("anyType"),
80         QNAME("QName"),
81         NOTATION("NOTATION"),
82         UNION("UNION");
83         
84         String JavaDoc name;
85         
86         Kind(String JavaDoc name) {
87             this.name = name;
88         }
89         
90         public String JavaDoc getName() {
91             return name;
92         }
93     }
94     
95     public enum Facet {
96         LENGTH("length", Length.class),
97         MINLENGTH("minLength", MinLength.class),
98         MAXLENGTH("maxLength", MaxLength.class),
99         PATTERN("pattern", Pattern.class),
100         ENUMERATION("enumeration", Enumeration.class),
101         WHITESPACE("whiteSpace", Whitespace.class),
102         TOTATDIGITS("totalDigits", TotalDigits.class),
103         FRACTIONDIGITS("fractionDigits", FractionDigits.class),
104         MAXINCLUSIVE("maxInclusive", MaxInclusive.class),
105         MAXEXCLUSIVE("maxExclusive", MaxExclusive.class),
106         MININCLUSIVE("minInclusive", MinInclusive.class),
107         MINEXCLUSIVE("minExclusive", MinExclusive.class);
108         
109         String JavaDoc name;
110         Class JavaDoc<? extends SchemaComponent> type;
111         
112         Facet(String JavaDoc name, Class JavaDoc<? extends SchemaComponent> type) {
113             this.name = name;
114             this.type = type;
115         }
116         
117         public String JavaDoc getName() {
118             return name;
119         }
120         
121         public Class JavaDoc<? extends SchemaComponent> getComponentType() {
122             return type;
123         }
124     }
125     
126     /*
127      * returns the kind of this datatype
128      *
129      * @return qName
130      */

131     public abstract Kind getKind();
132     
133     /*
134      * returns the name of this datatype
135      *
136      * @return name
137      */

138     public String JavaDoc getName() {
139         return getKind().getName();
140     }
141     
142     /**
143      * Allows a visitor to visit this Element.
144      */

145     public void accept(AXIVisitor visitor) {
146         visitor.visit(this);
147     }
148     
149     public abstract List JavaDoc<Facet> getApplicableFacets();
150     
151     public abstract boolean hasFacets();
152     
153     public abstract boolean isList();
154     
155     public abstract void setIsList(boolean b);
156     
157     public boolean isPrimitive() {
158         return !hasFacets() && !(this instanceof UnionType);
159     }
160     
161     /*
162      * returns pattern value (this corresponds to the value of pattern facet in schema)
163      *
164      * @return pattern
165      */

166     public List JavaDoc<? extends String JavaDoc> getPatterns() {
167         return Collections.emptyList();
168     }
169     
170     /*
171      * returns enumeration values (this corresponds to the values of enumeration facets in schema)
172      *
173      * @return enumeration
174      */

175     public List JavaDoc<? extends Object JavaDoc> getEnumerations() {
176         return Collections.emptyList();
177     }
178     
179     /*
180      * returns whitespace value (this corresponds to the value of whitespace facet in schema)
181      *
182      * @return whitespaces
183      */

184     public List JavaDoc<Whitespace.Treatment> getWhiteSpaces() {
185         return Collections.emptyList();
186     }
187     
188     /*
189      * returns total digits value (this corresponds to the value of totalDigits facet in schema)
190      *
191      * @return totalDigits
192      */

193     public List JavaDoc<? extends Number JavaDoc> getTotalDigits() {
194         return Collections.emptyList();
195     }
196     
197     /*
198      * returns fraction digits value (this corresponds to the value of fractionDigits facet in schema)
199      *
200      * @return fractionDigits
201      */

202     public List JavaDoc<? extends Number JavaDoc> getFractionDigits() {
203         return Collections.emptyList();
204     }
205     
206     /*
207      * returns maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
208      *
209      * @return maxInclusive
210      */

211     public List JavaDoc<? extends Object JavaDoc> getMaxInclusives() {
212         return Collections.emptyList();
213     }
214     
215     /*
216      * returns maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
217      *
218      * @return maxExclusive
219      */

220     public List JavaDoc<? extends Object JavaDoc> getMaxExclusives() {
221         return Collections.emptyList();
222     }
223     
224     /*
225      * returns minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
226      *
227      * @return minInclusive
228      */

229     public List JavaDoc<? extends Object JavaDoc> getMinInclusives() {
230         return Collections.emptyList();
231     }
232     
233     /*
234      * returns minExclusive value (this corresponds to the value of minExclusive facet in schema)
235      *
236      * @return minExclusive
237      */

238     public List JavaDoc<? extends Object JavaDoc> getMinExclusives() {
239         return Collections.emptyList();
240     }
241     
242     /*
243      * returns length (this corresponds to the value of length facet in schema)
244      *
245      * @return length
246      */

247     public List JavaDoc<? extends Number JavaDoc> getLengths() {
248         return Collections.emptyList();
249     }
250     
251     /*
252      * returns minimum length value (this corresponds to the value of minlength facet in schema)
253      *
254      * @return minLength
255      */

256     public List JavaDoc<? extends Number JavaDoc> getMinLengths() {
257         return Collections.emptyList();
258     }
259     
260     /*
261      * returns maximum length value (this corresponds to the value of maxlength facet in schema)
262      *
263      * @return maxLength
264      */

265     public List JavaDoc<? extends Number JavaDoc> getMaxLengths() {
266         return Collections.emptyList();
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 addPattern(String JavaDoc pattern) {
275     }
276     
277     /*
278      * set enumeration values (this corresponds to the values of enumeration facets in schema)
279      *
280      * @param enumeration
281      */

282     public void addEnumeration(Object JavaDoc enumeration) {
283     }
284     
285     /*
286      * set whitespace value (this corresponds to the value of whitespace facet in schema)
287      *
288      * @param whitespace
289      */

290     public void addWhitespace(Whitespace.Treatment whitespace) {
291     }
292     
293     /*
294      * set total digits value (this corresponds to the value of totalDigits facet in schema)
295      *
296      * @param totalDigits
297      */

298     public void addTotalDigits(int totalDigits ) {
299     }
300     
301     /*
302      * set fraction digits value (this corresponds to the value of fractionDigits facet in schema)
303      *
304      * @param fractionDigits
305      */

306     public void addFractionDigits(int fractionDigits) {
307     }
308     
309     /*
310      * set maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
311      *
312      * @param maxInclusive
313      */

314     public void addMaxInclusive(Object JavaDoc maxInclusive) {
315     }
316     
317     /*
318      * set maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
319      *
320      * @param maxExclusive
321      */

322     public void addMaxExclusive(Object JavaDoc maxExclusive) {
323     }
324     
325     /*
326      * set minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
327      *
328      * @param minInclusive
329      */

330     public void addMinInclusive(Object JavaDoc minInclusive) {
331     }
332     
333     /*
334      * set minExclusive value (this corresponds to the value of minExclusive facet in schema)
335      *
336      * @param minExclusive
337      */

338     public void addMinExclusive(Object JavaDoc minExclusive) {
339     }
340     
341     /*
342      * set length (this corresponds to the value of length facet in schema)
343      *
344      * @param length
345      */

346     public void addLength(int length) {
347     }
348     
349     /*
350      * set minimum length value (this corresponds to the value of minlength facet in schema)
351      *
352      * @param minLength
353      */

354     public void addMinLength(int minLength) {
355     }
356     
357     /*
358      * set maximum length value (this corresponds to the value of maxlength facet in schema)
359      *
360      * @param maxLength
361      */

362     public void addMaxLength(int maxLength) {
363     }
364     
365     /*
366      * remove pattern value (this corresponds to the value of pattern facet in schema)
367      *
368      * @param pattern
369      */

370     public void removePattern(String JavaDoc pattern) {
371     }
372     
373     /*
374      * remove enumeration values (this corresponds to the values of enumeration facets in schema)
375      *
376      * @param enumeration
377      */

378     public void removeEnumeration(Object JavaDoc enumeration) {
379     }
380     
381     /*
382      * remove whitespace value (this corresponds to the value of whitespace facet in schema)
383      *
384      * @param whitespace
385      */

386     public void removeWhitespace(Whitespace.Treatment whitespace) {
387     }
388     
389     /*
390      * remove total digits value (this corresponds to the value of totalDigits facet in schema)
391      *
392      * @param totalDigits
393      */

394     public void removeTotalDigits(Number JavaDoc totalDigits ) {
395     }
396     
397     /*
398      * remove fraction digits value (this corresponds to the value of fractionDigits facet in schema)
399      *
400      * @param fractionDigits
401      */

402     public void removeFractionDigits(Number JavaDoc fractionDigits) {
403     }
404     
405     /*
406      * remove maximum Inclusive value (this corresponds to the value of maxInclusive facet in schema)
407      *
408      * @param maxInclusive
409      */

410     public void removeMaxInclusive(Object JavaDoc maxInclusive) {
411     }
412     
413     /*
414      * remove maximum Exclusive value (this corresponds to the value of maxExclusive facet in schema)
415      *
416      * @param maxExclusive
417      */

418     public void removeMaxExclusive(Object JavaDoc maxExclusive) {
419     }
420     
421     /*
422      * remove minimum Inclusive value (this corresponds to the value of minInclusive facet in schema)
423      *
424      * @param minInclusive
425      */

426     public void removeMinInclusive(Object JavaDoc minInclusive) {
427     }
428     
429     /*
430      * remove minExclusive value (this corresponds to the value of minExclusive facet in schema)
431      *
432      * @param minExclusive
433      */

434     public void removeMinExclusive(Object JavaDoc minExclusive) {
435     }
436     
437     /*
438      * remove length (this corresponds to the value of length facet in schema)
439      *
440      * @param length
441      */

442     public void removeLength(Number JavaDoc length) {
443     }
444     
445     /*
446      * remove minimum length value (this corresponds to the value of minlength facet in schema)
447      *
448      * @param minLength
449      */

450     public void removeMinLength(Number JavaDoc minLength) {
451     }
452     
453     /*
454      * remove maximum length value (this corresponds to the value of maxlength facet in schema)
455      *
456      * @param maxLength
457      */

458     public void removeMaxLength(Number JavaDoc maxLength) {
459     }
460     
461     public String JavaDoc toString() {
462         return getName();
463     }
464 }
465
Popular Tags