001: package com.quadcap.sql.types;
002:
003: /* Copyright 1999 - 2003 Quadcap Software. All rights reserved.
004: *
005: * This software is distributed under the Quadcap Free Software License.
006: * This software may be used or modified for any purpose, personal or
007: * commercial. Open Source redistributions are permitted. Commercial
008: * redistribution of larger works derived from, or works which bundle
009: * this software requires a "Commercial Redistribution License"; see
010: * http://www.quadcap.com/purchase.
011: *
012: * Redistributions qualify as "Open Source" under one of the following terms:
013: *
014: * Redistributions are made at no charge beyond the reasonable cost of
015: * materials and delivery.
016: *
017: * Redistributions are accompanied by a copy of the Source Code or by an
018: * irrevocable offer to provide a copy of the Source Code for up to three
019: * years at the cost of materials and delivery. Such redistributions
020: * must allow further use, modification, and redistribution of the Source
021: * Code under substantially the same terms as this license.
022: *
023: * Redistributions of source code must retain the copyright notices as they
024: * appear in each source code file, these license terms, and the
025: * disclaimer/limitation of liability set forth as paragraph 6 below.
026: *
027: * Redistributions in binary form must reproduce this Copyright Notice,
028: * these license terms, and the disclaimer/limitation of liability set
029: * forth as paragraph 6 below, in the documentation and/or other materials
030: * provided with the distribution.
031: *
032: * The Software is provided on an "AS IS" basis. No warranty is
033: * provided that the Software is free of defects, or fit for a
034: * particular purpose.
035: *
036: * Limitation of Liability. Quadcap Software shall not be liable
037: * for any damages suffered by the Licensee or any third party resulting
038: * from use of the Software.
039: */
040:
041: import java.io.Externalizable;
042: import java.io.IOException;
043: import java.io.ObjectInput;
044: import java.io.ObjectOutput;
045:
046: /**
047: * The <b>UNKNOWN</b> value.
048: *
049: * @author Stan Bailes
050: */
051: public class ValueUnknown extends Value implements Externalizable {
052: public static final ValueUnknown valueUnknown = new ValueUnknown();
053:
054: public ValueUnknown() {
055: }
056:
057: public Value unop(int op) throws ValueException {
058: switch (op) {
059: case Op.NULL:
060: return ValueBoolean.falseBoolean;
061: case Op.NOT:
062: return this ;
063: default:
064: throw new ValueException("Unary op: " + Op.toString(op)
065: + " not implemented for this type");
066: }
067: }
068:
069: public Value binop(int op, Value l) throws ValueException {
070: return l.binop(op, this );
071: }
072:
073: public Value binop(int op, ValueBlob r) throws ValueException {
074: return this ;
075: }
076:
077: public Value binop(int op, ValueBoolean e) throws ValueException {
078: switch (op) {
079: case Op.AND:
080: if (e.isTrue())
081: return this ;
082: else
083: return new ValueBoolean(false);
084: case Op.OR:
085: if (e.isTrue())
086: return new ValueBoolean(true);
087: else
088: return this ;
089:
090: default:
091: throw new ValueException("op: " + op
092: + " not valid for this type");
093: }
094: }
095:
096: public Value binop(int op, ValueByte r) throws ValueException {
097: return this ;
098: }
099:
100: public Value binop(int op, ValueClob r) throws ValueException {
101: return this ;
102: }
103:
104: public Value binop(int op, ValueDate r) throws ValueException {
105: return this ;
106: }
107:
108: public Value binop(int op, ValueDefault r) throws ValueException {
109: return this ;
110: }
111:
112: public Value binop(int op, ValueDouble r) throws ValueException {
113: return this ;
114: }
115:
116: public Value binop(int op, ValueFloat r) throws ValueException {
117: return this ;
118: }
119:
120: public Value binop(int op, ValueInteger r) throws ValueException {
121: return this ;
122: }
123:
124: public Value binop(int op, ValueInterval r) throws ValueException {
125: return this ;
126: }
127:
128: public Value binop(int op, ValueLong r) throws ValueException {
129: return this ;
130: }
131:
132: public Value binop(int op, ValueNull r) throws ValueException {
133: return this ;
134: }
135:
136: public Value binop(int op, ValueOctets r) throws ValueException {
137: return this ;
138: }
139:
140: public Value binop(int op, ValuePattern r) throws ValueException {
141: return this ;
142: }
143:
144: public Value binop(int op, ValueScaledInteger r)
145: throws ValueException {
146: return this ;
147: }
148:
149: public Value binop(int op, ValueShort r) throws ValueException {
150: return this ;
151: }
152:
153: public Value binop(int op, ValueTime r) throws ValueException {
154: return this ;
155: }
156:
157: public Value binop(int op, ValueTimestamp r) throws ValueException {
158: return this ;
159: }
160:
161: public Value binop(int op, ValueType r) throws ValueException {
162: return this ;
163: }
164:
165: public Value binop(int op, ValueUnknown r) throws ValueException {
166: return this ;
167: }
168:
169: public boolean isTrue() {
170: return false;
171: }
172:
173: public Object asJavaObject() {
174: return null;
175: }
176:
177: public void fromJavaObject(Object obj) throws ValueException {
178: throw new ValueException("bad type: " + obj);
179: }
180:
181: public Value convert(TypeDecimal type) {
182: return ValueNull.valueNull;
183: }
184:
185: public Type getType() {
186: return TypeBinary.typeBinary;
187: }
188:
189: public void readExternal(ObjectInput in) throws IOException {
190: }
191:
192: public void writeExternal(ObjectOutput out) throws IOException {
193: }
194:
195: public void serializeKey(KeyStream out) throws IOException {
196: throw new IOException("can't use 'unknown' as key");
197: }
198:
199: }
|