com.realtime.crossfire.jxclient.skin.io
Class CommandParser

java.lang.Object
  extended by com.realtime.crossfire.jxclient.skin.io.CommandParser

public class CommandParser
extends java.lang.Object

Parser for creating GUICommand instances from string representations.


Field Summary
private  JXCSkinCache<GUIElement> definedGUIElements
          The defined GUI elements.
private  Dialogs dialogs
          The Dialogs instance to use.
private  FloorView floorView
          The FloorView to use.
 
Constructor Summary
CommandParser(Dialogs dialogs, FloorView floorView, JXCSkinCache<GUIElement> definedGUIElements)
          Creates a new instance.
 
Method Summary
private static GUICommand parseAccountCreate(GUIElement element, CommandCallback commandCallback)
          Parses and builds an "ACCOUNT_CREATE" command.
private static GUICommand parseAccountCreateCharacter(GUIElement element, CommandCallback commandCallback)
          Parses and builds an "ACCOUNT_CREATE_CHARACTER" command.
private static GUICommand parseAccountLink(GUIElement element, CommandCallback commandCallback)
          Parses and builds an "ACCOUNT_LINK" command.
private static GUICommand parseAccountLogin(GUIElement element, CommandCallback commandCallback)
          Parses and builds an "ACCOUNT_LOGIN" command.
private static GUICommand parseAccountPlay(GUIElement element, CommandCallback commandCallback)
          Parses and builds an "ACCOUNT_PLAY" command.
 GUICommand parseCommandArgs(Args args, GUIElement element, java.lang.String command, GuiStateManager guiStateManager, Commands commands, java.io.LineNumberReader lnr, CommandQueue commandQueue, CrossfireServerConnection crossfireServerConnection, CommandCallback commandCallback, Macros macros)
          Parses and builds command arguments.
private static GUICommand parseConnect(GUIElement element, GuiStateManager guiStateManager)
          Parses and builds a "CONNECT" command.
private  GUICommand parseDialogClose(Args args, GUIElement element, CommandCallback commandCallback)
          Parses and builds a "DIALOG_CLOSE" command.
private  GUICommand parseDialogOpen(Args args, GUIElement element, CommandCallback commandCallback)
          Parses and builds a "DIALOG_OPEN" command.
private  GUICommand parseDialogToggle(Args args, GUIElement element, CommandCallback commandCallback)
          Parses and builds a "DIALOG_TOGGLE" command.
private static GUICommand parseDisconnect(GUIElement element, GuiStateManager guiStateManager)
          Parses and builds a "DISCONNECT" command.
private  GUICommand parseExecSelection(Args args, GUIElement element, CommandQueue commandQueue, CrossfireServerConnection crossfireServerConnection)
          Parses and builds a "" command.
private static GUICommand parseGuiExecuteCommand(Args args, GUIElement element, Commands commands, java.io.LineNumberReader lnr, Macros macros)
          Parses and builds a "GUI_EXECUTE_COMMAND" command.
private static GUICommand parseGuiExecuteElement(GUIElement element)
          Parses and builds a "GUI_EXECUTE_ELEMENT" command.
private static GUICommand parseGuiMeta(GUIElement element, GuiStateManager guiStateManager)
          Parses and builds a "GUI_META" command.
private static GUICommand parseGuiStart(GUIElement element, GuiStateManager guiStateManager)
          Parses and builds a "GUI_START" command.
private static GUICommand parseHide(GUIElement element)
          Parses and builds a "HIDE" command.
private  GUICommand parseMoveFocus(Args args, GUIElement element)
          Parses and builds a "MOVE_FOCUS" command.
private static GUICommand parseMoveSelection(Args args, GUIElement element)
          Parses and builds a "MOVE_SELECTION" command.
private static GUICommand parsePrint(GUIElement element)
          Parses and builds a "PRINT" command.
private static GUICommand parseQuit(GUIElement element, CommandCallback commandCallback)
          Parses and builds a "QUIT" command.
private static GUICommand parseScroll(Args args, GUIElement element, boolean isScroll)
          Parses and builds a "SCROLL" or "SCROLL_NEVER command.
private static GUICommand parseScrollList(Args args, GUIElement element)
          Parses and builds a "SCROLL_LIST" command.
private static GUICommand parseScrollReset(GUIElement element)
          Parses and builds a "SCROLL_RESET" command.
private static GUICommand parseShow(GUIElement element)
          Parses and builds a "SHOW" command.
private static GUICommand parseToggle(GUIElement element)
          Parses and builds a "TOGGLE" command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

definedGUIElements

@NotNull
private final JXCSkinCache<GUIElement> definedGUIElements
The defined GUI elements.


dialogs

@NotNull
private final Dialogs dialogs
The Dialogs instance to use.


floorView

@NotNull
private final FloorView floorView
The FloorView to use.

Constructor Detail

CommandParser

public CommandParser(@NotNull
                     Dialogs dialogs,
                     @NotNull
                     FloorView floorView,
                     @NotNull
                     JXCSkinCache<GUIElement> definedGUIElements)
Creates a new instance.

Parameters:
dialogs - the dialogs instance to use
floorView - the floor view to use
definedGUIElements - the defined GUI elements
Method Detail

parseAccountCreate

@NotNull
private static GUICommand parseAccountCreate(@Nullable
                                                     GUIElement element,
                                                     @NotNull
                                                     CommandCallback commandCallback)
                                      throws java.io.IOException
Parses and builds an "ACCOUNT_CREATE" command.

Parameters:
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseAccountCreateCharacter

@NotNull
private static GUICommand parseAccountCreateCharacter(@Nullable
                                                              GUIElement element,
                                                              @NotNull
                                                              CommandCallback commandCallback)
                                               throws java.io.IOException
Parses and builds an "ACCOUNT_CREATE_CHARACTER" command.

Parameters:
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseAccountLink

@NotNull
private static GUICommand parseAccountLink(@Nullable
                                                   GUIElement element,
                                                   @NotNull
                                                   CommandCallback commandCallback)
                                    throws java.io.IOException
Parses and builds an "ACCOUNT_LINK" command.

Parameters:
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseAccountLogin

@NotNull
private static GUICommand parseAccountLogin(@Nullable
                                                    GUIElement element,
                                                    @NotNull
                                                    CommandCallback commandCallback)
                                     throws java.io.IOException
Parses and builds an "ACCOUNT_LOGIN" command.

Parameters:
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseAccountPlay

@NotNull
private static GUICommand parseAccountPlay(@Nullable
                                                   GUIElement element,
                                                   @NotNull
                                                   CommandCallback commandCallback)
                                    throws java.io.IOException
Parses and builds an "ACCOUNT_PLAY" command.

Parameters:
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseCommandArgs

@NotNull
public GUICommand parseCommandArgs(@NotNull
                                           Args args,
                                           @Nullable
                                           GUIElement element,
                                           @NotNull
                                           java.lang.String command,
                                           @NotNull
                                           GuiStateManager guiStateManager,
                                           @NotNull
                                           Commands commands,
                                           @NotNull
                                           java.io.LineNumberReader lnr,
                                           @NotNull
                                           CommandQueue commandQueue,
                                           @NotNull
                                           CrossfireServerConnection crossfireServerConnection,
                                           @NotNull
                                           CommandCallback commandCallback,
                                           @NotNull
                                           Macros macros)
                            throws java.io.IOException,
                                   JXCSkinException
Parses and builds command arguments.

Parameters:
args - the list of arguments
element - the target element
command - the command to parse the arguments of
guiStateManager - the gui state manager instance
commands - the commands instance for executing commands
lnr - the source to read more parameters from
commandQueue - the command queue for executing commands
crossfireServerConnection - the server connection to use
commandCallback - the command callback to use
macros - the macros instance to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs
JXCSkinException - if an element cannot be found

parseConnect

@NotNull
private static GUICommand parseConnect(@Nullable
                                               GUIElement element,
                                               @NotNull
                                               GuiStateManager guiStateManager)
                                throws java.io.IOException
Parses and builds a "CONNECT" command.

Parameters:
element - the target element
guiStateManager - the gui state manager instance
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseDialogClose

@NotNull
private GUICommand parseDialogClose(@NotNull
                                            Args args,
                                            @Nullable
                                            GUIElement element,
                                            @NotNull
                                            CommandCallback commandCallback)
                             throws java.io.IOException
Parses and builds a "DIALOG_CLOSE" command.

Parameters:
args - the list of arguments
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseDialogOpen

@NotNull
private GUICommand parseDialogOpen(@NotNull
                                           Args args,
                                           @Nullable
                                           GUIElement element,
                                           @NotNull
                                           CommandCallback commandCallback)
                            throws java.io.IOException
Parses and builds a "DIALOG_OPEN" command.

Parameters:
args - the list of arguments
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseDialogToggle

@NotNull
private GUICommand parseDialogToggle(@NotNull
                                             Args args,
                                             @Nullable
                                             GUIElement element,
                                             @NotNull
                                             CommandCallback commandCallback)
                              throws java.io.IOException
Parses and builds a "DIALOG_TOGGLE" command.

Parameters:
args - the list of arguments
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseDisconnect

@NotNull
private static GUICommand parseDisconnect(@Nullable
                                                  GUIElement element,
                                                  @NotNull
                                                  GuiStateManager guiStateManager)
                                   throws java.io.IOException
Parses and builds a "DISCONNECT" command.

Parameters:
element - the target element
guiStateManager - the gui state manager instance
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseExecSelection

@NotNull
private GUICommand parseExecSelection(@NotNull
                                              Args args,
                                              @Nullable
                                              GUIElement element,
                                              @NotNull
                                              CommandQueue commandQueue,
                                              @NotNull
                                              CrossfireServerConnection crossfireServerConnection)
                               throws java.io.IOException
Parses and builds a "" command.

Parameters:
args - the list of arguments
element - the target element
commandQueue - the command queue for executing commands
crossfireServerConnection - the server connection to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseGuiExecuteCommand

@NotNull
private static GUICommand parseGuiExecuteCommand(@NotNull
                                                         Args args,
                                                         @Nullable
                                                         GUIElement element,
                                                         @NotNull
                                                         Commands commands,
                                                         @NotNull
                                                         java.io.LineNumberReader lnr,
                                                         @NotNull
                                                         Macros macros)
                                          throws java.io.IOException
Parses and builds a "GUI_EXECUTE_COMMAND" command.

Parameters:
args - the list of arguments
element - the target element
commands - the commands instance for executing commands
lnr - the source to read more parameters from
macros - the macros instance to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseGuiExecuteElement

@NotNull
private static GUICommand parseGuiExecuteElement(@Nullable
                                                         GUIElement element)
                                          throws java.io.IOException
Parses and builds a "GUI_EXECUTE_ELEMENT" command.

Parameters:
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseGuiMeta

@NotNull
private static GUICommand parseGuiMeta(@Nullable
                                               GUIElement element,
                                               @NotNull
                                               GuiStateManager guiStateManager)
                                throws java.io.IOException
Parses and builds a "GUI_META" command.

Parameters:
element - the target element
guiStateManager - the gui state manager instance
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseGuiStart

@NotNull
private static GUICommand parseGuiStart(@Nullable
                                                GUIElement element,
                                                @NotNull
                                                GuiStateManager guiStateManager)
                                 throws java.io.IOException
Parses and builds a "GUI_START" command.

Parameters:
element - the target element
guiStateManager - the gui state manager instance
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseHide

@NotNull
private static GUICommand parseHide(@Nullable
                                            GUIElement element)
                             throws java.io.IOException
Parses and builds a "HIDE" command.

Parameters:
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseMoveFocus

@NotNull
private GUICommand parseMoveFocus(@NotNull
                                          Args args,
                                          @Nullable
                                          GUIElement element)
                           throws java.io.IOException,
                                  JXCSkinException
Parses and builds a "MOVE_FOCUS" command.

Parameters:
args - the list of arguments
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs
JXCSkinException - if a syntax error occurs

parseMoveSelection

@NotNull
private static GUICommand parseMoveSelection(@NotNull
                                                     Args args,
                                                     @Nullable
                                                     GUIElement element)
                                      throws java.io.IOException
Parses and builds a "MOVE_SELECTION" command.

Parameters:
args - the list of arguments
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parsePrint

@NotNull
private static GUICommand parsePrint(@Nullable
                                             GUIElement element)
                              throws java.io.IOException
Parses and builds a "PRINT" command.

Parameters:
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseQuit

@NotNull
private static GUICommand parseQuit(@Nullable
                                            GUIElement element,
                                            @NotNull
                                            CommandCallback commandCallback)
                             throws java.io.IOException
Parses and builds a "QUIT" command.

Parameters:
element - the target element
commandCallback - the command callback to use
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseScroll

@NotNull
private static GUICommand parseScroll(@NotNull
                                              Args args,
                                              @Nullable
                                              GUIElement element,
                                              boolean isScroll)
                               throws java.io.IOException
Parses and builds a "SCROLL" or "SCROLL_NEVER command.

Parameters:
args - the list of arguments
element - the target element
isScroll - whether to parse a "SCROLL" (true) or a "SCROLL_NEVER" (false) command
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseScrollList

@NotNull
private static GUICommand parseScrollList(@NotNull
                                                  Args args,
                                                  @Nullable
                                                  GUIElement element)
                                   throws java.io.IOException
Parses and builds a "SCROLL_LIST" command.

Parameters:
args - the list of arguments
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseScrollReset

@NotNull
private static GUICommand parseScrollReset(@Nullable
                                                   GUIElement element)
                                    throws java.io.IOException
Parses and builds a "SCROLL_RESET" command.

Parameters:
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseShow

@NotNull
private static GUICommand parseShow(@Nullable
                                            GUIElement element)
                             throws java.io.IOException
Parses and builds a "SHOW" command.

Parameters:
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs

parseToggle

@NotNull
private static GUICommand parseToggle(@Nullable
                                              GUIElement element)
                               throws java.io.IOException
Parses and builds a "TOGGLE" command.

Parameters:
element - the target element
Returns:
the command arguments
Throws:
java.io.IOException - if a syntax error occurs