public class Scan
extends java.lang.Object
Constructor and Description |
---|
Scan() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkForFieldName(ReaderTokenizer rtok,
java.lang.String name)
Checks to see if the next input token corresponds to a specific field
name.
|
static java.lang.Class<?> |
scanClass(ReaderTokenizer rtok)
Scans a class name (or known class name alias) and then returns the class
associated with that name.
|
static java.lang.Object |
scanClassAndObject(ReaderTokenizer rtok,
java.lang.Object ref)
Scans a class name, creates an instance of that class, and then, if the
class is Scannable, scans the instance.
|
static <T> T |
scanClassAndObject(ReaderTokenizer rtok,
java.lang.Object ref,
java.lang.Class<T> classType)
Scans a class name, creates an instance of that class, and then, if the
class is Scannable, scans the instance.
|
static java.awt.Color |
scanColor(ReaderTokenizer rtok)
Reads and returns a Color from a tokenizer.
|
static int |
scanDoubles(double[] vals,
ReaderTokenizer rtok)
Reads a set of double values, enclosed in square brackets
[
] . |
static double[] |
scanDoubles(ReaderTokenizer rtok)
Reads a set of double values, enclosed in square brackets
[
] ,
and returns them in an array. |
static int |
scanFloats(float[] vals,
ReaderTokenizer rtok)
Reads a set of float values, enclosed in square brackets
[
] . |
static float[] |
scanFloats(ReaderTokenizer rtok)
Reads a set of float values, enclosed in square brackets
[
] ,
and returns them in an array. |
static java.awt.Font |
scanFont(ReaderTokenizer rtok) |
static java.lang.Object |
scanInstance(ReaderTokenizer rtok,
java.lang.Class<?> defaultClass)
Attemptes to create and return a class instance based on a
defaultClass and input from a tokenizer. |
static int |
scanInts(int[] vals,
ReaderTokenizer rtok)
Reads a set of integer values, enclosed in square brackets
[
] . |
static int[] |
scanInts(ReaderTokenizer rtok)
Reads a set of integer values, enclosed in square brackets
[
] ,
and returns them in an array.Values which exceed the allowed range for
integers will be truncated in the high order bits. |
static int |
scanLongs(long[] vals,
ReaderTokenizer rtok)
Reads a set of long integer values, enclosed in square brackets
[ ] . |
static long[] |
scanLongs(ReaderTokenizer rtok)
Reads a set of long integer values, enclosed in square brackets
[ ] , and returns them in an array. |
static java.lang.String[] |
scanQuotedStrings(ReaderTokenizer rtok,
char quoteChar)
Reads a set of quoted strings, enclosed in square brackets
[ ] , and returns them as an array of Strings. |
static short[] |
scanShorts(ReaderTokenizer rtok)
Reads a set of short integer values, enclosed in square brackets
[ ] , and returns them in an array. |
static int |
scanShorts(short[] vals,
ReaderTokenizer rtok)
Reads a set of short integer values, enclosed in square brackets
[ ] . |
static java.lang.String[] |
scanWords(ReaderTokenizer rtok)
Reads a set of words values, enclosed in square brackets
[ ] ,
and returns them as an array of Strings. |
public static java.awt.Color scanColor(ReaderTokenizer rtok) throws java.io.IOException
[ ]
, representing red, green, and blue values, and an
optional alpha value, in the range 0 to 1. If alpha is not present, it
defaults to 1.rtok
- Tokenizer from which the color is readjava.io.IOException
- if the color is formatted incorrectly or if an I/O error occuredpublic static int scanDoubles(double[] vals, ReaderTokenizer rtok) throws java.io.IOException
[
]
.
Values are placed in an argument array and the number of values actually
read is returned.vals
- array in which values are storedrtok
- Tokenizer from which values are readjava.io.IOException
- if the number of values exceeds the size of the array, the values are not
numbers or are not enclosed in square brackets, or an I/O error occuredpublic static double[] scanDoubles(ReaderTokenizer rtok) throws java.io.IOException
[
]
,
and returns them in an array.rtok
- Tokenizer from which values are readjava.io.IOException
- if the values are not numbers or are not enclosed in square brackets, or
an I/O error occuredpublic static int scanFloats(float[] vals, ReaderTokenizer rtok) throws java.io.IOException
[
]
.
Values are placed in an argument array and the number of values actually
read is returned.vals
- array in which values are storedrtok
- Tokenizer from which values are readjava.io.IOException
- if the number of values exceeds the size of the array, the values are not
numbers or are not enclosed in square brackets, or an I/O error occuredpublic static float[] scanFloats(ReaderTokenizer rtok) throws java.io.IOException
[
]
,
and returns them in an array.rtok
- Tokenizer from which values are readjava.io.IOException
- if the values are not numbers or are not enclosed in square brackets, or
an I/O error occuredpublic static int scanInts(int[] vals, ReaderTokenizer rtok) throws java.io.IOException
[
]
.
Values are placed in an argument array and the number of values actually
read is returned. Values which exceed the allowed range for integers will
be truncated in the high order bits.vals
- array in which values are storedrtok
- Tokenizer from which values are readjava.io.IOException
- if the number of values exceeds the size of the array, the values are not
integers or are not enclosed in square brackets, or an I/O error occuredpublic static int[] scanInts(ReaderTokenizer rtok) throws java.io.IOException
[
]
,
and returns them in an array.Values which exceed the allowed range for
integers will be truncated in the high order bits.rtok
- Tokenizer from which values are readjava.io.IOException
- if the values are not integers or are not enclosed in square brackets, or
an I/O error occuredpublic static int scanShorts(short[] vals, ReaderTokenizer rtok) throws java.io.IOException
[ ]
. Values are placed in an argument array and the number
of values actually read is returned. Values which exceed the allowed range
for shorts will be truncated in the high order bits.vals
- array in which values are storedrtok
- Tokenizer from which values are readjava.io.IOException
- if the number of values exceeds the size of the array, the values are not
integers or are not enclosed in square brackets, or an I/O error occuredpublic static short[] scanShorts(ReaderTokenizer rtok) throws java.io.IOException
[ ]
, and returns them in an array. Values which exceed the
allowed range for shorts will be truncated in the high order bits.rtok
- Tokenizer from which values are readjava.io.IOException
- if the values are not integers or are not enclosed in square brackets, or
an I/O error occuredpublic static int scanLongs(long[] vals, ReaderTokenizer rtok) throws java.io.IOException
[ ]
. Values are placed in an argument array and the number
of values actually read is returned. Values which exceed the allowed range
for longs will be truncated in the high order bits.vals
- array in which values are storedrtok
- Tokenizer from which values are readjava.io.IOException
- if the number of values exceeds the size of the array, the values are not
integers or are not enclosed in square brackets, or an I/O error occuredpublic static long[] scanLongs(ReaderTokenizer rtok) throws java.io.IOException
[ ]
, and returns them in an array. Values which exceed the
allowed range for longs will be truncated in the high order bits.rtok
- Tokenizer from which values are readjava.io.IOException
- if the values are not integers or are not enclosed in square brackets, or
an I/O error occuredpublic static java.lang.String[] scanWords(ReaderTokenizer rtok) throws java.io.IOException
[ ]
,
and returns them as an array of Strings.rtok
- Tokenizer from which values are readjava.io.IOException
- if the values are not words or are not enclosed in square brackets, or an
I/O error occuredpublic static java.lang.String[] scanQuotedStrings(ReaderTokenizer rtok, char quoteChar) throws java.io.IOException
[ ]
, and returns them as an array of Strings.rtok
- Tokenizer from which values are readquoteChar
- quote character for the stringsjava.io.IOException
- if the strings are not quoted or are not enclosed in square brackets, or
an I/O error occuredpublic static java.lang.Class<?> scanClass(ReaderTokenizer rtok) throws java.io.IOException
Since this method temporarily changes the accepted word characters
in order to read a class name, it should not be called if the next
available token might have been pushed back on the token stream using
pushBack()
.
rtok
- Tokenizer from which values are readjava.io.IOException
- if no class is found for the class namepublic static java.lang.Object scanClassAndObject(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
Since this method temporarily changes the accepted word characters
in order to read a class name, it should not be called if the next
available token might have been pushed back on the token stream using
pushBack()
.
rtok
- Tokenizer from which values are readref
- if the object is Scannable
, is passed to its scan()
method.java.io.IOException
- if no class is found for the class name, the class
cannot be instantiated, or there was an error in scanningpublic static <T> T scanClassAndObject(ReaderTokenizer rtok, java.lang.Object ref, java.lang.Class<T> classType) throws java.io.IOException
Since this method temporarily changes the accepted word characters
in order to read a class name, it should not be called if the next
available token might have been pushed back on the token stream using
pushBack()
.
rtok
- Tokenizer from which values are readref
- if the object is Scannable
, is passed to its scan()
method.classType
- class type for the object being scannedjava.io.IOException
- if no class is found for the class name, the class
cannot be instantiated, or there was an error in scanningpublic static java.lang.Object scanInstance(ReaderTokenizer rtok, java.lang.Class<?> defaultClass) throws java.io.IOException
defaultClass
and input from a tokenizer.
"null"
, then no instance is created and null
is
returned. Otherwise, the word is assumed to be the name of a class for
which an instance is created and returned. The class must equal or be a
subclass of defaultClass
.
defaultClass
is created and returned.
Since this method temporarily changes the accepted word characters
in order to read a class name, it should not be called if the next
available token might have been pushed back on the token stream using
pushBack()
.
rtok
- Tokenizer from which values are readdefaultClass
- default class typejava.io.IOException
- if no class is found for the class name specified in
the input stream, or the class is not equal to, or a subclass of, defaultClass
, or the class cannot be instantiated.public static boolean checkForFieldName(ReaderTokenizer rtok, java.lang.String name) throws java.io.IOException
rtok
- Tokenizer from which input is readname
- field name to check forjava.io.IOException
- if the field name was present but not followed by an '=' token, or an I/O
error occuredpublic static java.awt.Font scanFont(ReaderTokenizer rtok) throws java.io.IOException
java.io.IOException