ubiware.core
Class BehaviorStartParameters

java.lang.Object
  extended by ubiware.core.BehaviorStartParameters

public class BehaviorStartParameters
extends java.lang.Object

Collection maintaining a list of BehaviorStartParameters. The collection can be queried for values of certain parameters. The current implementation is an improved version from the previous implementations in GuiAgent, ReusableAtomicBehavior and UbiwareAgent.

22.3.2010

Author:
Michael Cochez for UBIWARE project

Field Summary
(package private)  java.util.List<java.lang.String> addOnEnd
           
(package private)  java.util.List<java.lang.String> addOnFail
           
(package private)  java.util.List<java.lang.String> addOnStart
          A behaviour can have parameters like sapl:Success sapl:add ...
(package private)  java.util.List<java.lang.String> addOnSuccess
           
(package private)  java.util.List<java.lang.String> removeOnEnd
           
(package private)  java.util.List<java.lang.String> removeOnFail
           
(package private)  java.util.List<java.lang.String> removeOnStart
           
(package private)  java.util.List<java.lang.String> removeOnSuccess
           
 
Constructor Summary
BehaviorStartParameters()
           
 
Method Summary
 void add(ubiware.util.saplbuilder.Resource parameter, java.lang.String value)
          Add a parameter to the collection.
 boolean getObligatedBooleanParameter(ubiware.util.saplbuilder.Resource name)
          Returns a boolean representation of the value for that parameter
 java.lang.String getObligatedContainerID(ubiware.util.saplbuilder.Resource name)
          Get the value for the given resource.
 java.io.File getObligatedFileParameter(ubiware.util.saplbuilder.Resource name)
          Returns the File for the value of the parameter
 java.lang.String getObligatedNonEmptyStringParameter(ubiware.util.saplbuilder.Resource name)
          Returns a non empty String representation of the value for that parameter
 int getObligatedNumericParameter(ubiware.util.saplbuilder.Resource name)
          Returns a int representation of the value for that parameter.
 ubiware.util.saplbuilder.Resource getObligatedResourceParameter(ubiware.util.saplbuilder.Resource name)
          Returns the Resource given as a value for the given parameter.
 java.lang.String getObligatedStringParameter(ubiware.util.saplbuilder.Resource name)
          Returns a String representation of the value for that parameter
 java.net.URL getObligatedURLParameter(ubiware.util.saplbuilder.Resource name)
          Returns the URL for the value of the parameter
 java.lang.Boolean getOptionalBooleanParameter(ubiware.util.saplbuilder.Resource name)
          Returns a Boolean representation of the value for that parameter if it exists, otherwise null is returned.
 boolean getOptionalBooleanParameter(ubiware.util.saplbuilder.Resource name, boolean defaultValue)
          Returns a Boolean representation of the value for that parameter if it exists, otherwise the default is returned.
 java.lang.String getOptionalContainerID(ubiware.util.saplbuilder.Resource name)
          Get the value for the given resource.
 java.lang.String getOptionalContainerID(ubiware.util.saplbuilder.Resource name, java.lang.String defaultValue)
          Get the value for the given resource.
 java.io.File getOptionalFileParameter(ubiware.util.saplbuilder.Resource name)
          Returns the File for the value of the parameter or null if there is no such parameter.
 java.io.File getOptionalFileParameter(ubiware.util.saplbuilder.Resource name, java.io.File defaultValue)
          Returns the File for the value of the parameter or the default if there is no such parameter.
 java.lang.Integer getOptionalNumericParameter(ubiware.util.saplbuilder.Resource name)
          Returns a Integer representation of the value for that parameter if it exists, otherwise null is returned.
 int getOptionalNumericParameter(ubiware.util.saplbuilder.Resource name, int defaultValue)
          Returns a Integer representation of the value for that parameter if it exists, otherwise the default is returned.
 ubiware.util.saplbuilder.Resource getOptionalResourceParameter(ubiware.util.saplbuilder.Resource name)
          Returns the Resource given as a value for the given parameter or null if the parameter is not specified.
 ubiware.util.saplbuilder.Resource getOptionalResourceParameter(ubiware.util.saplbuilder.Resource name, ubiware.util.saplbuilder.Resource defaultValue)
          Returns the Resource given as a value for the given parameter or the default if the parameter is not specified.
 java.lang.String getOptionalStringParameter(ubiware.util.saplbuilder.Resource name)
          Returns a String representation of the value for that parameter if it exists, otherwise null is returned.
 java.lang.String getOptionalStringParameter(ubiware.util.saplbuilder.Resource name, java.lang.String defaultValue)
          Returns a String representation of the value for that parameter if it exists, otherwise null is returned.
 java.net.URL getOptionalURLParameter(ubiware.util.saplbuilder.Resource name)
          Returns the URL for the value of the parameter or null if there is no such parameter.
 java.net.URL getOptionalURLParameter(ubiware.util.saplbuilder.Resource name, java.net.URL defaultValue)
          Returns the URL for the value of the parameter or the default if there is no such parameter.
