|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.util.JCTypeConverter
JCTypeConverter
contains static methods for retrieving
parameters from a source file or applet, and for converting parameters to
particular data types.
Field Summary | |
static boolean |
reportErrors
|
Constructor Summary | |
JCTypeConverter()
|
Method Summary | |
static void |
checkEnum(int value,
String param,
int[] values)
Checks the validity of an enum. |
static void |
error(String msg)
Writes a parse error message to stdout. |
static void |
error(String s,
String token)
Writes a parse error message to stdout. |
static String |
fromDate(Date d,
String def)
Converts a Date to a proper String that can be read back in parsed to a date. |
static String |
fromEnum(int value,
String[] strings,
int[] values)
Converts an enum to a String. |
static String |
fromEnum(int value,
String param,
String type,
String[][] strings,
int[][] values,
String def)
Converts an enum to a String. |
static String |
fromEnum(long value,
String[] strings,
long[] values)
Converts an enum to a String where the enum index is a long. |
static String |
fromMatchListObject(Object value,
String[] strings,
Object[] values)
Finds an object within a match list of objects and returns the corresponding String from a synched-up String list. |
static String |
fromNewLine(String s)
Converts all occurrences of char '\n' to String "\n". |
static String |
fromPointList(Point[] parray,
char delim)
Converts an array of Points to a String in which the x,y pairs are separated by the specified delimiter. |
static String |
fromStringList(List slist)
Converts a List of Strings to a comma-separated String. |
static String |
fromStringList(List slist,
char delim)
Converts a List of Strings to a String in which values are separated by the specified delimiter. |
static String |
fromStringList(String[] slist)
Converts an array of Strings to a comma-separated String. |
static String |
fromStringList(String[] slist,
char delim)
Converts an array of Strings to a String in which values are separated by the specified delimiter. |
static void |
parseError(String token)
Displays a parsing error. |
static String |
removeEscape(String s)
Removes "escape" characters (backslashes) from the String. |
static boolean |
toBoolean(String s,
boolean def)
Converts a String to a boolean. |
static Date |
toDate(String s,
Date def)
Converts a String to a Date. |
static double |
toDouble(String s,
double def)
Converts a String to a double. |
static Double[] |
toDoubleList(String s,
char delim)
Converts a String to an array of Double objects based on the
provided delimiter. |
static Double[] |
toDoubleList(String s,
char delim,
Double[] def)
Converts a String to an array of integers based on the provided delimiter. |
static int |
toEnum(String s,
String[] strings,
int[] values,
int def)
Converts a String to an enum. |
static int |
toEnum(String s,
String type,
String[] strings,
int[] values,
int def)
Converts a String to an enum. |
static long |
toEnum(String s,
String type,
String[] strings,
long[] values,
long def)
Converts a String to an enum. |
static int |
toEnum(String string,
String type,
String param,
String[][] strings,
int[][] values,
int def)
Converts a String to an enum. |
static int[] |
toEnumList(String s,
String type,
String[] strings,
int[] values,
int[] def)
Converts a String to a list of enums. |
static int |
toInt(String s,
int def)
Converts a String to an integer. |
static Integer[] |
toIntegerList(String s,
char delim)
Converts a String to an array of Integer objects based on the provided delimiter. |
static Integer[] |
toIntegerList(String s,
char delim,
Integer[] def)
Converts a String to an array of integers based on the provided delimiter. |
static int[] |
toIntList(String s,
char delim)
Converts a String to an array of integers based on the provided delimiter. |
static int[] |
toIntList(String s,
char delim,
int[] def)
Converts a String to an array of integers based on the provided delimiter. |
static Object |
toMatchListObject(String value,
String[] strings,
Object[] values)
Finds a String within a match list of Strings and returns the corresponding object from a synched-up object list. |
static String |
toNewLine(String string)
Converts all occurrences of "\n" in a String to newlines. |
static Point[] |
toPointList(String s,
char delim)
Converts a String to an array of Points. |
static String |
toString(Object o)
Converts an object to a String. |
static String[] |
toStringList(String s)
Converts a String to an array of Strings. |
static String[] |
toStringList(String s,
char delim)
Converts a String to an array of Strings. |
static String[] |
toStringList(String s,
char delim,
boolean trim)
Converts a String to an array of Strings. |
static Vector |
toVector(String s,
char delim)
Converts a delimited list of tokens to a Vector. |
static Vector |
toVector(String s,
char delim,
Vector def)
Converts a delimited list of tokens to a Vector. |
static String |
trim(Object obj)
Returns a trimmed String, with trailing nulls removed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static boolean reportErrors
Constructor Detail |
public JCTypeConverter()
Method Detail |
public static void error(String s, String token)
s
- the entire string being parsedtoken
- the String which could not be parsedpublic static void error(String msg)
msg
- the String which could not be parsedpublic static void parseError(String token)
token
- the token on which the error happenedpublic static String trim(Object obj)
obj
- the object to trim
public static int toInt(String s, int def)
s
- the String for conversiondef
- the default value to be used when a parsing error occurs
public static double toDouble(String s, double def)
s
- the String for conversiondef
- the default value to be used when a parsing error occurs
public static boolean toBoolean(String s, boolean def)
s
- the String for conversiondef
- the default value to be used when a parsing error occurs
public static String[] toStringList(String s)
s
- the comma-separated Strings
public static String[] toStringList(String s, char delim)
s
- the Strings separated by delimiterdelim
- the delimiter
public static String[] toStringList(String s, char delim, boolean trim)
s
- the Strings separated by delimiterdelim
- the delimitertrim
- boolean to indicate if spaces are trimmed
public static Point[] toPointList(String s, char delim)
s
- A String of x,y pairsdelim
- the delimiter used to separate the x,y pairs
public static String fromStringList(String[] slist)
slist
- the array of Strings
public static String fromStringList(String[] slist, char delim)
slist
- the array of Stringsdelim
- the delimiter
public static String fromStringList(List slist)
slist
- the array of Strings
public static String fromStringList(List slist, char delim)
slist
- the array of Stringsdelim
- the delimiter
public static String fromPointList(Point[] parray, char delim)
parray
- the array of Pointsdelim
- the delimiter
public static int[] toIntList(String s, char delim)
s
- the String which will be converted to integersdelim
- the delimiter separating the integers in the String
public static Integer[] toIntegerList(String s, char delim)
s
- the String which will be converted to Integersdelim
- the delimiter separating the Integers in the String
public static Double[] toDoubleList(String s, char delim)
Double
objects based on the
provided delimiter.
s
- the String which will be converted to Doubles
delim
- the delimiter separating the Doubles
in the String
Double
list resulting from the converson of the
Stringpublic static int[] toIntList(String s, char delim, int[] def)
s
- the String which will be converted to integersdelim
- the delimiter separating the integers in the Stringdef
- the default value, returned if a parse error occurs
public static Integer[] toIntegerList(String s, char delim, Integer[] def)
s
- the String which will be converted to integersdelim
- the delimiter separating the integers in the Stringdef
- the default value, returned if a parse error occurs
public static Double[] toDoubleList(String s, char delim, Double[] def)
s
- the String which will be converted to integersdelim
- the delimiter separating the integers in the Stringdef
- the default value, returned if a parse error occurs
Double
list resulting from the converson of the
Stringpublic static String toNewLine(String string)
string
- the string to parse
public static String fromNewLine(String s)
s
- the String to parse
public static Vector toVector(String s, char delim)
s
- the String to convertdelim
- the delimiter that separates the tokens in the String
public static Vector toVector(String s, char delim, Vector def)
s
- the String to convertdelim
- the delimiter that separates the tokens in the Stringdef
- the default value, returned if a parse error occurs
public static int toEnum(String string, String type, String param, String[][] strings, int[][] values, int def)
string
- the String to be convertedtype
- the enum typeparam
- the optional PARAM name for the enum, used for the error messagestrings
- the first item in each list is the enum type;
each String has a corresponding value in the values arrayvalues
- list of values corresponding to the Stringsdef
- the default value, returned if the String could not be converted
public static int toEnum(String s, String type, String[] strings, int[] values, int def)
s
- the String to be convertedtype
- the enum type (for the console message)strings
- list of valid Stringsvalues
- list of values corresponding to each Stringdef
- the default value, returned if the String could not be converted
public static long toEnum(String s, String type, String[] strings, long[] values, long def)
s
- the String to be convertedtype
- the enum type (for the console message)strings
- list of valid Stringsvalues
- list of values corresponding to each Stringdef
- the default value, returned if the String could not be converted
public static int toEnum(String s, String[] strings, int[] values, int def)
s
- the String to be convertedstrings
- list of valid Stringsvalues
- list of values corresponding to each Stringdef
- the default value, returned if the String could not be converted
public static int[] toEnumList(String s, String type, String[] strings, int[] values, int[] def)
s
- the comma-separated list of enumstype
- the enum typestrings
- valid Stringsvalues
- list of values corresponding to each Stringdef
- the default value, returned if the String could not be converted
public static String fromEnum(int value, String[] strings, int[] values)
value
- the enum to be convertedstrings
- list of valid Stringsvalues
- list of values corresponding to each String
public static String fromEnum(long value, String[] strings, long[] values)
value
- the enum to be convertedstrings
- list of valid Stringsvalues
- list of values corresponding to each String
public static String fromEnum(int value, String param, String type, String[][] strings, int[][] values, String def)
value
- the enum to be convertedparam
- the optional PARAM name for the enum, used for the error messagetype
- the enum typestrings
- the first item in each list is the enum type;
each String has a corresponding value in the values arrayvalues
- list of values corresponding to the Stringsdef
- the default value, returned if the enum could not be converted
public static String fromMatchListObject(Object value, String[] strings, Object[] values)
value
- the object to be convertedstrings
- list of Strings corresponding to
each object in the values listvalues
- list of objects being searched
public static Object toMatchListObject(String value, String[] strings, Object[] values)
value
- the String to be convertedstrings
- list of Strings being searchedvalues
- list of objects corresponding to
each String in the Strings list
public static void checkEnum(int value, String param, int[] values)
value
- the enum value to checkparam
- enum name, used for error messagevalues
- the array in which to check for the value
IllegalArgumentException
- If the value is invalid.public static String toString(Object o)
o
- the object to be converted to a String
public static Date toDate(String s, Date def)
s
- the String to convertdef
- the default value, returned if the String could not be converted
public static String fromDate(Date d, String def)
d
- the date to convertdef
- the default String to return if the date could not be converted
public static String removeEscape(String s)
s
- the String from which the "escape" characters are to be removed
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |