com.billpringle.utils.wrputils
Class WrpValidateCsv.Variable

java.lang.Object
  extended by com.billpringle.utils.wrputils.WrpValidateCsv.Variable
Enclosing class:
WrpValidateCsv

public class WrpValidateCsv.Variable
extends java.lang.Object

Inner class for variable.

This class represents variables during the execution of the validation rules. All variables must be declared, although the declarations can appear after it is referenced. A variable exists throughout the execution stage. The map command can be used to define a relationship between a CSV field and a variable. Each time a new record is processed, the CSV fields are copied to the mapped variables. Non-mapped variables retain their values until they are changed. Because of this, variables can retain their values across different CSV records, which means you can accumulate totals for the entire execution phase.

To increase efficiency, the index into variables for a referenced variable is stored in the rule structure so that a search for the variable is not required during run time.

Author:
Bill Pringle

Field Summary
 boolean boolVal
          value of variable, if boolean
 java.lang.Boolean fld
          flag indicating variable is mapped to a field
 float fltVal
          value of variable, if float
 int intVal
          value of variable, if integer
 java.lang.String name
          variable name
 java.lang.String strVal
          value of variable, if string
 int type
          variable type (TYPE_something)
 
Constructor Summary
WrpValidateCsv.Variable()
          Default constructor
 
Method Summary
 float getFltVal()
          Get the floating point value of this variable
 int getIntVal()
          Get the integer value of this variable
 java.lang.String getName()
          Get the name of this variable
 java.lang.String getStrVal()
          Get the string value of this variable
 int getType()
          Get the data type of this variable
 java.lang.Object getVal()
          Get the current value of the variable.
 boolean isBoolVal()
          Get the boolean value for this variable
 boolean isField()
          Determines if the current variable is mapped to a CSV field.
 boolean set(WrpValidateCsv.Variable v)
          Set the value to that of the specified variable.
 void setBoolVal(boolean boolVal)
          Set the boolean value of this variable
 void setField(java.lang.Boolean b)
          Specify if the variable is mapped to a CSV field.
 void setFltVal(float fltVal)
          Set the floating point variable of this variable
 void setIntVal(int intVal)
          Set the integer variable of this variable
 void setName(java.lang.String name)
          Set the name of this variable
 void setStrVal(java.lang.String strVal)
          Set the string value of this variable
 void setType(int type)
          Set the data type of this variable
 void setType(java.lang.String ftype)
          Set the data type of this variable
 boolean setVal(java.lang.String val)
          Set the value based on the type of variable
 java.lang.String toString()
          Build string representation of Variable, including the values and locations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public java.lang.String name
variable name


type

public int type
variable type (TYPE_something)


fld

public java.lang.Boolean fld
flag indicating variable is mapped to a field


strVal

public java.lang.String strVal
value of variable, if string


intVal

public int intVal
value of variable, if integer


fltVal

public float fltVal
value of variable, if float


boolVal

public boolean boolVal
value of variable, if boolean

Constructor Detail

WrpValidateCsv.Variable

public WrpValidateCsv.Variable()
Default constructor

Method Detail

setVal

public boolean setVal(java.lang.String val)
               throws java.lang.NumberFormatException
Set the value based on the type of variable

Parameters:
val - the new value of the variable
Returns:
true if the assignment succeeds; false otherwise
Throws:
java.lang.NumberFormatException - if the value doesn't match the data type

set

public boolean set(WrpValidateCsv.Variable v)
Set the value to that of the specified variable. Both variables should be the same data type.

Parameters:
v - the Variable containing the new value
Returns:
true if operation suceeded

getVal

public java.lang.Object getVal()
Get the current value of the variable.

The data type that is returned depends on the type of the variable.

Returns:
an object with the current value of the variable

getName

public java.lang.String getName()
Get the name of this variable

Returns:
the name

setName

public void setName(java.lang.String name)
Set the name of this variable

Parameters:
name - the name to set

getType

public int getType()
Get the data type of this variable

Returns:
the type

setType

public void setType(int type)
Set the data type of this variable

Parameters:
type - the type to set

setType

public void setType(java.lang.String ftype)
Set the data type of this variable

Parameters:
ftype - the name of the data type to be set

getStrVal

public java.lang.String getStrVal()
Get the string value of this variable

Returns:
the strVal

setStrVal

public void setStrVal(java.lang.String strVal)
Set the string value of this variable

Parameters:
strVal - the strVal to set

getIntVal

public int getIntVal()
Get the integer value of this variable

Returns:
the intVal

setIntVal

public void setIntVal(int intVal)
Set the integer variable of this variable

Parameters:
intVal - the intVal to set

getFltVal

public float getFltVal()
Get the floating point value of this variable

Returns:
the fltVal

setFltVal

public void setFltVal(float fltVal)
Set the floating point variable of this variable

Parameters:
fltVal - the fltVal to set

isBoolVal

public boolean isBoolVal()
Get the boolean value for this variable

Returns:
the boolVal

setBoolVal

public void setBoolVal(boolean boolVal)
Set the boolean value of this variable

Parameters:
boolVal - the boolVal to set

isField

public boolean isField()
Determines if the current variable is mapped to a CSV field.

Returns:
true if the variable is mapped; otherwise false

setField

public void setField(java.lang.Boolean b)
Specify if the variable is mapped to a CSV field.

Parameters:
b - true if the variable is mapped; false otherwise

toString

public java.lang.String toString()
Build string representation of Variable, including the values and locations

Overrides:
toString in class java.lang.Object