com.konakart.app
Class ExpressionVariable

java.lang.Object
  extended by com.konakart.app.ExpressionVariable
All Implemented Interfaces:
ExpressionVariableIf

public class ExpressionVariable
extends java.lang.Object
implements ExpressionVariableIf

An expression variable is part of an expression


Field Summary
static int AND
          Expression type.
static int EQUAL
          Comparison type.
static int GREATER_EQUAL
          Comparison type.
static int GREATER_THAN
          Comparison type.
static int LESS_EQUAL
          Comparison type.
static int LESS_THAN
          Comparison type.
static int MATCH
          Comparison type to match regular expression
static int NOT_EQUAL
          Comparison type.
static int OR
          Expression type.
 
Constructor Summary
ExpressionVariable()
          Constructor
ExpressionVariable(com.workingdogs.village.Record vr, org.apache.torque.util.Criteria c)
          Instantiates the attributes of the Tag object from a Record object
 
Method Summary
protected  boolean compareBooleans(int operator)
          Compare Booleans
protected  boolean compareDates(int operator)
          Compare dates which are stored as strings containing the millisecond value
protected  boolean compareDecimals(int operator)
          Compare decimals
protected  boolean compareInts(int operator)
          Compare integers
protected  boolean compareMultiInt(int operator)
          Compare Multi ints which are stored as integers separated by CustomerTag.DELIM
protected  boolean compareStrings(int operator)
          Compare strings
 boolean evaluate()
          Evaluates the variable by comparing the value attribute with the customerValue attribute using the operator attribute.
 int getAndOr()
          Defines whether this variable has to be ANDed or ORed with the one that precedes it.
 int getCustomerTagId()
          Id of the customer tag for this variable
 java.lang.String getCustomerValue()
          The customer value for the tag which is compared to the value attribute when evaluating the expression variable.
 int getExpressionId()
          Id of the expression that this variable belongs to
 int getGroupAndOr()
          Defines whether this group has to be ANDed or ORed with the one that precedes it.
 int getGroupOrder()
          The order of the group that this expression variable belongs to.
 int getId()
           
 int getOperator()
          Valid operators are: ExpressionVariable.EQUAL ExpressionVariable.NOT_EQUAL ExpressionVariable.GREATER_EQUAL ExpressionVariable.GREATER_THAN ExpressionVariable.LESS_EQUAL ExpressionVariable.LESS_THAN ExpressionVariable.MATCH - Used to match regular expression Note that not all operators are valid for all tag types.
protected  java.lang.String getOperatorName(int operator)
          Returns the name of the operator mainly for reporting purposes.
 int getOrder()
          The order of this expression variable.
 int getType()
          The type of variable.
 java.lang.String getValue()
          The value of the expression variable.
 void setAndOr(int andOr)
          Defines whether this variable has to be ANDed or ORed with the one that precedes it.
 void setCustomerTagId(int customerTagId)
          Id of the customer tag for this variable
 void setCustomerValue(java.lang.String customerValue)
          The customer value for the tag which is compared to the value attribute when evaluating the expression variable.
 void setExpressionId(int expressionId)
          Id of the expression that this variable belongs to
 void setGroupAndOr(int groupAndOr)
          Defines whether this group has to be ANDed or ORed with the one that precedes it.
 void setGroupOrder(int groupOrder)
          The order of the group that this expression variable belongs to.
 void setId(int id)
           
 void setOperator(int operator)
          Valid operators are: ExpressionVariable.EQUAL ExpressionVariable.NOT_EQUAL ExpressionVariable.GREATER_EQUAL ExpressionVariable.GREATER_THAN ExpressionVariable.LESS_EQUAL ExpressionVariable.LESS_THAN ExpressionVariable.MATCH - Used to match regular expression Note that not all operators are valid for all tag types.
 void setOrder(int order)
          The order of this expression variable.
 void setType(int type)
          The type of variable.
 void setValue(java.lang.String value)
          The value of the expression variable.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUAL

public static final int EQUAL
Comparison type.

See Also:
Constant Field Values

NOT_EQUAL

public static final int NOT_EQUAL
Comparison type.

See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
Comparison type.

See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
Comparison type.

See Also:
Constant Field Values

GREATER_EQUAL

public static final int GREATER_EQUAL
Comparison type.

See Also:
Constant Field Values

LESS_EQUAL

public static final int LESS_EQUAL
Comparison type.

See Also:
Constant Field Values

MATCH

