Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.able.rules
Class AbleSwitchStatement

    java.lang.Object
      com.ibm.able.data.AbleLiteral
          com.ibm.able.rules.AbleSwitchStatement

All Implemented Interfaces:
  AbleRd, java.io.Serializable

public class AbleSwitchStatement
extends AbleLiteral
implements java.io.Serializable

This class holds the expressions and actions used in a switch action (which could be nested in other rules or actions). The integer expression can be an arbitrarily complex integer expression and the case sections can contain one or more consequent (action) clauses.

Since:
  ABLE 2.2.0
See Also:
  Serialized Form

Nested Class Summary
`class` | `AbleSwitchStatement.CaseListElement_` This class is used to store information about each 'case' as it is defined.

Constructor Summary
`AbleSwitchStatement(AbleRuleSet theRuleSet, AbleRuleBlock theRuleBlock, AbleExpression theIntExpression)` Creates a new switch statement with the specified integer expression.

Method Summary
`void` | `addCaseCode(AbleConsequentClause theCaseCode)` Adds a single line of code to the body of the last added case label.
`void` | `addCaseCode(java.util.Collection theCaseCode)` Adds a block of code to the body of the last added case label.
`void` | `addCaseLabel(AbleRd theCaseLabel)` Adds a new case label to the current set of switch cases.
`void` | `addDefaultCode(AbleConsequentClause theDefaultCode)` Adds a single line of code to this switch statement's 'default' code block.
`void` | `addDefaultCode(java.util.Collection theDefaultCode)` Adds a block of code to this switch statement's 'default' code block.
`java.lang.String` | `arlCRdString()` Returns a formal ARL "clause read" (CRd) string representation of this statement.
`java.lang.String` | `arlString()` Returns a formal ABLE Rule Language (ARL) string representation of this statement.
`java.lang.String` | `armlString()` Returns a formal ABLE Rule Markup Language (ARML) string representation of this statement.
`protected void` | `evalConsequentClause(AbleConsequentClause theClause)` Evaluate the specified consequent clause.
`void` | `evaluate()` Evaluates this switch statement.
`boolean` | `getBooleanValue()` Retrieve the value of this data object as a boolean value.
`int` | `getDataType()` Retrieve the data type of this data object.
`java.lang.Class` | `getDataTypeClass()` Retrieve the actual class of this object's underlying data type.
`java.lang.String` | `getDataTypeClassName()` Retrieve the name of the class of this object's underlying data type.
`AbleFuzzySet` | `getFuzzyValue()` Retrieve the value of this data object as a fuzzy value.
`java.lang.Object` | `getGenericValue()` Retrieve the value of this data object as an Object.
`double` | `getNumericValue()` Retrieve the value of this data object as a numeric value.
`java.lang.String` | `getStringValue()` Retrieve the value of this data object as a string value.
`java.lang.String` | `getTemplateString(java.util.Vector theTemplateVars)` Retrieve a text format string for use by rule templates.
`AbleLiteral` | `getValue()` Retrieves the value of this data object as a literal.
`java.lang.String` | `toString()` Retrieves a string describing (the contents of) the object.
`java.lang.String` | `traceString(int theTraceStringFlavor)` Retrieves a string describing (the contents of) the object.
`java.lang.String` | `xmlCRdString()` Returns a formal XML "clause read" (CRd) string representation of this statement.
`java.lang.String` | `xmlString()` Returns a formal XML string representation of this statement.

Methods inherited from class com.ibm.able.data.AbleLiteral
`bitwiseAND, bitwiseNOT, bitwiseOR, bitwiseShiftLeft, bitwiseShiftRight, bitwiseShiftRightZeroFill, bitwiseXOR, cmpEq, cmpGt, cmpGtEq, cmpIs, cmpLt, cmpLtEq, cmpNeq, compDivide, compMinus, compModulo, compMultiply, compPlus, compUnaryMinus, getDataTypeAsString, getReferent, getReferents, isConstant, logicalAND, logicalNOT, logicalOR`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### AbleSwitchStatement

    public AbleSwitchStatement(AbleRuleSet theRuleSet,
                               AbleRuleBlock theRuleBlock,
                               AbleExpression theIntExpression)

  Creates a new switch statement with the specified integer expression.

  Use `addCaseLabel(AbleRd)`, `addCaseCode(Collection)`, and `addDefaultCode(Collection)` to build up the desired switch construct.

Parameters:
  `theRuleSet` - The ruleset to which this statement belongs.
  `theRuleBlock` - The ruleblock to which this statement belongs.
  `theIntExpression` - An AbleExpression that, when evaluated, will determine the entry point into the code body. This expression must be able to give up an Integer value.

Method Detail

