org.ujac.util.exi.type
Class BaseType

java.lang.Object
  extended by org.ujac.util.exi.type.BaseType
All Implemented Interfaces:
ExpressionType
Direct Known Subclasses:
BaseDateType, BaseNumberType, BooleanType, ByteArrayType, CharArrayType, CharType, CollectionType, ConditionResultHolderType, DefaultType, DoubleArrayType, FloatArrayType, IntArrayType, LongArrayType, MapEntryType, MapType, NullValueType, ObjectArrayType, ResourceBundleType, RowType, ShortArrayType, StringType, TableType

public abstract class BaseType
extends Object
implements ExpressionType

Name: BaseType
Description: A base implementation for expression type handlers.

Author:
lauerc

Nested Class Summary
 class BaseType.EqualOperation
          The equal compare operation.
 class BaseType.InstanceofOperation
          The 'instanceof' operation.
 class BaseType.NotEqualOperation
          The 'not equal' compare operation.
 class BaseType.ObjectDefinedOperation
          Checks the existance of the given object.
 class BaseType.ObjectNotDefinedOperation
          Checks the existance of the given object.
 class BaseType.ToStringOperation
          Determines the textual representation of the given object.
 
Field Summary
protected  ExpressionInterpreter interpreter
          The expression interpreter.
protected  Map operations
          The operation map.
 
Constructor Summary
BaseType(ExpressionInterpreter interpreter)
          Constructs a BaseType instace with specific attributes.
 
Method Summary
 void addOperation(String name, ExpressionOperation operation)
          Adds an operation.
 Object evalTuple(ExpressionTuple expr, ExpressionContext ctx)
          Evaluates the given expression tuple.
protected  String execToString(ExpressionTuple expr, FormatHelper formatHelper)
          Executes the toString operation.
 String getAlias()
          Gets the alias of the expression type.
 String getDescription()
          Gets a description for the operation.
 ExpressionOperation getOperation(Operation operation)
          Gets the operation implementation that matches the given operation.
 Set getOperationNames()
          Gets all registered operation names.
 Map getOperations()
          Gets all registered operations.
 String getTypeName()
          Gets the type name of the expression type.
 void removeAllOperations()
          Removes all operations.
 void removeOperation(String name)
          Removes an operation.
 Object typeCast(Object value)
          Casts the given value into the handler-specific type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ujac.util.exi.ExpressionType
getType
 

Field Detail

interpreter

protected ExpressionInterpreter interpreter
The expression interpreter.


operations

protected Map operations
The operation map.

Constructor Detail

BaseType

public BaseType(ExpressionInterpreter interpreter)
Constructs a BaseType instace with specific attributes.

Parameters:
interpreter - The expression interpreter.
Method Detail

execToString

protected String execToString(ExpressionTuple expr,
                              FormatHelper formatHelper)
Executes the toString operation.

Parameters:
expr - The expression, holding the object to get as string.
formatHelper - The format helper to use.
Returns:
The textual representation of the expression value.

getOperation

public ExpressionOperation getOperation(Operation operation)
Description copied from interface: ExpressionType
Gets the operation implementation that matches the given operation.

Specified by:
getOperation in interface ExpressionType
Parameters:
operation - gets the expression operation for the given operation definition.
Returns:
The operation object if a operation for this name is defined else null.
See Also:
ExpressionType.getOperation(org.ujac.util.exi.Operation)

getOperationNames

public Set getOperationNames()
Gets all registered operation names.

Specified by:
getOperationNames in interface ExpressionType
Returns:
The names of the operations, registerd with this type handler.

getOperations

public Map getOperations()
Gets all registered operations.

Specified by:
getOperations in interface ExpressionType
Returns:
The operations, registerd with this type handler.

addOperation

public void addOperation(String name,
                         ExpressionOperation operation)
Adds an operation.

Parameters:
name - The name of the operation.
operation - The operation.

removeOperation

public void removeOperation(String name)
Removes an operation.

Parameters:
name - The name of the operation.

removeAllOperations

public void removeAllOperations()
Removes all operations.


evalTuple

public Object evalTuple(ExpressionTuple expr,
                        ExpressionContext ctx)
                 throws ExpressionException
Evaluates the given expression tuple.

Specified by:
evalTuple in interface ExpressionType
Parameters:
expr - The expression tuple to evaluate.
ctx - The expression context.
Returns:
The result of the tuple evaluation.
Throws:
ExpressionException - If the evaluation failed.

getTypeName

public String getTypeName()
Gets the type name of the expression type.

Specified by:
getTypeName in interface ExpressionType
Returns:
The name of the class the expression type is valid for.

getAlias

public String getAlias()
Gets the alias of the expression type.

Specified by:
getAlias in interface ExpressionType
Returns:
The type alias.

getDescription

public String getDescription()
Gets a description for the operation.

Specified by:
getDescription in interface ExpressionType
Returns:
The item's description.

typeCast

public Object typeCast(Object value)
                throws TypeCastException
Casts the given value into the handler-specific type.

Specified by:
typeCast in interface ExpressionType
Parameters:
value - The value to cast.
Returns:
The transformed value.
Throws:
TypeCastException - In case the type cast failed.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.