1 package com.quadcap.sql; 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 import java.sql.SQLException ; 47 48 import com.quadcap.sql.types.Type; 49 import com.quadcap.sql.types.Value; 50 51 56 public class ValueExpression extends Expression implements Externalizable { 57 Value value; 58 59 public ValueExpression() {} 60 61 public ValueExpression(Value value) { 62 this.value = value; 63 } 64 65 public int rank() { return 0; } 66 public Value getValue(Session session, Cursor cursor) { return value; } 67 public Type getType(Session session, Cursor cursor) throws SQLException { 68 return value.getType(); 69 } 70 71 public void invert() { 72 throw new RuntimeException ( 73 "invert not implemented for ValueExpression"); 74 } 75 76 public void visitSubExpressions(ExpressionVisitor ev) { 77 } 78 79 public void readExternal(ObjectInput in) 80 throws IOException , ClassNotFoundException 81 { 82 value = (Value)in.readObject(); 83 } 84 85 public void writeExternal(ObjectOutput out) throws IOException { 86 out.writeObject(value); 87 } 88 89 public String toString() { 90 if (value == null) { 91 return "<null>"; 92 } else { 93 return value.toString(); 94 } 95 } 96 } 97 | Popular Tags |