utilities
Class Converter

java.lang.Object
  |
  +--utilities.Converter

public class Converter
extends java.lang.Object

Converts stuff to and from strings


Constructor Summary
Converter()
           
 
Method Summary
static java.lang.String getPropertyType(java.lang.Object property)
          This method returns the property type name, in string form, of the supplied property
static java.lang.Object reTypeProperty(java.lang.String property, java.lang.String type)
          This method converts string data to other formats, as specified by their property info.
static java.lang.String unTypeProperty(java.lang.Object property, java.lang.String delim)
          This method converts typed data to string representation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Method Detail

reTypeProperty

public static java.lang.Object reTypeProperty(java.lang.String property,
                                              java.lang.String type)
This method converts string data to other formats, as specified by their property info. Useful when reading data from the config file, or wherever. Currently supported formats are String, Long, Integer, Float, Double, Short, Boolean, Vector (str1,str2,str3...), and Hashtable (key1,obj1,key2,obj2...).

For those items which are lists (e.g. Vector, Hashtable), you may optionally set the object delimiter in the property. To do this, follow this example:

MyVector: DELIM=; Item 1;Item 2;Item 3;...

The default delimiter is a comma, note that the contents of aggregate types (Vector, Hashtable) will be converted to Strings.

This function and its companion unTypeProperty may be useful to other components doing string/data processing.

Parameters:
property - The data to change
type - The type to change it to
Returns:
The typed, converted data, or null if error
See Also:
unTypeProperty(java.lang.Object, java.lang.String)

getPropertyType

public static java.lang.String getPropertyType(java.lang.Object property)
This method returns the property type name, in string form, of the supplied property
Parameters:
property - The data to look at
Returns:
The type name for property, or null if unrecognized

unTypeProperty

public static java.lang.String unTypeProperty(java.lang.Object property,
                                              java.lang.String delim)
This method converts typed data to string representation. This function essentially reverses the behavior of reTypeProperty
Parameters:
property - The data to change
delim - The delim to use, if any
Returns:
The untyped, stringified data, or null if error
See Also:
reTypeProperty(java.lang.String, java.lang.String)