|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cse466.parser.Parser
This class implements the functionality needed for parsing the input file and generating the action list that will later be executed.
Field Summary | |
protected java.io.BufferedReader |
_br
The buffered reader that is reading the file |
protected int |
_lineNumber
The current line number being parsed |
Constructor Summary | |
protected |
Parser(java.io.BufferedReader br)
Initializes the current line, and assigns the buffered reader to be the one the rest of the parser will use |
Method Summary | |
protected java.util.List |
doParsing(boolean ignoreBadAMValues)
Runs the parser and appends the incoming actions to the list of actions. |
protected java.lang.String |
nextLine()
Grab the next line from the file, but if it hits the end of the file it will throw an IOException saying that it was expecting more. |
protected java.lang.String |
nextLineEndOk()
Grab the next line from the file. |
protected cse466.actions.Action |
parseDelayAction(java.lang.String line)
Creates a DelayAction out of the input line. |
static java.util.List |
parseFile(java.lang.String filename,
boolean ignoreBadAMValues)
Parses the file specified and gives back the ordered list of actions declared in the file. |
protected cse466.actions.Action |
parseNextAction(boolean ignoreBadAMValues)
Grab the next line and figure out what type of action it is (delay or packet) then delegate the rest of the parsing to the appropriate method. |
protected cse466.actions.Action |
parsePacketAction(java.lang.String line,
boolean ignoreBadAMValues)
Parses the sequence of lines that make up a @link PacketAction. |
protected java.lang.String[] |
splitInTwo(java.lang.String s)
A helper function that splits a string into two space delimited strings and then trims them. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int _lineNumber
protected java.io.BufferedReader _br
Constructor Detail |
protected Parser(java.io.BufferedReader br)
br
- The buffered reader that will be used for all the file
readingMethod Detail |
protected java.lang.String[] splitInTwo(java.lang.String s) throws ParserException
s
- the string to split
ParserException
- if it cannot figure out how to split the
stringprotected java.lang.String nextLineEndOk() throws java.io.IOException
java.io.IOException
- if one occurs from trying to read the fileprotected java.lang.String nextLine() throws java.io.IOException
java.io.IOException
- if the end of the file was reached or if there
was a problem trying to read the file.protected cse466.actions.Action parseDelayAction(java.lang.String line) throws ParserException
delay timeInMilliseconds
line
- The line of the file that contains the delay
specification.
ParserException
- if there was something wrong with the line
of input.protected cse466.actions.Action parsePacketAction(java.lang.String line, boolean ignoreBadAMValues) throws ParserException, java.io.IOException
packet packetType
fieldName value
fieldName value
end
Note that you must have as many fieldname/value pairs as the packet
has fields.
line
- The line that contains the start of the packet action
(packet packetType).ignoreBadAMValues
- if true, it will let you put whatever
amType you want to put in the packet. If false, it will throw a
ParserException
- if the input was malformed
java.io.IOException
- if there was a problem reading from the file.protected cse466.actions.Action parseNextAction(boolean ignoreBadAMValues) throws java.io.IOException, ParserException
ignoreBadAMValues
- if true, will let you use whatever am
values you want otherwise, it forces you to use the ones that
correspond to the packets.
ParserException
- if the input file is malformed
java.io.IOException
- if there was a problem reading from the fileprotected java.util.List doParsing(boolean ignoreBadAMValues) throws java.io.IOException, ParserException
ignoreBadAMValues
- if it should ignore when the amValue does
not match the amValue that the packet is supposed to have
ParserException
- on malformed input
java.io.IOException
- if there was a problem reading from the filepublic static java.util.List parseFile(java.lang.String filename, boolean ignoreBadAMValues) throws java.io.IOException, ParserException
filename
- The name of the file to parseignoreBadAMValues
- if true, it will ignore the case where the
packet is receiving an amValue that does not correspond to the type
of packet being created.
java.io.IOException
- if there was a problem reading the file
ParserException
- if there was malformed input
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |