4 * This file was generated by XMLSpy 2007sp2 Enterprise Edition.
6 * YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
7 * OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
9 * Refer to the XMLSpy Documentation for further details.
10 * http://www.altova.com/xmlspy
14 package com.jmex.xml.types;
16 import java.math.BigDecimal;
17 import java.math.BigInteger;
19 public class SchemaBoolean implements SchemaTypeNumber {
20 protected boolean value;
21 protected boolean isempty;
22 protected boolean isnull;
25 public SchemaBoolean() {
29 public SchemaBoolean(SchemaBoolean newvalue) {
30 value = newvalue.value;
31 isempty = newvalue.isempty;
32 isnull = newvalue.isnull;
35 public SchemaBoolean(boolean newvalue) {
39 public SchemaBoolean(String newvalue) {
43 public SchemaBoolean(SchemaType newvalue) {
47 public SchemaBoolean(SchemaTypeNumber newvalue) {
48 assign( (SchemaType)newvalue );
52 public boolean getValue() {
56 public void setValue(boolean newvalue) {
62 public void parse(String s) {
64 String newvalue = SchemaNormalizedString.normalize(SchemaNormalizedString.WHITESPACE_COLLAPSE, s);
66 if( newvalue == null )
68 else if( newvalue.length() == 0)
71 setValue( new SchemaString(newvalue).booleanValue() );
74 public void assign(SchemaType newvalue) {
75 if( newvalue == null || newvalue.isNull() )
77 else if( newvalue.isEmpty() )
80 parse( newvalue.toString() );
83 public void setNull() {
89 public void setEmpty() {
96 public int hashCode() {
97 return value ? 1231 : 1237;
100 public boolean equals(Object obj) {
101 if (! (obj instanceof SchemaBoolean))
103 return value == ( (SchemaBoolean) obj).value;
106 public Object clone() {
107 return new SchemaBoolean(this);
110 public String toString() {
111 if( isempty || isnull )
113 return value ? "true" : "false"; // when converting to an string-value, than XML-Schema would expect "" for false.
116 public int length() {
117 return 1; // length of the number (0 or 1)
120 public boolean booleanValue() {
124 public boolean isEmpty() {
128 public boolean isNull() {
132 public int compareTo(Object obj) {
133 return compareTo( (SchemaBoolean) obj);
136 public int compareTo(SchemaBoolean obj) {
137 if (value == obj.value)
139 else if (value == false)
145 // interface SchemaTypeNumber
146 public int numericType() {
147 return NUMERIC_VALUE_INT;
150 public void setValue(int newvalue) {
153 value = ! (newvalue == 0);
156 public void setValue(long newvalue) {
159 value = ! (newvalue == 0);
162 public void setValue(BigInteger newvalue) {
165 value = newvalue.compareTo(BigInteger.valueOf(0)) != 0;
168 public void setValue(float newvalue) {
171 value = ! (newvalue == 0);
174 public void setValue(double newvalue) {
177 value = ! (newvalue == 0);
180 public void setValue(BigDecimal newvalue) {
183 value = newvalue.compareTo(BigDecimal.valueOf(0)) != 0;
186 public int intValue() {
192 public long longValue() {
198 public BigInteger bigIntegerValue() {
200 return BigInteger.valueOf(1L);
201 return BigInteger.valueOf(0L);
204 public float floatValue() {
210 public double doubleValue() {
216 public BigDecimal bigDecimalValue() {
218 return BigDecimal.valueOf(1L);
219 return BigDecimal.valueOf(0L);