simpledb.query
Class ConstantExpression

java.lang.Object
  extended by simpledb.query.ConstantExpression
All Implemented Interfaces:
Expression

public class ConstantExpression
extends Object
implements Expression

An expression consisting entirely of a single constant.

Author:
Edward Sciore

Constructor Summary
ConstantExpression(Constant c)
          Creates a new expression by wrapping a constant.
 
Method Summary
 boolean appliesTo(Schema sch)
          Returns true, because a constant applies to any schema.
 Constant asConstant()
          Unwraps the constant and returns it.
 String asFieldName()
          This method should never be called.
 Constant evaluate(Scan s)
          Returns the constant, regardless of the scan.
 boolean isConstant()
          Returns true.
 boolean isFieldName()
          Returns false.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantExpression

public ConstantExpression(Constant c)
Creates a new expression by wrapping a constant.

Parameters:
c - the constant
Method Detail

isConstant

public boolean isConstant()
Returns true.

Specified by:
isConstant in interface Expression
Returns:
true if the expression is a constant
See Also:
Expression.isConstant()

isFieldName

public boolean isFieldName()
Returns false.

Specified by:
isFieldName in interface Expression
Returns:
true if the expression denotes a field
See Also:
Expression.isFieldName()

asConstant

public Constant asConstant()
Unwraps the constant and returns it.

Specified by:
asConstant in interface Expression
Returns:
the expression as a constant
See Also:
Expression.asConstant()

asFieldName

public String asFieldName()
This method should never be called. Throws a ClassCastException.

Specified by:
asFieldName in interface Expression
Returns:
the expression as a field name
See Also:
Expression.asFieldName()

evaluate

public Constant evaluate(Scan s)
Returns the constant, regardless of the scan.

Specified by:
evaluate in interface Expression
Parameters:
s - the scan
Returns:
the value of the expression, as a Constant
See Also:
Expression.evaluate(simpledb.query.Scan)

appliesTo

public boolean appliesTo(Schema sch)
Returns true, because a constant applies to any schema.

Specified by:
appliesTo in interface Expression
Parameters:
sch - the schema
Returns:
true if all fields in the expression are in the schema
See Also:
Expression.appliesTo(simpledb.record.Schema)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.