public static final int MATCH
Comparison type to match regular expression

See Also:
Constant Field Values

AND

public static final int AND
Expression type.

See Also:
Constant Field Values

OR

public static final int OR
Expression type.

See Also:
Constant Field Values
Constructor Detail

ExpressionVariable

public ExpressionVariable()
Constructor


ExpressionVariable

public ExpressionVariable(com.workingdogs.village.Record vr,
                          org.apache.torque.util.Criteria c)
                   throws com.workingdogs.village.DataSetException
Instantiates the attributes of the Tag object from a Record object

Parameters:
vr - Record containing data
c - Criteria containing column names
Throws:
com.workingdogs.village.DataSetException
Method Detail

evaluate

public boolean evaluate()
                 throws KKException
Evaluates the variable by comparing the value attribute with the customerValue attribute using the operator attribute. False is returned if any of the values are null.
Not all operators are valid for all customer tag types. The valid operators for each customer tag type are:

Returns:
Returns a boolean
Throws:
KKException

compareStrings

protected boolean compareStrings(int operator)
                          throws KKException
Compare strings

Parameters:
operator -
Returns:
Returns true or false
Throws:
KKException

compareBooleans

protected boolean compareBooleans(int operator)
                           throws KKException
Compare Booleans

Parameters:
operator -
Returns:
Returns true or false
Throws:
KKException

compareMultiInt

protected boolean compareMultiInt(int operator)
                           throws KKException
Compare Multi ints which are stored as integers separated by CustomerTag.DELIM

Parameters:
operator -
Returns:
Returns true or false
Throws:
KKException

compareInts

protected boolean compareInts(int operator)
                       throws KKException
Compare integers

Parameters:
operator -
Returns:
Returns true or false
Throws:
KKException

compareDates

protected boolean compareDates(int operator)
                        throws KKException
Compare dates which are stored as strings containing the millisecond value

Parameters:
operator -
Returns:
Returns true or false
Throws:
KKException

compareDecimals

protected boolean compareDecimals(int operator)
                           throws KKException
Compare decimals

Parameters:
operator -
Returns:
Returns true or false
Throws:
KKException

getOperatorName

protected java.lang.String getOperatorName(int operator)
Returns the name of the operator mainly for reporting purposes.

Parameters:
operator -
Returns:
the name of the operator as a String.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
Returns a string containing the attributes of the ExpressionVariable object.

getId

public int getId()
Specified by:
getId in interface ExpressionVariableIf
Returns:
the id

setId

public void setId(int id)
Specified by:
setId in interface ExpressionVariableIf
Parameters:
id - the id to set

getCustomerTagId

public int getCustomerTagId()
Description copied from interface: ExpressionVariableIf
Id of the customer tag for this variable

Specified by:
getCustomerTagId in interface ExpressionVariableIf
Returns:
the customerTagId

setCustomerTagId

public void setCustomerTagId(int customerTagId)
Description copied from interface: ExpressionVariableIf
Id of the customer tag for this variable

Specified by:
setCustomerTagId in interface ExpressionVariableIf
Parameters:
customerTagId - the customerTagId to set

getExpressionId

public int getExpressionId()
Description copied from interface: ExpressionVariableIf
Id of the expression that this variable belongs to

Specified by:
getExpressionId in interface ExpressionVariableIf
Returns:
the expressionId

setExpressionId

public void setExpressionId(int expressionId)
Description copied from interface: ExpressionVariableIf
Id of the expression that this variable belongs to

Specified by:
setExpressionId in interface ExpressionVariableIf
Parameters:
expressionId - the expressionId to set

getType

public int getType()
Description copied from interface: ExpressionVariableIf
The type of variable. It must match the type of the customer tag referred to by customerTagId. Valid types are:

Specified by:
getType in interface ExpressionVariableIf
Returns:
the type

setType

public void setType(int type)
Description copied from interface: ExpressionVariableIf
The type of variable. It must match the type of the customer tag referred to by customerTagId. Valid types are:
  • CustomerTag.STRING_TYPE: The value is a String
  • CustomerTag.INT_TYPE: The value is an integer
  • CustomerTag.MULTI_INT_TYPE: The value contains one or more integers separated by a delimiter. The maxInts attributes determines how many integers are allowed.
  • CustomerTag.DECIMAL_TYPE: The value is a decimal.
  • CustomerTag.DATE_TYPE: The value is a date.
  • CustomerTag.BOOLEAN_TYPE: The value is a boolean and so must contain the string true or false

