uk.org.ogsadai.tools
Class EditorUtils

java.lang.Object
  extended by uk.org.ogsadai.tools.EditorUtils

public class EditorUtils
extends java.lang.Object

Editor utilities.

Author:
The OGSA-DAI Project Team

Constructor Summary
EditorUtils()
           
 
Method Summary
static void addKeyValue(KeyValueProperties properties, java.lang.String keyString, java.lang.String value)
          Add a configuration property.
static void deleteKeyValue(KeyValueProperties properties, java.lang.String keyString)
          Delete a configuration property.
static java.lang.String getArgument(java.lang.String[] arguments, int index, java.lang.String error)
          Get the ith argument from an array.
static void getKeyValue(KeyValueProperties properties, java.lang.String keyString)
          Get a configuration property.
static void invokeStringMethod(java.lang.Object object, java.lang.String method, java.lang.String[] arguments)
          Invoke by reflection a method that takes 0 or more string arguments.
static void listKeys(KeyValueProperties properties)
          List configuration property keys only.
static void listKeyValues(KeyValueProperties properties)
          List key-value properties properties.
static void printException(java.lang.Throwable e)
          Print an exception chain, displaying the localized messages.
static void purgeKeyValues(KeyValueProperties properties)
          Purge configuration properties.
static java.util.List<java.lang.String> tokenize(java.lang.String str)
          Tokenize the given string into a list of strings.
static java.util.List<java.lang.String> tokenizeRegexp(java.lang.String str)
          Tokenize the given string into a list of strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditorUtils

public EditorUtils()
Method Detail

invokeStringMethod

public static void invokeStringMethod(java.lang.Object object,
                                      java.lang.String method,
                                      java.lang.String[] arguments)
                               throws ConfigEditorException
Invoke by reflection a method that takes 0 or more string arguments.

Parameters:
object - Object.
method - Method name.
arguments - Arguments.
Throws:
ConfigEditorException - If there is a problem in the invocation.

printException

public static void printException(java.lang.Throwable e)
Print an exception chain, displaying the localized messages.

Parameters:
e - Exception.

tokenizeRegexp

public static java.util.List<java.lang.String> tokenizeRegexp(java.lang.String str)
Tokenize the given string into a list of strings. Space is used as the delimiter. If there are quoted sub-strings then these are returned as single tokens.

Parameters:
str - String.
Returns:
tokens.

tokenize

public static java.util.List<java.lang.String> tokenize(java.lang.String str)
                                                 throws java.io.IOException
Tokenize the given string into a list of strings. Space is used as the delimiter. If there are quoted sub-strings then these are returned as single tokens.

Parameters:
str - String.
Returns:
tokens.
Throws:
java.io.IOException - If any problems arise.

listKeyValues

public static void listKeyValues(KeyValueProperties properties)
List key-value properties properties.

Parameters:
properties - Key-value properties.

listKeys

public static void listKeys(KeyValueProperties properties)
List configuration property keys only.

Parameters:
properties - Key-value properties.

getKeyValue

public static void getKeyValue(KeyValueProperties properties,
                               java.lang.String keyString)
                        throws KeyValueUnknownException
Get a configuration property.

Parameters:
properties - Key-value properties.
keyString - Key as a string.
Throws:
KeyValueUnknownException - If the key is not known to the configuration properties.

deleteKeyValue

public static void deleteKeyValue(KeyValueProperties properties,
                                  java.lang.String keyString)
                           throws KeyValueUnknownException
Delete a configuration property.

Parameters:
properties - Key-value properties.
keyString - Key as a string.
Throws:
KeyValueUnknownException - If the key is not known to the configuration properties.

addKeyValue

public static void addKeyValue(KeyValueProperties properties,
                               java.lang.String keyString,
                               java.lang.String value)
Add a configuration property.

Parameters:
properties - Key-value properties.
keyString - Key as a string.
value - Value.

purgeKeyValues

public static void purgeKeyValues(KeyValueProperties properties)
Purge configuration properties.

Parameters:
properties - Key-value properties.

getArgument

public static java.lang.String getArgument(java.lang.String[] arguments,
                                           int index,
                                           java.lang.String error)
Get the ith argument from an array. If it is not there (i.e. i is outwith the bounds of the array) then throw an exception with the given error message.

Parameters:
arguments - Array of arguments.
index - Index of requested argument.
error - Error message.
Returns:
argument.
Throws:
java.lang.IllegalArgumentException - If the index is out of bounds. The exception will contain the given error message.