http://www.eteks.com

com.eteks.parser
Interface ExpressionParameter

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
JeksParameter

public interface ExpressionParameter
extends java.io.Serializable

Parameters supported in parsed expressions. Classes implementing this interface are used by the compileExpression () method of the ExpressionParser class to check the parameters of an expression at parsing time and is used by the computeExpression () method of the ExpressionParameterNode class to get the value of each parameter at runtime.
For each lexical accepted as a correct identifier by the isValidIdentifier () method of the syntax of a parser, the getParameterKey () method is called to check if the identifier is supported as a parameter in an expression. This method returns either null if it doesn't accept the parameter as a valid one, or a key matching the parameter. This key (that may be the identifier itself) is passed to the getParameterValue () method at runtime to get the value of the matching parameter.
For example, the JeksParameter class implements this interface to check if an identifier is a valid cell of a table and to return the value of that cell. The schema of this class looks like :

 public class JeksParameter implements ExpressionParameter
 {
   // private data

   // constructor

   public Object getParameterKey (String parameter)
   {
     // if parameter is a cell (A1, a$2,...)
     //   return an instance of JeksCell as parameter key

     // else if parameter is a set of cells (C3:D4, $A1:$A5,...)
     //   return an instance of JeksCellSet as parameter key

     // else return null;
   }

   public Object getParameterValue (Object parameterKey)
   {
     if (parameterKey instanceof JeksCell)
       // return the value of the cell matching parameterKey stored in the table

     else // parameterKey instanceof JeksCellSet
       // return a double dimension array that contains the values of the cells
       // matching parameterKey stored in the table
   }
 }
(read JeksParameter.java for full source).

Since:
Jeks 1.0
Version:
1.0
Author:
Emmanuel Puybaret
See Also:
JeksParameter, ExpressionParser, Syntax, CompiledExpression

Method Summary
 java.lang.Object getParameterKey(java.lang.String parameter)
          Returns a key matching the identifier parameter, if parameter is a valid parameter in expressions parsed with this instance.
 java.lang.Object getParameterValue(java.lang.Object identifierKey)
          Returns the value matching parameterKey.
 

Method Detail

getParameterKey

public java.lang.Object getParameterKey(java.lang.String parameter)
Returns a key matching the identifier parameter, if parameter is a valid parameter in expressions parsed with this instance.
Parameters:
parameter - the identifier of a parameter. The identifier is already valid for the isValidIdentifier () method of the syntax used by the parser.
Returns:
null if parameter is not valid. Otherwise the key returned will be the one passed to getParameterValue () at run time. The key may be the parameter itself.

getParameterValue

public java.lang.Object getParameterValue(java.lang.Object identifierKey)
Returns the value matching parameterKey. This value may be of any type (Double, String or other).
Parameters:
parameterKey - the key of the parameter returned by getParameterKey.
Returns:
The value matching parameterKey.

&cp; 1998-2003 eTeks - All rights reserved