de.zeigermann.xml.simpleImporter

Class ConversionHelpers


public class ConversionHelpers
extends java.lang.Object

Collection of some simple conversion and fallback methods for convenience.
Author:
Olli Z.

Method Summary

static boolean
getBoolean(String value, boolean fallBack)
Gets boolean value a string value.
static int
getInt(String value)
Gets int value from a string value.
static int
getInt(String value, int fallBack)
Gets int value from a string value.
static long
getLong(String value)
Gets long value from a string value.
static long
getLong(String value, long fallBack)
Gets long value from a string value.
static String
getString(String value, String fallBack)
Returns value if not null, otherwise fallBack.

Method Details

getBoolean

public static boolean getBoolean(String value,
                                 boolean fallBack)
Gets boolean value a string value.
Parameters:
value - string value to get boolean from
fallBack - fall back value
Returns:
boolean representation of value fallBack if it can not properly be converted to a boolean

getInt

public static int getInt(String value)
Gets int value from a string value.
Parameters:
value - string value to get int from
Returns:
int representation of value or -1 if it can not be converted to an int

getInt

public static int getInt(String value,
                         int fallBack)
Gets int value from a string value.
Parameters:
value - string value to get int from
fallBack - fall back value
Returns:
int representation of value or fallBack if it can not be converted to an int

getLong

public static long getLong(String value)
Gets long value from a string value.
Parameters:
value - string value to get long from
Returns:
long representation of value or -1L if it can not be converted to a long

getLong

public static long getLong(String value,
                           long fallBack)
Gets long value from a string value.
Parameters:
value - string value to get long from
fallBack - fall back value
Returns:
long representation of value or fallBack if it can not be converted to a long

getString

public static String getString(String value,
                               String fallBack)
Returns value if not null, otherwise fallBack.

Copyright © 2002-2004 Oliver Zeigermann. All Rights Reserved.