org.hava.engine
Class HValue

java.lang.Object
  extended by org.hava.engine.HValue
Direct Known Subclasses:
HReference

public class HValue
extends java.lang.Object

A value that may be assigned to a Hava variable at run-time. It is implemented as a wrapper on what might be a standard Java class (Integer, Double, Boolean) or a custom Hava class (not publicly visible).


Field Summary
static HValue BLANK
          A built-in token.
static HValue BOOLEAN
          A built-in token, returned by getType().
static HValue EMPTYLIST
          A built-in value.
static HValue ERROR
          A built-in token.
static HValue FALSE
          A built-in value.
static HValue IGNORE
          A built-in token.
static HValue INTEGER
          A built-in token, returned by getType().
static HValue LIST
          A built-in token, returned by getType().
static HValue ONE
          A built-in value.
static HValue REAL
          A built-in token, returned by getType().
static HValue STRUCTURE
          A built-in token, returned by getType().
static HValue TOKEN
          A built-in token, returned by getType().
static HValue TRUE
          A built-in value.
static HValue TWO
          A built-in value.
static HValue ZERO
          A built-in value.
 
Constructor Summary
HValue(java.lang.Boolean dvalue)
          Create an HValue wrapper for the given boolean.
HValue(java.lang.Double dvalue)
          Create an HValue wrapper for the given double.
HValue(HValue[] a)
          Create an HValue wrapper for the given list.
HValue(java.lang.Integer ivalue)
          Create an HValue wrapper for the given integer.
 
Method Summary
 boolean booleanValue()
          Returns this value as a boolean (run-time failure if it is not boolean).
 int compareDefinitionRank(HValue v)
          Used by report generator to determine the sequence in which value types were defined.
 double doubleValue()
          Returns this value as a double (run-time failure if it is not numerical).
 boolean equals(java.lang.Object x)
           
 HValue getElement(int i)
          If compound, returns the i-th element.
 int getNumElements()
          If compound, returns the number of elements it contains.
 HParameters getParameters()
          Returns the definition of the indexes or fields of this value (if it is an index or a structure).
 HValue getType()
          Returns the type of this value, as a Hava token instance.
 int hashCode()
           
 int intValue()
          Returns this value as an int (run-time failure if it is not numerical).
 boolean isBoolean()
          Returns true if this value is a boolean.
 boolean isCompound()
          Returns true if this value is a list, an index or a structure.
 boolean isDouble()
          Returns true if this value is a double.
 boolean isIndex()
          Returns true if this value is an index.
 boolean isInteger()
          Returns true if this value is an integer.
 boolean isList()
          Returns true if this value is a list.
 boolean isNumerical()
          Returns true if this value is a number (integer or double).
 boolean isStructure()
          Returns true if this value is a structure.
 boolean isToken()
          Returns true if this value is a token.
 HValue structField(java.lang.String fieldName)
          Returns the value of the field of given name (struct value only).
 java.lang.String toString()
          Provides a representation of this value in the same format that appears in the demo report.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BLANK

public static final HValue BLANK
A built-in token.


BOOLEAN

public static final HValue BOOLEAN
A built-in token, returned by getType().


EMPTYLIST

public static final HValue EMPTYLIST
A built-in value.


ERROR

public static final HValue ERROR
A built-in token.


FALSE

public static final HValue FALSE
A built-in value.


IGNORE

public static final HValue IGNORE
A built-in token.


INTEGER

public static final HValue INTEGER
A built-in token, returned by getType().


LIST

public static final HValue LIST
A built-in token, returned by getType().


ONE

public static final HValue ONE
A built-in value.


REAL

public static final HValue REAL
A built-in token, returned by getType().


STRUCTURE

public static final HValue STRUCTURE
A built-in token, returned by getType().


TOKEN

public static final HValue TOKEN
A built-in token, returned by getType().


TRUE

public static final HValue TRUE
A built-in value.


TWO

public static final HValue TWO
A built-in value.


ZERO

public static final HValue ZERO
A built-in value.

Constructor Detail

HValue

public HValue(java.lang.Boolean dvalue)
Create an HValue wrapper for the given boolean.


HValue

public HValue(java.lang.Double dvalue)
Create an HValue wrapper for the given double.


HValue

public HValue(HValue[] a)
Create an HValue wrapper for the given list.


HValue

public HValue(java.lang.Integer ivalue)
Create an HValue wrapper for the given integer.

Method Detail

booleanValue

public boolean booleanValue()
Returns this value as a boolean (run-time failure if it is not boolean).


compareDefinitionRank

public int compareDefinitionRank(HValue v)
Used by report generator to determine the sequence in which value types were defined.

Meaningful only values with defined types: token, structure, reference, import or doc comment. In other words, not meaningful for integer, real, boolean or list types.

Returns 1 if the type of this value was defined before the type of the argument v, -1 if the opposite is true, or 0 if they have the same definition.


doubleValue

public double doubleValue()
Returns this value as a double (run-time failure if it is not numerical).


equals

public boolean equals(java.lang.Object x)
Overrides:
equals in class java.lang.Object

getElement

public HValue getElement(int i)
If compound, returns the i-th element.


getNumElements

public int getNumElements()
If compound, returns the number of elements it contains.


getParameters

public HParameters getParameters()
Returns the definition of the indexes or fields of this value (if it is an index or a structure).


getType

public HValue getType()
Returns the type of this value, as a Hava token instance.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

intValue

public int intValue()
Returns this value as an int (run-time failure if it is not numerical). May round or truncate if not integer.


isBoolean

public boolean isBoolean()
Returns true if this value is a boolean.


isCompound

public boolean isCompound()
Returns true if this value is a list, an index or a structure.


isDouble

public boolean isDouble()
Returns true if this value is a double.


isIndex

public boolean isIndex()
Returns true if this value is an index.


isInteger

public boolean isInteger()
Returns true if this value is an integer.


isList

public boolean isList()
Returns true if this value is a list.


isNumerical

public boolean isNumerical()
Returns true if this value is a number (integer or double).


isStructure

public boolean isStructure()
Returns true if this value is a structure.


isToken

public boolean isToken()
Returns true if this value is a token.


structField

public HValue structField(java.lang.String fieldName)
Returns the value of the field of given name (struct value only).


toString

public java.lang.String toString()
Provides a representation of this value in the same format that appears in the demo report.

Overrides:
toString in class java.lang.Object