001: package com.quadcap.sql;
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: import java.sql.SQLException;
047:
048: import com.quadcap.sql.types.Type;
049: import com.quadcap.sql.types.Value;
050:
051: /**
052: * Expression yielding a constant value.
053: *
054: * @author Stan Bailes
055: */
056: public class ValueExpression extends Expression implements
057: Externalizable {
058: Value value;
059:
060: public ValueExpression() {
061: }
062:
063: public ValueExpression(Value value) {
064: this .value = value;
065: }
066:
067: public int rank() {
068: return 0;
069: }
070:
071: public Value getValue(Session session, Cursor cursor) {
072: return value;
073: }
074:
075: public Type getType(Session session, Cursor cursor)
076: throws SQLException {
077: return value.getType();
078: }
079:
080: public void invert() {
081: throw new RuntimeException(
082: "invert not implemented for ValueExpression");
083: }
084:
085: public void visitSubExpressions(ExpressionVisitor ev) {
086: }
087:
088: public void readExternal(ObjectInput in) throws IOException,
089: ClassNotFoundException {
090: value = (Value) in.readObject();
091: }
092:
093: public void writeExternal(ObjectOutput out) throws IOException {
094: out.writeObject(value);
095: }
096:
097: public String toString() {
098: if (value == null) {
099: return "<null>";
100: } else {
101: return value.toString();
102: }
103: }
104: }
|