(package private)  com.google.common.collect.Multimap<ubiware.util.saplbuilder.Resource,java.lang.String> getParameters()
          get an unmodifiable collection containing all parameters added.
 java.lang.String getParameterValue(ubiware.util.saplbuilder.Resource name)
          Retrieves the value of the parameter from the collection.
 java.util.Collection<java.lang.String> getParameterValues(ubiware.util.saplbuilder.Resource name)
          retrieves all the values of the parameter with the given parameter name from the collection in an unmodifiable collection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addOnStart

final java.util.List<java.lang.String> addOnStart
A behaviour can have parameters like sapl:Success sapl:add ... and so on. This class keeps references to the ID's of the contexts. Those values will be empty if they are not set. Otherwise ID's of contexts. These fields are only visible in this package, rab's do not need direct access to these variables.


addOnEnd

final java.util.List<java.lang.String> addOnEnd

addOnFail

final java.util.List<java.lang.String> addOnFail

addOnSuccess

final java.util.List<java.lang.String> addOnSuccess

removeOnStart

final java.util.List<java.lang.String> removeOnStart

removeOnEnd

final java.util.List<java.lang.String> removeOnEnd

removeOnFail

final java.util.List<java.lang.String> removeOnFail

removeOnSuccess

final java.util.List<java.lang.String> removeOnSuccess
Constructor Detail

BehaviorStartParameters

public BehaviorStartParameters()
Method Detail

add

public void add(ubiware.util.saplbuilder.Resource parameter,
                java.lang.String value)
Add a parameter to the collection.

Parameters:
parameter - The resource of the parameter.
value - The value of the parameter.

getParameters

com.google.common.collect.Multimap<ubiware.util.saplbuilder.Resource,java.lang.String> getParameters()
get an unmodifiable collection containing all parameters added.

Returns:

getParameterValue

public java.lang.String getParameterValue(ubiware.util.saplbuilder.Resource name)
                                   throws IllegalParameterConfigurationException
Retrieves the value of the parameter from the collection. If the no such parameter exists, null is returned.

Parameters:
name - the parameter name
Returns:
the value of the parameter
Throws:
IllegalParameterConfigurationException - If multiple values are specified for this parameter.

getParameterValues

public java.util.Collection<java.lang.String> getParameterValues(ubiware.util.saplbuilder.Resource name)
retrieves all the values of the parameter with the given parameter name from the collection in an unmodifiable collection

Parameters:
name - the parameter name
Returns:
the values bound to this parameter

getObligatedStringParameter

public java.lang.String getObligatedStringParameter(ubiware.util.saplbuilder.Resource name)
                                             throws IllegalParameterConfigurationException
Returns a String representation of the value for that parameter

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter.
Throws:
IllegalParameterConfigurationException - If there is no argument with name name

getObligatedNonEmptyStringParameter

public java.lang.String getObligatedNonEmptyStringParameter(ubiware.util.saplbuilder.Resource name)
                                                     throws IllegalParameterConfigurationException
Returns a non empty String representation of the value for that parameter

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter.
Throws:
IllegalParameterConfigurationException - If there is no argument with name name or the argument value is empty.

getOptionalStringParameter

public java.lang.String getOptionalStringParameter(ubiware.util.saplbuilder.Resource name)
                                            throws IllegalParameterConfigurationException
Returns a String representation of the value for that parameter if it exists, otherwise null is returned.

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter or null if it doesn't exist.
Throws:
IllegalParameterConfigurationException - thrown if more as one binding for this parameter is found.

getOptionalStringParameter

public java.lang.String getOptionalStringParameter(ubiware.util.saplbuilder.Resource name,
                                                   java.lang.String defaultValue)
                                            throws IllegalParameterConfigurationException
Returns a String representation of the value for that parameter if it exists, otherwise null is returned.

Parameters:
name - The name of the parameter.
defaultValue - The default value if the parameter does not exist.
Returns:
The value of the parameter or null if it doesn't exist.
Throws:
IllegalParameterConfigurationException - thrown if more as one binding for this parameter is found.

getObligatedContainerID

public java.lang.String getObligatedContainerID(ubiware.util.saplbuilder.Resource name)
                                         throws IllegalParameterConfigurationException
Get the value for the given resource. If the value is not specified, or is not a container ID, an IllegalParameterConfigurationException is thrown.

Parameters:
name - The name of the parameter.
Returns:
The String representation of the container ID
Throws:
IllegalParameterConfigurationException - If no such parameter is specified or the value is not a container ID.

getOptionalContainerID

public java.lang.String getOptionalContainerID(ubiware.util.saplbuilder.Resource name)
                                        throws IllegalParameterConfigurationException
Get the value for the given resource. If the value is not a container ID, an IllegalParameterConfigurationException is thrown. If the value is not specified, null is returned.

Parameters:
name - The name of the parameter.
Returns:
The String representation of the container ID or null if not specified.
Throws:
IllegalParameterConfigurationException - If the parameter is specified and the value is not a container ID.

getOptionalContainerID

public java.lang.String getOptionalContainerID(ubiware.util.saplbuilder.Resource name,
                                               java.lang.String defaultValue)
                                        throws IllegalParameterConfigurationException
Get the value for the given resource. If the value is not a container ID, an IllegalParameterConfigurationException is thrown. If the value is not specified, the default value is returned.

Parameters:
name - The name of the parameter.
defaultValue - The default value which will be returned in case this parameter is not specified.
Returns:
The String representation of the container ID
Throws:
IllegalParameterConfigurationException - If the parameter is specified and the value is not a container ID.

getObligatedBooleanParameter

public boolean getObligatedBooleanParameter(ubiware.util.saplbuilder.Resource name)
                                     throws IllegalParameterConfigurationException
Returns a boolean representation of the value for that parameter

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter.
Throws:
IllegalParameterConfigurationException - If there is no argument with name name or the value is not "true" or "false"

getOptionalBooleanParameter

public java.lang.Boolean getOptionalBooleanParameter(ubiware.util.saplbuilder.Resource name)
                                              throws IllegalParameterConfigurationException
Returns a Boolean representation of the value for that parameter if it exists, otherwise null is returned.

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter or null if it doesn't exist.
Throws:
IllegalParameterConfigurationException - If there is a value but it is none of "true" or "false". Or, if there are multiple bindings for this variable.

getOptionalBooleanParameter

public boolean getOptionalBooleanParameter(ubiware.util.saplbuilder.Resource name,
                                           boolean defaultValue)
                                    throws IllegalParameterConfigurationException
Returns a Boolean representation of the value for that parameter if it exists, otherwise the default is returned.

Parameters:
name - The name of the parameter.
defaultValue - The default value, which will be returned in case this parameter is not specified.
Returns:
The value of the parameter or null if it doesn't exist.
Throws:
IllegalParameterConfigurationException - If there is a value but it is none of "true" or "false". Or, if there are multiple bindings for this variable.

getObligatedNumericParameter

public int getObligatedNumericParameter(ubiware.util.saplbuilder.Resource name)
                                 throws IllegalParameterConfigurationException
Returns a int representation of the value for that parameter.

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter.
Throws:
IllegalParameterConfigurationException - If there is no argument with name name or the value triggers a NumberFormatException in Integer.parseInt(String)

getOptionalNumericParameter

public java.lang.Integer getOptionalNumericParameter(ubiware.util.saplbuilder.Resource name)
                                              throws IllegalParameterConfigurationException
Returns a Integer representation of the value for that parameter if it exists, otherwise null is returned.

Parameters:
name - The name of the parameter.
Returns:
The value of the parameter or null if it doesn't exist.
Throws:
IllegalParameterConfigurationException - If the value is specified but not convertible to integer by Integer.parseInt(String)

getOptionalNumericParameter

public int getOptionalNumericParameter(ubiware.util.saplbuilder.Resource name,
                                       int defaultValue)
                                throws IllegalParameterConfigurationException
Returns a Integer representation of the value for that parameter if it exists, otherwise the default is returned.

Parameters:
name - The name of the parameter.
defaultValue - The value which will be returned in case the parameter is not specified.
Returns:
The value of the parameter or null if it doesn't exist.
Throws:
IllegalParameterConfigurationException - If the value is specified but is not convertible to integer by Integer.parseInt(String)

