com.frinika.contrib.boblang
Class Convert

java.lang.Object
  extended by com.frinika.contrib.boblang.Convert

public class Convert
extends java.lang.Object

Text conversion and formatting methods. Each method is static.

The methods are divided into two groups:

Methods for converting and formatting values into strings are:

Methods for converting strings to values are:

Version:
Thu Nov 15 2001
Author:
Bob Lang
See Also:
TextInput, TextOutput

Constructor Summary
Convert()
          This class only contains static methods.
 
Method Summary
static java.lang.String doubleToString(double d, int width, int decimal)
          Convert a double to a string.
static java.lang.String floatToString(float f, int width, int decimal)
          Convert a float to a string.
static java.lang.String intToString(int i, int width)
          Convert a standard integer to a string.
static boolean isValidDouble(java.lang.String s)
          Test if the characters in a string may be converted into a double value.
static boolean isValidFloat(java.lang.String s)
          Test if the characters in a string may be converted into a float value.
static boolean isValidInt(java.lang.String s)
          Test if the characters in a string may be converted into an integer.
static boolean isValidLong(java.lang.String s)
          Test if the characters in a string may be converted into a long integer.
static boolean isValidShort(java.lang.String s)
          Test if the characters in a string may be converted into a short integer.
static java.lang.String longToString(long l, int width)
          Convert a long integer to a string.
static java.lang.String shortToString(short s, int width)
          Convert a short integer to a string.
static double stringToDouble(java.lang.String s, double defaultValue)
          Convert a string to a double.
static float stringToFloat(java.lang.String s, float defaultValue)
          Convert a string to a float.
static int stringToInt(java.lang.String s, int defaultValue)
          Convert a string to a int.
static long stringToLong(java.lang.String s, long defaultValue)
          Convert a string to a long.
static short stringToShort(java.lang.String s, short defaultValue)
          Convert a string to a short.
static java.lang.String version()
          Return the version of this class as a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Convert

public Convert()
This class only contains static methods. There is no need to call its constructor.

Method Detail

version

public static java.lang.String version()
Return the version of this class as a String


doubleToString

public static java.lang.String doubleToString(double d,
                                              int width,
                                              int decimal)
Convert a double to a string. See documentation at start of class for parameter usage.

Example call:

String s = Convert.doubleToString (doubleValue, width, decimal);


floatToString

public static java.lang.String floatToString(float f,
                                             int width,
                                             int decimal)
Convert a float to a string. See documentation at start of class for parameter usage.

Example call:

String s = Convert.floatToString (floatValue, width, decimal);


longToString

public static java.lang.String longToString(long l,
                                            int width)
Convert a long integer to a string. See documentation at start of class for parameter usage.

Example call:

String s = Convert.longToString (longValue, width);


intToString

public static java.lang.String intToString(int i,
                                           int width)
Convert a standard integer to a string. See documentation at start of class for parameter usage.

Example call:

String s = Convert.intToString (intValue, width);


shortToString

public static java.lang.String shortToString(short s,
                                             int width)
Convert a short integer to a string. See documentation at start of class for parameter usage.

Example call:

String s = Convert.shortToString (shortValue, width);


isValidDouble

public static boolean isValidDouble(java.lang.String s)
Test if the characters in a string may be converted into a double value.

Example call:

boolean b = Convert.isValidDouble (digitString);


stringToDouble

public static double stringToDouble(java.lang.String s,
                                    double defaultValue)
Convert a string to a double. If the string is not a valid double value then the default value is returned. The string may be checked for validity by calling isValidDouble ()

Example call:

double val = Convert.stringToDouble (digitString, defaultValue);


isValidFloat

public static boolean isValidFloat(java.lang.String s)
Test if the characters in a string may be converted into a float value.

Example call:

boolean b = Convert.isValidFloat (digitString);


stringToFloat

public static float stringToFloat(java.lang.String s,
                                  float defaultValue)
Convert a string to a float. If the string is not a valid float value then the default value is returned. The string may be checked for validity by calling isValidFloat ()

Example call:

float val = Convert.stringToFloat (digitString, (float) defaultValue);


isValidLong

public static boolean isValidLong(java.lang.String s)
Test if the characters in a string may be converted into a long integer.

Example call:

boolean b = Convert.isValidLong (digitString);


stringToLong

public static long stringToLong(java.lang.String s,
                                long defaultValue)
Convert a string to a long. If the string is not a valid long value then the default value is returned. The string may be checked for validity by calling isValidLong ()

Example call:

long val = Convert.stringToLong (digitString, (long) defaultValue);


isValidInt

public static boolean isValidInt(java.lang.String s)
Test if the characters in a string may be converted into an integer.

Example call:

boolean b = Convert.isValidInt (digitString);


stringToInt

public static int stringToInt(java.lang.String s,
                              int defaultValue)
Convert a string to a int. If the string is not a valid int value then the default value is returned. The string may be checked for validity by calling isValidInt ()

Example call:

int val = Convert.stringToInt (digitString, defaultValue);


isValidShort

public static boolean isValidShort(java.lang.String s)
Test if the characters in a string may be converted into a short integer.

Example call:

boolean b = Convert.isValidShort (digitString);


stringToShort

public static short stringToShort(java.lang.String s,
                                  short defaultValue)
Convert a string to a short. If the string is not a valid short value then the default value is returned. The string may be checked for validity by calling isValidShort ()

Example call:

short val = Convert.stringToShort (digitString, (short) defaultValue);