1 package com.quadcap.sql.types; 2 3 40 41 import java.io.Externalizable ; 42 import java.io.IOException ; 43 import java.io.ObjectInput ; 44 import java.io.ObjectOutput ; 45 46 51 public class ValueUnknown extends Value implements Externalizable { 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 asJavaObject() { 168 return null; 169 } 170 171 public void fromJavaObject(Object 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 in) throws IOException { 184 } 185 186 public void writeExternal(ObjectOutput out) 187 throws IOException 188 { 189 } 190 191 public void serializeKey(KeyStream out) throws IOException { 192 throw new IOException ("can't use 'unknown' as key"); 193 } 194 195 } 196 | Popular Tags |