|
Breakout Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object breakout.LoaderUtils
Utility class to help Loader process information in a boardfile.
Constructor Summary | |
LoaderUtils()
|
Method Summary | |
static java.util.Vector |
extractArgs(java.lang.String line,
java.lang.String label)
Given the label "fooArgs", extracts "5" "4" and "%" out of the string, [foo p="5" q="0" fooArgs="5, 4, %foo"] . |
static java.util.Vector |
extractClassObjectArrays(java.util.Vector args,
Board board)
Extracts a Class[] and a Object[] out of a Vector of constructor arguments, and returns them in a Vector as elements 0 and 1, respectively. |
static java.lang.String |
extractValue(java.lang.String line,
java.lang.String label)
Given the label "q", extracts "0" out of the string, [foo p="5" q="0"] |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LoaderUtils()
Method Detail |
public static java.lang.String extractValue(java.lang.String line, java.lang.String label) throws BadBoardFormatException
[foo p="5" q="0"]
line
- The line of text to be parsed for the value of label
label
- The String labeling the desired value in the line of text.
label
.
BadBoardFormatException
- if the label can't be found in the string, or if the value trails off
the end of the string before encountering a closing double-quote("
).public static java.util.Vector extractArgs(java.lang.String line, java.lang.String label) throws BadBoardFormatException, java.lang.NumberFormatException
[foo p="5" q="0" fooArgs="5, 4, %foo"]
.
%
) into
Integer
s. Arguments beginning with a percent sign(%
) become
simply the String "%". Arguments must be comma-delimited; spaces between arguments don't matter.
line
- The line of text to be parsed for the args labeled with label
label
- The String labeling the desired args in the line of text.
label
.
BadBoardFormatException
- if label
cannot be found in the string, or
if the group of arguments labeled by label
trails off the end of the string
before the closing double-quote("
).
java.lang.NumberFormatException
- if one of the comma-delimited arguments does not begin with
a percent sign(%
) and cannot be cast into an Integer.public static java.util.Vector extractClassObjectArrays(java.util.Vector args, Board board)
getConstructor
method of class Class
takes an
array of Class
objects defining the order and types of the arguments passed
to the desired constructor. Once in ownership of the desired Constructor
object, an instance is obtained using the getInstance
method, which
takes an array of Object
objects as the actual arguments to be
passed to the constructor.
LoaderUtils.extractArgs(String
line, String label)
to get a Vector of arguments. This method takes that Vector, and
hands you back the corresponding Class[]
and Object[]
.
args
- A Vector containing only Integer objects and String objects starting with "%"board
- The board this object will eventually be added to; into which "%" becomes translated.
Class[]
and whose second element(1)
is a Object[]
.
|
Breakout Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |