|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.ucm.fdi.hysteria.console.Parser
public class Parser
Represents the parser of the game engine that analyzes the input stream and identifies valid commands.
Field Summary | |
---|---|
protected java.util.Vector<Command> |
_commandPrototypes
Contains the prototypes of every command that the player can use during the game |
protected GameConfig |
_config
Config |
protected Engine |
_engine
Engine |
protected Game |
_game
A reference to the game that created the Interpreter |
protected java.util.Scanner |
_reader
Scanner needed for reading from keyboard |
static java.lang.String |
LINE_SEPARATOR
Platform-independent line separator |
Constructor Summary | |
---|---|
Parser(java.io.InputStream in,
Game theGame,
Engine theEngine)
Constructs a parser, specifying the input stream from which the game receives the player commands and a reference to the game itself (to be used for constructing the commands), assuming the default configuration. |
|
Parser(java.io.InputStream in,
Game theGame,
Engine theEngine,
java.util.Properties config)
Constructs a parser, specifying the input stream from which the game receives the player commands, a reference to the game itself (to be used for constructing the commands) and a new configuration. |
Method Summary | |
---|---|
boolean |
hasNextCommand()
Checks whether there is text for another command in the player input. |
Command |
parseNextCommand()
Parses the player input, consuming its characters and returning the next command that has been identified. |
java.lang.String |
reportHelp()
Reports the help information of all the available commands. |
void |
setConfig(java.util.Properties config)
Sets a new configuration. |
void |
setGame(Game theGame)
|
void |
setInput(java.io.InputStream input)
Sets the input stream for the parser. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Scanner _reader
protected java.util.Vector<Command> _commandPrototypes
protected Game _game
protected GameConfig _config
protected Engine _engine
public static java.lang.String LINE_SEPARATOR
Constructor Detail |
---|
public Parser(java.io.InputStream in, Game theGame, Engine theEngine) throws java.lang.IllegalArgumentException
in
- Input streamtheGame
- The Game
java.lang.IllegalArgumentException
- Arguments in, theGame cannot be nullpublic Parser(java.io.InputStream in, Game theGame, Engine theEngine, java.util.Properties config) throws java.lang.IllegalArgumentException
in
- Input streamtheGame
- The Gameconfig
- The config
java.lang.IllegalArgumentException
- Arguments in, theGame and config cannot be nullMethod Detail |
---|
public boolean hasNextCommand()
public Command parseNextCommand() throws NoNextCommandException
NoNextCommandException
- There is no next command to parse.public java.lang.String reportHelp()
public void setConfig(java.util.Properties config) throws java.lang.IllegalArgumentException
config
- The config
java.lang.IllegalArgumentException
- Argument config cannot be nullpublic void setInput(java.io.InputStream input) throws java.lang.IllegalArgumentException
input
- The input
java.lang.IllegalArgumentException
- Argument "input" cannot be nullpublic void setGame(Game theGame) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |