uk.ac.leeds.ccg.andyt.projects.moses.utilities
Class StaticConverter

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.projects.moses.utilities.StaticConverter

public abstract class StaticConverter
extends java.lang.Object

A class of static methods used to convert between types of Object and primitive.


Constructor Summary
StaticConverter()
           
 
Method Summary
static boolean to_boolean(java.lang.String aString)
           
static int to_int(java.lang.String aString)
           
static long to_long(java.lang.String aString)
           
static short to_short(java.lang.String aString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticConverter

public StaticConverter()
Method Detail

to_int

public static int to_int(java.lang.String aString)
Parameters:
aString - The String to be converted to an int.
Returns:
an int derived from aString. This does no checking: return new BigInteger(aString).intValue();

to_boolean

public static boolean to_boolean(java.lang.String aString)
Parameters:
aString - The String to be converted to a boolean.
Returns:
a boolean derived from aString. if (to_int(aString) == 1 || aString.equalsIgnoreCase("true")) { return true; } return false;

to_short

public static short to_short(java.lang.String aString)
Parameters:
aString - The String to be converted to an short.
Returns:
A short derived from aString. return (short) to_int(aString);

to_long

public static long to_long(java.lang.String aString)
Parameters:
aString - The String to be converted to a long.
Returns:
a long derived from aString. This tries to cope with exponential notation (e.g. 3.4E10) by catching NumberFormatExceptions when running: return new BigInteger(aString).longValue();