gnu.jel
Class DVMap

java.lang.Object
  |
  +--gnu.jel.DVMap
All Implemented Interfaces:
DVResolver

public abstract class DVMap
extends java.lang.Object
implements DVResolver

Provides the information about defined dynamic variables.

Additionally to DVResolver it allows to translate variable names into constants of Java primitive types at compile-time. See the section of the manual on dynamic variables.


Constructor Summary
DVMap()
           
 
Method Summary
 java.lang.Object translate(java.lang.String name)
          This method is used to translate the variable name of type String to a constant of another type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gnu.jel.DVResolver
getTypeName
 

Constructor Detail

DVMap

public DVMap()
Method Detail

translate

public java.lang.Object translate(java.lang.String name)
This method is used to translate the variable name of type String to a constant of another type.

The performance of the compiled code can be sometimes improved by letting it not to deal with strings. For example, in older JEL <=0.9.8 this method was absent, and, if the underlying representation of the dynamic variables storage was an array, the translation of variable name (represented by String) into integer index had to happen at run-time, taking up the valuable processor cycles. Defining the proper DVResolver.translate one can perform the translation "variable name(String)"->"slot number(int)" at compile time. There can be also other clever ways of using translation to improve performance even if variables are not stored in an array or vector.

The default implementation provides the identity translation, which simulates the behaviour of older versions of JEL.

Introducing this method breaks the source code compatibility (requiring to add an identity translation) with version 0.9.8. The binary compatibility is preserved, so that old code compiled against 0.9.8 will run unchanged with 0.9.9 (or later up to JEL 1.0, where the workaround will be removed), but the old code will not compile until the identity translation is added. This incompatibility is the price to pay for DVResolver being an interface.

Parameters:
name - Name of the variable to be translated.
Returns:
Object representing the translated name, this object must be either a reflection type wrapping a primitive (e.g. java.lang.Integer, java.lang.Byte) or String. No other object is allowed, othwerwise an exception will emerge at compile-time. This limitation is due to Java class file format not allowing to store constants of types other than specified above.
Since:
0.9.9