SMILA 1.0 API documentation

org.eclipse.smila.common.definitions
Class AccessAny

java.lang.Object
  extended by org.eclipse.smila.common.definitions.AccessAny

public final class AccessAny
extends java.lang.Object

Some job manager related helper methods to deal with Any and their Exception handling.


Field Summary
static DataFactory FACTORY
          factory for Any.
 
Method Summary
static Any get(AnyMap any, java.lang.String fieldName, Any.ValueType fieldType)
          get a field value from a Map and check that it has an expected type.
static boolean getBoolean(AnyMap any, java.lang.String fieldName, boolean defaultValue)
          get a boolean from a Map.
static AnySeq getSeq(AnyMap any, java.lang.String fieldName)
          get a sequence from a Map.
static java.lang.String getString(AnyMap any, java.lang.String fieldName)
          get a string from a Map.
static java.lang.String getStringRequired(AnyMap any, java.lang.String fieldName)
          like #getString(Any, String), but throw an exception if the field does not exists.
static java.util.List<java.lang.String> getStringSeq(AnyMap any, java.lang.String fieldName)
          get list of strings from a field of the any.
static java.lang.String getValidName(AnyMap any, java.lang.String fieldName)
          like #getStringRequired(Any, String), but throw an exception if value is not a valid name accoring to NameValidator.
static ValueExpression getValueExpression(AnyMap any, java.lang.String fieldName)
          get a value expression from a Map.
static ValueExpression getValueExpressionRequired(AnyMap any, java.lang.String fieldName)
          like #getValueExpression(Any, String), but throw an exception if the field does not exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY

public static final DataFactory FACTORY
factory for Any.

Method Detail

get

public static Any get(AnyMap any,
                      java.lang.String fieldName,
                      Any.ValueType fieldType)
               throws InvalidDefinitionException
get a field value from a Map and check that it has an expected type.

Parameters:
any - a map any.
fieldName - key.
fieldType - expected field type
Returns:
the value for the key or null if it doesn't exist.
Throws:
InvalidDefinitionException - any is not a map, value does not have expected type or error accessing any.

getValueExpression

public static ValueExpression getValueExpression(AnyMap any,
                                                 java.lang.String fieldName)
                                          throws InvalidDefinitionException
get a value expression from a Map.

Parameters:
any - a map any.
fieldName - key.
Returns:
the value expression for the key or null if it doesn't exist.
Throws:
InvalidDefinitionException - any is not a map, value is not a string or error accessing any.

getString

public static java.lang.String getString(AnyMap any,
                                         java.lang.String fieldName)
                                  throws InvalidDefinitionException
get a string from a Map.

Parameters:
any - a map any.
fieldName - key.
Returns:
the string for the key or null if it doesn't exist.
Throws:
InvalidDefinitionException - any is not a map, value is not a string or error accessing any.

getSeq

public static AnySeq getSeq(AnyMap any,
                            java.lang.String fieldName)
                     throws InvalidDefinitionException
get a sequence from a Map.

Parameters:
any - a map any.
fieldName - key.
Returns:
the sequence for the key or null if it doesn't exist.
Throws:
InvalidDefinitionException - any is not a map, value is not a sequence or error accessing any.

getBoolean

public static boolean getBoolean(AnyMap any,
                                 java.lang.String fieldName,
                                 boolean defaultValue)
                          throws InvalidDefinitionException
get a boolean from a Map. Accept the string values "true" or "false", too.

Parameters:
any - a map any.
fieldName - key.
defaultValue - value to return if key is not set.
Returns:
the boolean for the key
Throws:
InvalidDefinitionException - any is not a map, value is not a boolean or error accessing any.

getValueExpressionRequired

public static ValueExpression getValueExpressionRequired(AnyMap any,
                                                         java.lang.String fieldName)
                                                  throws InvalidDefinitionException
like #getValueExpression(Any, String), but throw an exception if the field does not exists.

Parameters:
any - a map any.
fieldName - key.
Returns:
the value expression for the key.
Throws:
InvalidDefinitionException - any is not a map, value does not exists or is not a string or error accessing any.

getStringRequired

public static java.lang.String getStringRequired(AnyMap any,
                                                 java.lang.String fieldName)
                                          throws InvalidDefinitionException
like #getString(Any, String), but throw an exception if the field does not exists.

Parameters:
any - a map any.
fieldName - key.
Returns:
the string for the key.
Throws:
InvalidDefinitionException - any is not a map, value does not exists or is not a string or error accessing any.

getValidName

public static java.lang.String getValidName(AnyMap any,
                                            java.lang.String fieldName)
                                     throws InvalidDefinitionException
like #getStringRequired(Any, String), but throw an exception if value is not a valid name accoring to NameValidator.

Parameters:
any - a map any.
fieldName - key.
Returns:
the name value for the key.
Throws:
InvalidDefinitionException - any is not a map, value does not exists or is not a string or not valid or error accessing any.

getStringSeq

public static java.util.List<java.lang.String> getStringSeq(AnyMap any,
                                                            java.lang.String fieldName)
                                                     throws InvalidDefinitionException
get list of strings from a field of the any.

Parameters:
any - a map any.
fieldName - key.
Returns:
the list of strings or null if the field does not exists.
Throws:
InvalidDefinitionException - any is not a map, value is not an sequence of strings or error accessing any.

SMILA 1.0 API documentation