### addCaseLabel

    public void addCaseLabel(AbleRd theCaseLabel)
                      throws AbleParException

  Adds a new case label to the current set of switch cases. This method may be followed by another call to this method, to create something like:

         case 1:
         case 2:

  or this method may be followed by a call to `addCaseCode(Collection)` to create something like:

         case 1:
           statement1;
           statement2;

  Parameters:
    `theCaseLabel` - An expression that must give up an integer value. The expression is evaluated immediately, and the returned value becomes the fixed key to an entry point in the code table.
  Throws:
    `AbleParException` - When theCaseLabel cannot be turned into an integer value.

### addCaseCode

    public void addCaseCode(java.util.Collection theCaseCode)

  Adds a block of code to the body of the last added case label. This method may be called multiple times before the next case label is added to this switch statement, allowing the case body to be built up several lines at a time or all at once.

  A single line of code may also be added to the code body by using the `addCaseCode(AbleConsequentClause)` method.

  Parameters:
    `theCaseCode` - A collection of one or more code statements.

### addCaseCode

    public void addCaseCode(AbleConsequentClause theCaseCode)

  Adds a single line of code to the body of the last added case label. This method may be called multiple times before the next case label is added to this switch statement, allowing the case body to be built up a line at a time.

  Multiple lines of code may also be added all at once by using the `addCaseCode(Collection)` method.

  Parameters:
    `theCaseCode` - A single code statement.

### addDefaultCode

    public void addDefaultCode(java.util.Collection theDefaultCode)

  Adds a block of code to this switch statement's 'default' code block.

  The default code block is evaluated either when (1) the integer expression fails to resolve to a code body entry point, or (2) the code body falls through to this code due to the lack of a 'break' statement. Note that there does not have to be a default block of code; that is, the list can be empty, in which case this method does not have to be called at all.

  This method may be called multiple times, allowing the default code body to be built up several lines at a time or all at once.

  A single line of code may also be added to the default code body by using the `addDefaultCode(AbleConsequentClause)` method.

  Parameters:
    `theDefaultCode` - A collection of one or more code statements.

### addDefaultCode

    public void addDefaultCode(AbleConsequentClause theDefaultCode)

  Adds a single line of code to this switch statement's 'default' code block.

  The default code block is evaluated either when (1) the integer expression fails to resolve to a code body entry point, or (2) the code body falls through to this code due to the lack of a 'break' statement. Note that there does not have to be a default block of code; that is, the list can be empty, in which case this method does not have to be called at all.

  This method may be called multiple times, allowing the default code body to be built up a line at a time.

  Multiple lines of code may also be added to the default code body all at once by using the `addDefaultCode(Collection)` method.

  Parameters:
    `theDefaultCode` - A single code statement.

### getValue

    public AbleLiteral getValue()
                         throws AbleDataException

  Retrieves the value of this data object as a literal.

  Yeah, OK, this method is really used just to evaluate this statement, which shouldn't return anything.

  Specified by:
    `getValue` in interface `AbleRd`
  Specified by:
    `getValue` in class `AbleLiteral`
  Returns:
    An AbleBooleanLiteral object whose value is true.
  Throws:
    `AbleDataException` - If the value of this object cannot be represented as a literal.

### evaluate

    public void evaluate()
                  throws AbleDataException

  Evaluates this switch statement.

  Throws:
    `AbleDataException` - If any data conversion error is encountered while evaluating this statement.

### evalConsequentClause

    protected void evalConsequentClause(AbleConsequentClause theClause)
                                 throws AbleDataException

  Evaluate the specified consequent clause.

  Parameters:
    `theClause` - a consequent clause to evaluate.

  Throws:
    `AbleDataException` - when the clause's data objects are incompatible, or when the relational operator is invalid for the current situation or unrecognized.

### arlString

    public java.lang.String arlString()

  Returns a formal ABLE Rule Language (ARL) string representation of this statement.

  Returns:
    An ARL representation of this statement.

### armlString

    public java.lang.String armlString()

  Returns a formal ABLE Rule Markup Language (ARML) string representation of this statement.

  Returns:
    An ARML representation of this statement.

### xmlString

    public java.lang.String xmlString()

  Returns a formal XML string representation of this statement.

  Returns:
    An XML representation of this statement.

### getTemplateString

    public java.lang.String getTemplateString(java.util.Vector theTemplateVars)

  Retrieve a text format string for use by rule templates. The string contains "{n}" strings, where the index 'n' corresponds to the template variables defined in the rule template. This string is based on the standard arlString() representation of the rule. After replacement of the template variable values, the resulting string must be a valid ARL format string that can be parsed.

  Specified by:
    `getTemplateString` in interface `AbleRd`
  Overrides:
    `getTemplateString` in class `AbleLiteral`
  Parameters:
    `theTemplateVars` - An ordered list of template variables referenced by this rule.
  Returns:
    A Text format string used to create a new rule instance.
  See Also:
    `AbleRuleTemplate`

