KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quadcap > sql > types > ValueUnknown


1 package com.quadcap.sql.types;
2
3 /* Copyright 1999 - 2003 Quadcap Software. All rights reserved.
4  *
5  * This software is distributed under the Quadcap Free Software License.
6  * This software may be used or modified for any purpose, personal or
7  * commercial. Open Source redistributions are permitted. Commercial
8  * redistribution of larger works derived from, or works which bundle
9  * this software requires a "Commercial Redistribution License"; see
10  * http://www.quadcap.com/purchase.
11  *
12  * Redistributions qualify as "Open Source" under one of the following terms:
13  *
14  * Redistributions are made at no charge beyond the reasonable cost of
15  * materials and delivery.
16  *
17  * Redistributions are accompanied by a copy of the Source Code or by an
18  * irrevocable offer to provide a copy of the Source Code for up to three
19  * years at the cost of materials and delivery. Such redistributions
20  * must allow further use, modification, and redistribution of the Source
21  * Code under substantially the same terms as this license.
22  *
23  * Redistributions of source code must retain the copyright notices as they
24  * appear in each source code file, these license terms, and the
25  * disclaimer/limitation of liability set forth as paragraph 6 below.
26  *
27  * Redistributions in binary form must reproduce this Copyright Notice,
28  * these license terms, and the disclaimer/limitation of liability set
29  * forth as paragraph 6 below, in the documentation and/or other materials
30  * provided with the distribution.
31  *
32  * The Software is provided on an "AS IS" basis. No warranty is
33  * provided that the Software is free of defects, or fit for a
34  * particular purpose.
35  *
36  * Limitation of Liability. Quadcap Software shall not be liable
37  * for any damages suffered by the Licensee or any third party resulting
38  * from use of the Software.
39  */

40
41 import java.io.Externalizable JavaDoc;
42 import java.io.IOException JavaDoc;
43 import java.io.ObjectInput JavaDoc;
44 import java.io.ObjectOutput JavaDoc;
45
46 /**
47  * The <b>UNKNOWN</b> value.
48  *
49  * @author Stan Bailes
50  */

51 public class ValueUnknown extends Value implements Externalizable JavaDoc {
52     public static final ValueUnknown valueUnknown
53     = new ValueUnknown();
54     
55     public ValueUnknown() {}
56
57     public Value unop(int op) throws ValueException {
58     switch (op) {
59     case Op.NULL:
60         return ValueBoolean.falseBoolean;
61     case Op.NOT:
62         return this;
63     default:
64         throw new ValueException("Unary op: " + Op.toString(op) +
65                      " not implemented for this type");
66     }
67     }
68     
69     public Value binop(int op, Value l) throws ValueException {
70     return l.binop(op, this);
71     }
72
73     public Value binop(int op, ValueBlob r) throws ValueException {
74     return this;
75     }
76
77     public Value binop(int op, ValueBoolean e)
78     throws ValueException
79     {
80     switch (op) {
81         case Op.AND:
82         if (e.isTrue()) return this;
83         else return new ValueBoolean(false);
84         case Op.OR:
85         if (e.isTrue()) return new ValueBoolean(true);
86         else return this;
87
88     default:
89         throw new ValueException("op: " + op + " not valid for this type");
90     }
91     }
92
93     public Value binop(int op, ValueByte r) throws ValueException {
94     return this;
95     }
96
97     public Value binop(int op, ValueClob r) throws ValueException {
98     return this;
99     }
100
101     public Value binop(int op, ValueDate r) throws ValueException {
102     return this;
103     }
104
105     public Value binop(int op, ValueDefault r) throws ValueException {
106     return this;
107     }
108
109     public Value binop(int op, ValueDouble r) throws ValueException {
110     return this;
111     }
112
113     public Value binop(int op, ValueFloat r) throws ValueException {
114     return this;
115     }
116
117     public Value binop(int op, ValueInteger r) throws ValueException {
118     return this;
119     }
120
121     public Value binop(int op, ValueInterval r) throws ValueException {
122     return this;
123     }
124
125     public Value binop(int op, ValueLong r) throws ValueException {
126     return this;
127     }
128
129     public Value binop(int op, ValueNull r) throws ValueException {
130     return this;
131     }
132
133     public Value binop(int op, ValueOctets r) throws ValueException {
134     return this;
135     }
136
137     public Value binop(int op, ValuePattern r) throws ValueException {
138     return this;
139     }
140
141     public Value binop(int op, ValueScaledInteger r) throws ValueException {
142     return this;
143     }
144
145     public Value binop(int op, ValueShort r) throws ValueException {
146     return this;
147     }
148
149     public Value binop(int op, ValueTime r) throws ValueException {
150     return this;
151     }
152
153     public Value binop(int op, ValueTimestamp r) throws ValueException {
154     return this;
155     }
156
157     public Value binop(int op, ValueType r) throws ValueException {
158     return this;
159     }
160
161     public Value binop(int op, ValueUnknown r) throws ValueException {
162     return this;
163     }
164
165     public boolean isTrue() { return false; }
166
167     public Object JavaDoc asJavaObject() {
168     return null;
169     }
170
171     public void fromJavaObject(Object JavaDoc obj) throws ValueException {
172     throw new ValueException("bad type: " + obj);
173     }
174
175     public Value convert(TypeDecimal type) {
176     return ValueNull.valueNull;
177     }
178
179     public Type getType() {
180     return TypeBinary.typeBinary;
181     }
182
183     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc {
184     }
185     
186     public void writeExternal(ObjectOutput JavaDoc out)
187     throws IOException JavaDoc
188     {
189     }
190
191     public void serializeKey(KeyStream out) throws IOException JavaDoc {
192     throw new IOException JavaDoc("can't use 'unknown' as key");
193     }
194
195 }
196
Popular Tags