Specified by:
setType in interface ExpressionVariableIf
Parameters:
type - the type to set

getOperator

public int getOperator()
Description copied from interface: ExpressionVariableIf
Valid operators are:
  • ExpressionVariable.EQUAL
  • ExpressionVariable.NOT_EQUAL
  • ExpressionVariable.GREATER_EQUAL
  • ExpressionVariable.GREATER_THAN
  • ExpressionVariable.LESS_EQUAL
  • ExpressionVariable.LESS_THAN
  • ExpressionVariable.MATCH - Used to match regular expression
Note that not all operators are valid for all tag types.

Specified by:
getOperator in interface ExpressionVariableIf
Returns:
the operator

setOperator

public void setOperator(int operator)
Description copied from interface: ExpressionVariableIf
Valid operators are:
  • ExpressionVariable.EQUAL
  • ExpressionVariable.NOT_EQUAL
  • ExpressionVariable.GREATER_EQUAL
  • ExpressionVariable.GREATER_THAN
  • ExpressionVariable.LESS_EQUAL
  • ExpressionVariable.LESS_THAN
  • ExpressionVariable.MATCH - Used to match regular expression
Note that not all operators are valid for all tag types.

Specified by:
setOperator in interface ExpressionVariableIf
Parameters:
operator - the operator to set

getValue

public java.lang.String getValue()
Description copied from interface: ExpressionVariableIf
The value of the expression variable. Valid values depend on the tag type.

Specified by:
getValue in interface ExpressionVariableIf
Returns:
the value

setValue

public void setValue(java.lang.String value)
Description copied from interface: ExpressionVariableIf
The value of the expression variable. Valid values depend on the tag type.

Specified by:
setValue in interface ExpressionVariableIf
Parameters:
value - the value to set

getCustomerValue

public java.lang.String getCustomerValue()
Description copied from interface: ExpressionVariableIf
The customer value for the tag which is compared to the value attribute when evaluating the expression variable.

Specified by:
getCustomerValue in interface ExpressionVariableIf
Returns:
the customerValue

setCustomerValue

public void setCustomerValue(java.lang.String customerValue)
Description copied from interface: ExpressionVariableIf
The customer value for the tag which is compared to the value attribute when evaluating the expression variable.

Specified by:
setCustomerValue in interface ExpressionVariableIf
Parameters:
customerValue - the customerValue to set

getOrder

public int getOrder()
Description copied from interface: ExpressionVariableIf
The order of this expression variable.

Specified by:
getOrder in interface ExpressionVariableIf
Returns:
the order

setOrder

public void setOrder(int order)
Description copied from interface: ExpressionVariableIf
The order of this expression variable.

Specified by:
setOrder in interface ExpressionVariableIf
Parameters:
order - the order to set

getAndOr

public int getAndOr()
Description copied from interface: ExpressionVariableIf
Defines whether this variable has to be ANDed or ORed with the one that precedes it.

Specified by:
getAndOr in interface ExpressionVariableIf
Returns:
the andOr

setAndOr

public void setAndOr(int andOr)
Description copied from interface: ExpressionVariableIf
Defines whether this variable has to be ANDed or ORed with the one that precedes it.

Specified by:
setAndOr in interface ExpressionVariableIf
Parameters:
andOr - the andOr to set

getGroupOrder

public int getGroupOrder()
Description copied from interface: ExpressionVariableIf
The order of the group that this expression variable belongs to.

Specified by:
getGroupOrder in interface ExpressionVariableIf
Returns:
the groupOrder

setGroupOrder

public void setGroupOrder(int groupOrder)
Description copied from interface: ExpressionVariableIf
The order of the group that this expression variable belongs to.

Specified by:
setGroupOrder in interface ExpressionVariableIf
Parameters:
groupOrder - the groupOrder to set

getGroupAndOr

public int getGroupAndOr()
Description copied from interface: ExpressionVariableIf
Defines whether this group has to be ANDed or ORed with the one that precedes it.

Specified by:
getGroupAndOr in interface ExpressionVariableIf
Returns:
the groupAndOr

setGroupAndOr

public void setGroupAndOr(int groupAndOr)
Description copied from interface: ExpressionVariableIf
Defines whether this group has to be ANDed or ORed with the one that precedes it.

Specified by:
setGroupAndOr in interface ExpressionVariableIf
Parameters:
groupAndOr - the groupAndOr to set


Copyright © 2011 DS Data Systems UK Ltd.