simpledb.query
Class FieldNameExpression

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

public class FieldNameExpression
extends Object
implements Expression

An expression consisting entirely of a single field.

Author:
Edward Sciore

Constructor Summary
FieldNameExpression(String fldname)
          Creates a new expression by wrapping a field.
 
Method Summary
 boolean appliesTo(Schema sch)
          Returns true if the field is in the specified schema.
 Constant asConstant()
          This method should never be called.
 String asFieldName()
          Unwraps the field name and returns it.
 Constant evaluate(Scan s)
          Evaluates the field by getting its value in the scan.
 boolean isConstant()
          Returns false.
 boolean isFieldName()
          Returns true.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldNameExpression

public FieldNameExpression(String fldname)
Creates a new expression by wrapping a field.

Parameters:
fldname - the name of the wrapped field
Method Detail

isConstant

public boolean isConstant()
Returns false.

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

isFieldName

public boolean isFieldName()
Returns true.

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

asConstant

public Constant asConstant()
This method should never be called. Throws a ClassCastException.

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

asFieldName

public String asFieldName()
Unwraps the field name and returns it.

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

evaluate

public Constant evaluate(Scan s)
Evaluates the field by getting its value in 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 if the field is in the specified 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.