OSDN Git Service

Set optimal mime types and executable settings.
[mikumikustudio/MikuMikuStudio.git] / src / com / jmex / xml / types / SchemaBoolean.java
1 /**
2  * SchemaBoolean.java
3  *
4  * This file was generated by XMLSpy 2007sp2 Enterprise Edition.
5  *
6  * YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
7  * OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
8  *
9  * Refer to the XMLSpy Documentation for further details.
10  * http://www.altova.com/xmlspy
11  */
12
13
14 package com.jmex.xml.types;
15
16 import java.math.BigDecimal;
17 import java.math.BigInteger;
18
19 public class SchemaBoolean implements SchemaTypeNumber {
20   protected boolean value;
21   protected boolean isempty;
22   protected boolean isnull;
23
24   // construction
25   public SchemaBoolean() {
26     setEmpty();
27   }
28
29   public SchemaBoolean(SchemaBoolean newvalue) {
30     value = newvalue.value;
31     isempty = newvalue.isempty;
32     isnull = newvalue.isnull;
33   }
34
35   public SchemaBoolean(boolean newvalue) {
36     setValue( newvalue );
37   }
38
39   public SchemaBoolean(String newvalue) {
40     parse( newvalue );
41   }
42
43   public SchemaBoolean(SchemaType newvalue) {
44     assign( newvalue );
45   }
46
47   public SchemaBoolean(SchemaTypeNumber newvalue) {
48     assign( (SchemaType)newvalue );
49   }
50
51   // getValue, setValue
52   public boolean getValue() {
53     return value;
54   }
55
56   public void setValue(boolean newvalue) {
57     isnull = false;
58     isempty = false;
59     value = newvalue;
60   }
61
62  public void parse(String s) {
63           
64         String newvalue = SchemaNormalizedString.normalize(SchemaNormalizedString.WHITESPACE_COLLAPSE, s);
65
66     if( newvalue == null )
67       setNull();
68     else if( newvalue.length() == 0)
69       setEmpty();
70     else
71       setValue( new SchemaString(newvalue).booleanValue() );
72   }
73
74   public void assign(SchemaType newvalue) {
75     if( newvalue == null || newvalue.isNull() )
76       setNull();
77     else if( newvalue.isEmpty() )
78       setEmpty();
79     else
80       parse( newvalue.toString() );
81   }
82
83   public void setNull() {
84     isnull = true;
85     isempty = true;
86     value = false;
87   }
88
89   public void setEmpty() {
90     isnull = false;
91     isempty = true;
92     value = false;
93   }
94
95   // further
96   public int hashCode() {
97     return value ? 1231 : 1237;
98   }
99
100   public boolean equals(Object obj) {
101     if (! (obj instanceof SchemaBoolean))
102       return false;
103     return value == ( (SchemaBoolean) obj).value;
104   }
105
106   public Object clone() {
107     return new SchemaBoolean(this);
108   }
109
110   public String toString() {
111     if( isempty || isnull )
112       return "";
113     return value ? "true" : "false"; // when converting to an string-value, than XML-Schema would expect "" for false.
114   }
115
116   public int length() {
117     return 1;   // length of the number (0 or 1)
118   }
119
120   public boolean booleanValue() {
121     return value;
122   }
123
124   public boolean isEmpty() {
125     return isempty;
126   }
127
128   public boolean isNull() {
129     return isnull;
130   }
131
132   public int compareTo(Object obj) {
133     return compareTo( (SchemaBoolean) obj);
134   }
135
136   public int compareTo(SchemaBoolean obj) {
137     if (value == obj.value)
138       return 0;
139     else if (value == false)
140       return -1;
141     else
142       return 1;
143   }
144
145   // interface SchemaTypeNumber
146   public int numericType() {
147     return NUMERIC_VALUE_INT;
148   }
149
150   public void setValue(int newvalue) {
151     isnull = false;
152     isempty = false;
153     value = ! (newvalue == 0);
154   }
155
156   public void setValue(long newvalue) {
157     isnull = false;
158     isempty = false;
159     value = ! (newvalue == 0);
160   }
161
162   public void setValue(BigInteger newvalue) {
163     isnull = false;
164     isempty = false;
165     value = newvalue.compareTo(BigInteger.valueOf(0)) != 0;
166   }
167
168   public void setValue(float newvalue) {
169     isnull = false;
170     isempty = false;
171     value = ! (newvalue == 0);
172   }
173
174   public void setValue(double newvalue) {
175     isnull = false;
176     isempty = false;
177     value = ! (newvalue == 0);
178   }
179
180   public void setValue(BigDecimal newvalue) {
181     isnull = false;
182     isempty = false;
183     value = newvalue.compareTo(BigDecimal.valueOf(0)) != 0;
184   }
185
186   public int intValue() {
187     if (value)
188       return 1;
189     return 0;
190   }
191
192   public long longValue() {
193     if (value)
194       return 1L;
195     return 0L;
196   }
197
198   public BigInteger bigIntegerValue() {
199     if (value)
200       return BigInteger.valueOf(1L);
201     return BigInteger.valueOf(0L);
202   }
203
204   public float floatValue() {
205     if (value)
206       return 1;
207     return 0;
208   }
209
210   public double doubleValue() {
211     if (value)
212       return 1.0;
213     return 0.0;
214   }
215
216   public BigDecimal bigDecimalValue() {
217     if (value)
218       return BigDecimal.valueOf(1L);
219     return BigDecimal.valueOf(0L);
220   }
221 }