com.apama.services.scenario
Enum ParameterTypeEnum

java.lang.Object
  extended by java.lang.Enum<ParameterTypeEnum>
      extended by com.apama.services.scenario.ParameterTypeEnum
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ParameterTypeEnum>

public enum ParameterTypeEnum
extends java.lang.Enum<ParameterTypeEnum>

Enum class to model the "type" of scenario input/output parameters.

There are several type structures used when dealing with scenarios: Java types, MonitorScript types, and a kind of extension to MonitorScript types that are used within ScenarioManager to add support for enumerations. The point of this class to ease development of code that must deal with these types and conversions between them. Note that the Scenario enumeration type is modelled as a string in MonitorScript, and a java.lang.String in Java.

The following table shows the relationship between these type systems.

.............
ScenarioManager GUI Scenario Type MonitorScript Type Java Type
Text string string java.lang.String
Whole Number integer integer java.lang.Long
Number float float java.lang.Double
? ?decimal DecimalFieldValue
True/False boolean boolean java.lang.Boolean
Choice enumeration string java.lang.String

In releases prior to Apama 3.0, this was a class in the form of the standard type-safe enum pattern, but has been upgraded to a new style Java enum once the Java 5 language features were permitted in our code-base.


Enum Constant Summary
BOOLEAN
          Scenario boolean, MonitorScript boolean, Java Boolean, ScenarioManager GUI True/False.
DECIMAL
          Scenario decimal, MonitorScript decimal, Java Big Decimal, ScenarioManager GUI decimal.
ENUMERATION
          Scenario enumeration, MonitorScript string, Java String, ScenarioManager GUI Choice.
FLOAT
          Scenario float, MonitorScript float, Java Double, ScenarioManager GUI Number.
INTEGER
          Scenario integer, MonitorScript integer, Java Long, ScenarioManager GUI Whole Number.
STRING
          Scenario string, MonitorScript string, Java String, ScenarioManager GUI Text.
 
Method Summary
static boolean canDecodeString(java.lang.String value, ParameterTypeEnum paramType)
          Utility method to check whether a string representation of a parameter value (in the format used by the Correlator) can be converted to a Java object, based on its type identifier.
static java.lang.Object decodeString(java.lang.String value, ParameterTypeEnum paramType)
          Utility method to convert the EPL string representation of a parameter value to a Java object, based on its type identifier.
static ParameterTypeEnum fromScenarioType(java.lang.String stype)
          Static utility method to determine the enum value from the scenario version of a type.
 java.lang.Class<?> getJavaType()
          Get the Java type (class) that is used to represent parameters of this type.
 java.lang.String getMonitorScriptType()
          Get the MonitorScript type that is used internally within the correlator for variable of this type.
 java.lang.String getScenarioType()
          Get the type as defined in the Scenario definition file (sdf), and which is also returned from the correlator.
 java.lang.String toString()
          Override the toString() method of the Object class to return the scenario type.
static ParameterTypeEnum valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ParameterTypeEnum[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

STRING

public static final ParameterTypeEnum STRING
Scenario string, MonitorScript string, Java String, ScenarioManager GUI Text.


INTEGER

public static final ParameterTypeEnum INTEGER
Scenario integer, MonitorScript integer, Java Long, ScenarioManager GUI Whole Number.


FLOAT

public static final ParameterTypeEnum FLOAT
Scenario float, MonitorScript float, Java Double, ScenarioManager GUI Number.


DECIMAL

public static final ParameterTypeEnum DECIMAL
Scenario decimal, MonitorScript decimal, Java Big Decimal, ScenarioManager GUI decimal.


BOOLEAN

public static final ParameterTypeEnum BOOLEAN
Scenario boolean, MonitorScript boolean, Java Boolean, ScenarioManager GUI True/False.


ENUMERATION

public static final ParameterTypeEnum ENUMERATION
Scenario enumeration, MonitorScript string, Java String, ScenarioManager GUI Choice.

Method Detail

values

public static ParameterTypeEnum[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ParameterTypeEnum c : ParameterTypeEnum.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ParameterTypeEnum valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

getScenarioType

public java.lang.String getScenarioType()
Get the type as defined in the Scenario definition file (sdf), and which is also returned from the correlator.

Returns:
a String that specifies the Scenario type, e.g. "enumeration".

getMonitorScriptType

public java.lang.String getMonitorScriptType()
Get the MonitorScript type that is used internally within the correlator for variable of this type.

Returns:
a String that specifies the MonitorScript type, e.g. "string".

getJavaType

public java.lang.Class<?> getJavaType()
Get the Java type (class) that is used to represent parameters of this type.

Returns:
the java.lang.Class for the corresponding Java type. e.g. java.lang.String

toString

public java.lang.String toString()
Override the toString() method of the Object class to return the scenario type. The result is identical to that returned by getScenarioType().

Overrides:
toString in class java.lang.Enum<ParameterTypeEnum>

fromScenarioType

public static ParameterTypeEnum fromScenarioType(java.lang.String stype)
                                          throws ScenarioServiceException
Static utility method to determine the enum value from the scenario version of a type.

Returns:
One of the static predefined instances of this class, or null for any error case.
Throws:
ScenarioServiceException - if the parameter does not represent a valid type.

decodeString

public static java.lang.Object decodeString(java.lang.String value,
                                            ParameterTypeEnum paramType)
Utility method to convert the EPL string representation of a parameter value to a Java object, based on its type identifier. Note that this method is for decoding strings in the format used by the Correlator (see also the EventParser package for more classes to format and parse EPL strings). User interface code should normally use user-friendly locale-sensitive parsing methods instead.

If the value cannot be parsed, a warning is logged and a default value is returned; this method should not throw exceptions.

Parameters:
value - the stringified value to be decoded, in the format used by the Apama EPL.
paramType - the type identifier to indicate which type to convert to.
Returns:
an object of the correct type. If the paramType is null, the value will be returned unchanged.

canDecodeString

public static boolean canDecodeString(java.lang.String value,
                                      ParameterTypeEnum paramType)
Utility method to check whether a string representation of a parameter value (in the format used by the Correlator) can be converted to a Java object, based on its type identifier.

Parameters:
value - the stringified value to be decoded, in the format used by the Apama Correlator.
paramType - the type identifier to indicate which type to convert to.
Returns:
true if it can be decoded, false otherwise. If the paramType is null, return false.


Submit a bug or feature
Copyright (c) 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG