KickJava   Java API By Example, From Geeks To Geeks.

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


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 BooleanType. This is one of those atomic types that can
30  * be used to type an Attribute or leaf Elements in AXI Model
31  *
32  *
33  *
34  * @author Ayub Khan
35  */

36 public class BooleanType extends Datatype {
37     
38     static List JavaDoc<Facet> applicableFacets;
39     
40     private Datatype.Kind kind;
41     
42     protected boolean hasFacets;
43     
44     private boolean isList;
45     
46     private List JavaDoc<String JavaDoc> patterns;
47     
48     private List JavaDoc<Whitespace.Treatment> whitespaces;
49     
50     /**
51      * Creates a new instance of BooleanType
52      */

53     public BooleanType() {
54         this.kind = Datatype.Kind.BOOLEAN;
55     }
56     
57     public Kind getKind() {
58         return kind;
59     }
60     
61     public List JavaDoc<Facet> getApplicableFacets() {
62         if(applicableFacets == null) {
63             List JavaDoc<Facet> facets = new ArrayList JavaDoc<Facet>();
64             facets.add(Facet.PATTERN);
65             facets.add(Facet.WHITESPACE);
66             applicableFacets = Collections.unmodifiableList(facets);
67         }
68         return applicableFacets;
69     }
70     
71     public boolean hasFacets() {
72         return hasFacets;
73     }
74     
75     public boolean isList() {
76         return isList;
77     }
78     
79     public void setIsList(boolean isList) {
80         this.isList = isList;
81     }
82     
83     /*
84      * returns pattern value (this corresponds to the value of pattern facet in schema)
85      *
86      * @return pattern
87      */

88     public List JavaDoc<String JavaDoc> getPatterns() {
89         return patterns;
90     }
91     
92     /*
93      * returns whitespace value (this corresponds to the value of whitespace facet in schema)
94      *
95      * @return whitespaces
96      */

97     public List JavaDoc<Whitespace.Treatment> getWhiteSpaces() {
98         return whitespaces;
99     }
100     
101     /*
102      * set pattern value (this corresponds to the value of pattern facet in schema)
103      *
104      * @param pattern
105      */

106     public void addPattern(String JavaDoc pattern) {
107         if(patterns == null) {
108             patterns = new ArrayList JavaDoc<String JavaDoc>(1);
109             hasFacets = true;
110         }
111         this.patterns.add(pattern);
112     }
113     
114     /*
115      * set whitespace value (this corresponds to the value of whitespace facet in schema)
116      *
117      * @param whitespace
118      */

119     public void addWhitespace(Whitespace.Treatment whitespace) {
120         if(whitespaces == null) {
121             whitespaces = new ArrayList JavaDoc<Whitespace.Treatment>(1);
122             hasFacets = true;
123         }
124         this.whitespaces.add(whitespace);
125     }
126 }
127
Popular Tags