com.neilmoomey.util
Class Type

java.lang.Object
  |
  +--com.neilmoomey.util.Type

public final class Type
extends java.lang.Object

A common source of frustration for Java programmers is strongly typed variables. I created this class to help solve that problem. Use this static class to easily convert any Java type to any other Java type. Works with byte, double, float, int, long, short, and String. It includes error checking to warn you when exceeding the range of a data type. Just add the jar file to your CLASSPATH and follow this example. Because it's a static class you don't need to create an object to use it.

Example of use:

 import com.neilmoomey.util.Type;
 String s = "12345.6789";
 float f = Type.toFloat(s);
 


Constructor Summary
Type()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static byte toByte(double d)
          double to byte
static byte toByte(float f)
          float to byte
static byte toByte(int i)
          int to byte
static byte toByte(long l)
          long to byte
static byte toByte(short sh)
          short to byte
static byte toByte(java.lang.String s)
          String to byte
static double toDouble(byte b)
          byte to double
static double toDouble(float f)
          float to double
static double toDouble(int i)
          int to double
static double toDouble(long l)
          long to double
static double toDouble(short s)
          short to double
static double toDouble(java.lang.String s)
          String to double
static float toFloat(byte b)
          byte to float
static float toFloat(double d)
          double to float
static float toFloat(int i)
          int to float
static float toFloat(long l)
          long to float
static float toFloat(short sh)
          short to float
static float toFloat(java.lang.String s)
          String to float
static int toInt(byte b)
          byte to int
static int toInt(double d)
          double to int
static int toInt(float f)
          float to int
static int toInt(long l)
          long to int
static int toInt(short sh)
          short to int
static int toInt(java.lang.String s)
          String to int
static long toLong(byte b)
          byte to Long
static long toLong(double d)
          double to Long
static long toLong(float f)
          float to Long
static long toLong(int i)
          int to Long
static long toLong(short sh)
          short to Long
static long toLong(java.lang.String s)
          String to Long
static short toShort(byte b)
          byte to Short
static short toShort(double d)
          double to Short
static short toShort(float f)
          float to Short
static short toShort(int i)
          int to Short
static short toShort(long l)
          long to Short
static short toShort(java.lang.String s)
          String to Short
static java.lang.String toString(byte d)
          byte to String
static java.lang.String toString(double d)
          double to String
static java.lang.String toString(float f)
          float to String
static java.lang.String toString(int i)
          int to String
static java.lang.String toString(long l)
          long to String
static java.lang.String toString(short sh)
          short to String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Type

public Type()
Method Detail

toByte

public static byte toByte(double d)
double to byte


toByte

public static byte toByte(float f)
float to byte


toByte

public static byte toByte(int i)
int to byte


toByte

public static byte toByte(long l)
long to byte


toByte

public static byte toByte(short sh)
short to byte


toByte

public static byte toByte(java.lang.String s)
String to byte


toDouble

public static double toDouble(byte b)
byte to double


toDouble

public static double toDouble(float f)
float to double


toDouble

public static double toDouble(int i)
int to double


toDouble

public static double toDouble(long l)
long to double


toDouble

public static double toDouble(short s)
short to double


toDouble

public static double toDouble(java.lang.String s)
String to double


toFloat

public static float toFloat(byte b)
byte to float


toFloat

public static float toFloat(double d)
double to float


toFloat

public static float toFloat(int i)
int to float


toFloat

public static float toFloat(long l)
long to float


toFloat

public static float toFloat(short sh)
short to float


toFloat

public static float toFloat(java.lang.String s)
String to float


toInt

public static int toInt(byte b)
byte to int


toInt

public static int toInt(double d)
double to int


toInt

public static int toInt(float f)
float to int


toInt

public static int toInt(long l)
long to int


toInt

public static int toInt(short sh)
short to int


toInt

public static int toInt(java.lang.String s)
String to int


toLong

public static long toLong(byte b)
byte to Long


toLong

public static long toLong(double d)
double to Long


toLong

public static long toLong(float f)
float to Long


toLong

public static long toLong(int i)
int to Long


toLong

public static long toLong(short sh)
short to Long


toLong

public static long toLong(java.lang.String s)
String to Long


toShort

public static short toShort(byte b)
byte to Short


toShort

public static short toShort(double d)
double to Short


toShort

public static short toShort(float f)
float to Short


toShort

public static short toShort(int i)
int to Short


toShort

public static short toShort(long l)
long to Short


toShort

public static short toShort(java.lang.String s)
String to Short


toString

public static java.lang.String toString(byte d)
byte to String


toString

public static java.lang.String toString(double d)
double to String


toString

public static java.lang.String toString(float f)
float to String


toString

public static java.lang.String toString(int i)
int to String


toString

public static java.lang.String toString(long l)
long to String


toString

public static java.lang.String toString(short sh)
short to String


main

public static void main(java.lang.String[] args)