unsw.cse.mica.util
Class ListProperties

java.lang.Object
  extended by unsw.cse.mica.util.ListProperties
All Implemented Interfaces:
MicaProperties

public class ListProperties
extends java.lang.Object
implements MicaProperties

A concrete implementation of the MicaProperties interface

Author:
Waleed
See Also:
MicaProperties

Constructor Summary
ListProperties()
           
ListProperties(ListProperties properties)
           
 
Method Summary
 void add(java.lang.String param)
          Adds a parameter with no value.
 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 readFromStringArray(java.lang.String[] arr)
          Converts an array created by the "writeToStringArray" back into the normal param-value format, including any necessary decoding of encoded charactes in the param part of the string.
 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.
 java.lang.String toString()
           
 java.lang.String[] writeToStringArray()
          Helper function to convert the param-value pairs into uniquely reversible strings that are then placed into a 1-D String array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListProperties

public ListProperties()

ListProperties

public ListProperties(ListProperties properties)
Method Detail

add

public void add(java.lang.String param)
Adds a parameter with no value.

Parameters:
param - the name of the parameter

add

public void add(java.lang.String param,
                java.lang.String value)
Description copied from interface: MicaProperties
Add a param-value pair to the end of the properties.

Specified by:
add in interface MicaProperties

replace

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

Specified by:
replace in interface MicaProperties

remove

public void remove(java.lang.String param)
Description copied from interface: MicaProperties
Remove the first occurence of the given param.

Specified by:
remove in interface MicaProperties
Parameters:
param - the name of the parameter to be removed

hasParam

public boolean hasParam(java.lang.String param)
Description copied from interface: MicaProperties
check if there is a param with the given name

Specified by:
hasParam in interface MicaProperties
Parameters:
param - the name of the parameter to look for.
Returns:
true if there is a with the given name, false otherwise.

getValue

public java.lang.String getValue(java.lang.String param)
Description copied from interface: MicaProperties
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.

Specified by:
getValue in interface MicaProperties
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

public java.lang.String getValue(java.lang.String param,
                                 java.lang.String defaultValue)
Description copied from interface: MicaProperties
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.

Specified by:
getValue in interface MicaProperties
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

public boolean getBooleanValue(java.lang.String param,
                               boolean defaultValue)
Description copied from interface: MicaProperties
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.

Specified by:
getBooleanValue in interface MicaProperties
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

public int getIntegerValue(java.lang.String param,
                           int defaultValue)
Description copied from interface: MicaProperties
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.

Specified by:
getIntegerValue in interface MicaProperties
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

public float getFloatValue(java.lang.String param,
                           float defaultValue)
Description copied from interface: MicaProperties
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.

Specified by:
getFloatValue in interface MicaProperties
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

public double getDoubleValue(java.lang.String param,
                             double defaultValue)
Description copied from interface: MicaProperties
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.

Specified by:
getDoubleValue in interface MicaProperties
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

public int getSize()
Description copied from interface: MicaProperties
Get the number of param-value pairs

Specified by:
getSize in interface MicaProperties
Returns:
the number of properties

getParam

public java.lang.String getParam(int pos)
Description copied from interface: MicaProperties
Get the param name of the param-value pair at the given index.

Specified by:
getParam in interface MicaProperties
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

public java.lang.String getValue(int pos)
Description copied from interface: MicaProperties
Get the value of the param-value pair at the given index.

Specified by:
getValue in interface MicaProperties
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.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeToStringArray

public java.lang.String[] writeToStringArray()
Helper function to convert the param-value pairs into uniquely reversible strings that are then placed into a 1-D String array. Used by the agent handler to pass parameters to the child process. The strings take the form param=value, with any '=' and '&' characters in the 'param' part of the string having been escaped (converted to "&eq;" and "&" respectively). If the value of a param-value pair is null, the '=' symbol is dropped.

Returns:
A 1-D string array containing the param-values in the encoded form

readFromStringArray

public void readFromStringArray(java.lang.String[] arr)
Converts an array created by the "writeToStringArray" back into the normal param-value format, including any necessary decoding of encoded charactes in the param part of the string.