unsw.cse.mica.util
Interface MicaProperties

All Known Implementing Classes:
ListProperties

public interface MicaProperties

An interface for the settings passed to an Agent at init time (and possibly for other things too). It provides functionality for a list of param-value pairs where duplicate non-null parameter names and null values allowed. It differs from the standard Java Properties in that it maintains its original ordering. This is useful as it allows Agents to accept order-specific initialization information. We use an interface so that any future changes will (hopefully) have less impact on existing code.

Author:
jhw

Method Summary
 void add(java.lang.String param, java.lang.String value)
          Add a param-value pair to the end of the properties.
 boolean getBooleanValue(java.lang.String param, boolean defaultValue)
          Get the boolean value for a given property name.
 double getDoubleValue(java.lang.String param, double defaultValue)
          Get the double value for a given property name.
 float getFloatValue(java.lang.String param, float defaultValue)
          Get the float value for a given property name.
 int getIntegerValue(java.lang.String param, int defaultValue)
          Get the integer value for a given property name.
 java.lang.String getParam(int pos)
          Get the param name of the param-value pair at the given index.
 int getSize()
          Get the number of param-value pairs
 java.lang.String getValue(int pos)
          Get the value of the param-value pair at the given index.
 java.lang.String getValue(java.lang.String param)
          Get the value for a given property name.
 java.lang.String getValue(java.lang.String param, java.lang.String defaultValue)
          Get the value for a given property name.
 boolean hasParam(java.lang.String param)
          check if there is a param with the given name
 void remove(java.lang.String param)
          Remove the first occurence of the given param.
 void replace(java.lang.String param, java.lang.String value)
          Replace the first occurrence of param with value.
 

Method Detail

hasParam

boolean hasParam(java.lang.String param)
check if there is a param with the given name

Parameters:
param - the name of the parameter to look for.
Returns:
true if there is a with the given name, false otherwise.

add

void add(java.lang.String param,
         java.lang.String value)
Add a param-value pair to the end of the properties.

Parameters:
param -
value -

replace

void replace(java.lang.String param,
             java.lang.String value)
Replace the first occurrence of param with value. If no occurences are found than add the param-value pair to the end.

Parameters:
param -
value -

remove

void remove(java.lang.String param)
Remove the first occurence of the given param.

Parameters:
param - the name of the parameter to be removed

getValue

java.lang.String getValue(java.lang.String param)
Get the value for a given property name. If there are multiple properties with the same name, the value of the first property with a matching name is returned.

Parameters:
param - The parameter whose value is to be obtained
Returns:
The value of a given parameter, or null if the is no parameter with the given name

getValue

java.lang.String getValue(java.lang.String param,
                          java.lang.String defaultValue)
Get the value for a given property name. If there are multiple properties with the same name, the value of the first property with a matching name is returned.

Parameters:
param - The parameter whose value is to be obtained
Returns:
The value of a given parameter, or the default value if the is no parameter with the given name

getBooleanValue

boolean getBooleanValue(java.lang.String param,
                        boolean defaultValue)
Get the boolean value for a given property name. If there are multiple properties with the same name, the value of the first property with a matching name is returned.

Parameters:
param - The parameter whose value is to be obtained
Returns:
The value of a given parameter, or the default value if the is no parameter with the given name

getIntegerValue

int getIntegerValue(java.lang.String param,
                    int defaultValue)
Get the integer value for a given property name. If there are multiple properties with the same name, the value of the first property with a matching name is returned.

Parameters:
param - The parameter whose value is to be obtained
Returns:
The value of a given parameter, or the default value if the is no parameter with the given name

getFloatValue

float getFloatValue(java.lang.String param,
                    float defaultValue)
Get the float value for a given property name. If there are multiple properties with the same name, the value of the first property with a matching name is returned.

Parameters:
param - The parameter whose value is to be obtained
Returns:
The value of a given parameter, or the default value if the is no parameter with the given name

getDoubleValue

double getDoubleValue(java.lang.String param,
                      double defaultValue)
Get the double value for a given property name. If there are multiple properties with the same name, the value of the first property with a matching name is returned.

Parameters:
param - The parameter whose value is to be obtained
Returns:
The value of a given parameter, or the default value if the is no parameter with the given name

getSize

int getSize()
Get the number of param-value pairs

Returns:
the number of properties

getParam

java.lang.String getParam(int pos)
Get the param name of the param-value pair at the given index.

Parameters:
pos - the index of the param name to be obtained
Returns:
The param name of the param-value pair at the given index, or null if the index is invalid.

getValue

java.lang.String getValue(int pos)
Get the value of the param-value pair at the given index.

Parameters:
pos - the index of the value to be obtained
Returns:
The value of the param-value pair at the given index, or null if the index is invalid.