getObligatedFileParameter

public java.io.File getObligatedFileParameter(ubiware.util.saplbuilder.Resource name)
                                       throws IllegalParameterConfigurationException
Returns the File for the value of the parameter

Parameters:
name - The name of the parameter.
Returns:
The File.
Throws:
IllegalParameterConfigurationException - If there is no argument with name name. TODO should there be more checks on this object?

getOptionalFileParameter

public java.io.File getOptionalFileParameter(ubiware.util.saplbuilder.Resource name)
                                      throws IllegalParameterConfigurationException
Returns the File for the value of the parameter or null if there is no such parameter.

Parameters:
name - The name of the parameter.
Returns:
The File.
Throws:
IllegalParameterConfigurationException - Never thrown at the moment, might be if more checks get implemented. TODO should there be more checks on this object?

getOptionalFileParameter

public java.io.File getOptionalFileParameter(ubiware.util.saplbuilder.Resource name,
                                             java.io.File defaultValue)
                                      throws IllegalParameterConfigurationException
Returns the File for the value of the parameter or the default if there is no such parameter.

Parameters:
name - The name of the parameter.
defaultValue - The default which will be returned in case this parameter is not specified.
Returns:
The File.
Throws:
IllegalParameterConfigurationException - Never thrown at the moment, might be if more checks get implemented. TODO should there be more checks on this object?

getObligatedURLParameter

public java.net.URL getObligatedURLParameter(ubiware.util.saplbuilder.Resource name)
                                      throws IllegalParameterConfigurationException
Returns the URL for the value of the parameter

Parameters:
name - The name of the parameter.
Returns:
The URL.
Throws:
IllegalParameterConfigurationException - If there is no argument with name name or does not have a value which is a valid URL. TODO should there be more checks on this object?

getOptionalURLParameter

public java.net.URL getOptionalURLParameter(ubiware.util.saplbuilder.Resource name)
                                     throws IllegalParameterConfigurationException
Returns the URL for the value of the parameter or null if there is no such parameter.

Parameters:
name - The name of the parameter.
Returns:
The URL.
Throws:
IllegalParameterConfigurationException - If the argument is given, but does not have a value which is a valid URL. TODO should there be more checks on this object?

getOptionalURLParameter

public java.net.URL getOptionalURLParameter(ubiware.util.saplbuilder.Resource name,
                                            java.net.URL defaultValue)
                                     throws IllegalParameterConfigurationException
Returns the URL for the value of the parameter or the default if there is no such parameter.

Parameters:
name - The name of the parameter.
defaultValue - The default which will be returned in case this parameter is not specified.
Returns:
The URL.
Throws:
IllegalParameterConfigurationException - If the argument is given, but does not have a value which is a valid URL. TODO should there be more checks on this object?

getObligatedResourceParameter

public ubiware.util.saplbuilder.Resource getObligatedResourceParameter(ubiware.util.saplbuilder.Resource name)
                                                                throws IllegalParameterConfigurationException
Returns the Resource given as a value for the given parameter.

Parameters:
name - The parameter name.
Returns:
The Resource specified as a parameter value.
Throws:
IllegalParameterConfigurationException - If the parameter is not specified or is not convertible to a resource.

getOptionalResourceParameter

public ubiware.util.saplbuilder.Resource getOptionalResourceParameter(ubiware.util.saplbuilder.Resource name)
                                                               throws IllegalParameterConfigurationException
Returns the Resource given as a value for the given parameter or null if the parameter is not specified.

Parameters:
name - The parameter name.
Returns:
The Resource specified as a parameter value or the null if the parameter is not specified.
Throws:
IllegalParameterConfigurationException - If the parameter is specified but is not convertible to a resource.

getOptionalResourceParameter

public ubiware.util.saplbuilder.Resource getOptionalResourceParameter(ubiware.util.saplbuilder.Resource name,
                                                                      ubiware.util.saplbuilder.Resource defaultValue)
                                                               throws IllegalParameterConfigurationException
Returns the Resource given as a value for the given parameter or the default if the parameter is not specified.

Parameters:
name - The parameter name.
defaultValue - The default value which will be returned in case the parameter is not specified.
Returns:
The Resource specified as a parameter value or the default if the parameter is not specified.
Throws:
IllegalParameterConfigurationException - If the parameter is specified but is not convertible to a resource.