### toString

    public java.lang.String toString()

  Retrieves a string describing (the contents of) the object.

  Overrides:
    `toString` in class `AbleLiteral`
  Returns:
    A String containing the current contents of the object.

### traceString

    public java.lang.String traceString(int theTraceStringFlavor)

  Retrieves a string describing (the contents of) the object.

  Specified by:
    `traceString` in interface `AbleRd`
  Specified by:
    `traceString` in class `AbleLiteral`
  Parameters:
    `theTraceStringFlavor` - An Able.TraceStringFlavor value.
  Returns:
    A String containing the current contents of the object.

### getDataType

    public int getDataType()

  Description copied from class: `AbleLiteral`
  Retrieve the data type of this data object.

  Specified by:
    `getDataType` in interface `AbleRd`
  Specified by:
    `getDataType` in class `AbleLiteral`
  Returns:
    An AbleData.<DataType> constant.
  See Also:
    `AbleRd.getDataType()`

### getDataTypeClass

    public java.lang.Class getDataTypeClass()

  Description copied from class: `AbleLiteral`
  Retrieve the actual class of this object's underlying data type.

  Specified by:
    `getDataTypeClass` in interface `AbleRd`
  Specified by:
    `getDataTypeClass` in class `AbleLiteral`
  Returns:
    The class of the underlying data type.

### getDataTypeClassName

    public java.lang.String getDataTypeClassName()

  Description copied from class: `AbleLiteral`
  Retrieve the name of the class of this object's underlying data type.

  Specified by:
    `getDataTypeClassName` in interface `AbleRd`
  Specified by:
    `getDataTypeClassName` in class `AbleLiteral`
  Returns:
    A String that is the name of the class of the underlying data type.

### arlCRdString

    public java.lang.String arlCRdString()

  Returns a formal ARL "clause read" (CRd) string representation of this statement.

  Specified by:
    `arlCRdString` in interface `AbleRd`
  Specified by:
    `arlCRdString` in class `AbleLiteral`
  Returns:
    A String representation of this statement in formal Able Rule Language.

### xmlCRdString

    public java.lang.String xmlCRdString()

  Returns a formal XML "clause read" (CRd) string representation of this statement.

  Specified by:
    `xmlCRdString` in interface `AbleRd`
  Specified by:
    `xmlCRdString` in class `AbleLiteral`
  Returns:
    A String representation of this statement in XML.

### getBooleanValue

    public boolean getBooleanValue()
                            throws AbleDataException

  Description copied from class: `AbleLiteral`
  Retrieve the value of this data object as a boolean value.

  Specified by:
    `getBooleanValue` in interface `AbleRd`
  Specified by:
    `getBooleanValue` in class `AbleLiteral`
  Returns:
    A boolean, if the value of this object can be represented as a boolean value.
  Throws:
    `AbleDataException` - If the value of this object cannot be represented as a boolean value.

### getFuzzyValue

    public AbleFuzzySet getFuzzyValue()
                               throws AbleDataException

  Description copied from class: `AbleLiteral`
  Retrieve the value of this data object as a fuzzy value.

  Specified by:
    `getFuzzyValue` in interface `AbleRd`
  Specified by:
    `getFuzzyValue` in class `AbleLiteral`
  Returns:
    A fuzzy set, if the value of this object can be represented as a fuzzy value.
  Throws:
    `AbleDataException` - If the value of this object cannot be represented as a fuzzy value.

### getGenericValue

    public java.lang.Object getGenericValue()
                                     throws AbleDataException

  Description copied from class: `AbleLiteral`
  Retrieve the value of this data object as an Object.

  Specified by:
    `getGenericValue` in interface `AbleRd`
  Specified by:
    `getGenericValue` in class `AbleLiteral`
  Returns:
    A Boolean, Double, String or Object object depending on the derived class.
  Throws:
    `AbleDataException` - If the value of this object cannot be represented as an Object.

### getNumericValue

    public double getNumericValue()
                           throws AbleDataException

  Description copied from class: `AbleLiteral`
  Retrieve the value of this data object as a numeric value.

  Specified by:
    `getNumericValue` in interface `AbleRd`
  Specified by:
    `getNumericValue` in class `AbleLiteral`
  Returns:
    A double, if the value of this object can be represented as a numeric value.
  Throws:
    `AbleDataException` - If the value of this object cannot be represented as a numeric value.

### getStringValue

    public java.lang.String getStringValue()
                                    throws AbleDataException

  Description copied from class: `AbleLiteral`
  Retrieve the value of this data object as a string value.

  Specified by:
    `getStringValue` in interface `AbleRd`
  Specified by:
    `getStringValue` in class `AbleLiteral`
  Returns:
    A String, if the value of this object can be represented as a string value.
  Throws:
    `AbleDataException` - If the value of this object cannot be represented as a string value.

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

(C) Copyright IBM Corporation 1999, 2005