net.sf.freecol.client.control
Class PreGameInputHandler

java.lang.Object
  extended by net.sf.freecol.client.control.InputHandler
      extended by net.sf.freecol.client.control.PreGameInputHandler
All Implemented Interfaces:
MessageHandler, StreamedMessageHandler

public final class PreGameInputHandler
extends InputHandler
implements StreamedMessageHandler

Handles the network messages that arrives before the game starts.


Field Summary
private static java.util.logging.Logger logger
           
 
Fields inherited from class net.sf.freecol.client.control.InputHandler
gui
 
Constructor Summary
PreGameInputHandler(FreeColClient freeColClient, GUI gui)
          The constructor to use.
 
Method Summary
 boolean accepts(java.lang.String tagName)
          Checks if the message handler support the given message.
private  org.w3c.dom.Element addPlayer(org.w3c.dom.Element element)
          Handles an "addPlayer"-message.
private  org.w3c.dom.Element chat(org.w3c.dom.Element element)
          Handles a "chat"-message.
private  org.w3c.dom.Element error(org.w3c.dom.Element element)
          Handles an "error"-message.
 org.w3c.dom.Element handle(Connection connection, org.w3c.dom.Element element)
          Deals with incoming messages that have just been received.
 void handle(Connection connection, javax.xml.stream.XMLStreamReader in, javax.xml.stream.XMLStreamWriter out)
          Handles the main element of an XML message.
private  org.w3c.dom.Element logout(org.w3c.dom.Element element)
          Handles an "logout"-message.
 org.w3c.dom.Element multiple(Connection connection, org.w3c.dom.Element element)
          Handle all the children of this element.
private  org.w3c.dom.Element playerReady(org.w3c.dom.Element element)
          Handles a PlayerReady message.
private  org.w3c.dom.Element removePlayer(org.w3c.dom.Element element)
          Handles a "removePlayer"-message.
private  org.w3c.dom.Element setAvailable(org.w3c.dom.Element element)
          Handles a "setAvailable"-message.
private  org.w3c.dom.Element startGame(org.w3c.dom.Element element)
          Handles an "startGame"-message.
private  void updateGame(Connection connection, javax.xml.stream.XMLStreamReader in, javax.xml.stream.XMLStreamWriter out)
          Handles an "updateGame"-message.
private  org.w3c.dom.Element updateGameOptions(org.w3c.dom.Element element)
          Handles an "updateGameOptions"-message.
private  org.w3c.dom.Element updateMapGeneratorOptions(org.w3c.dom.Element element)
          Handles an "updateMapGeneratorOptions"-message.
private  org.w3c.dom.Element updateNation(org.w3c.dom.Element element)
          Handles an "updateNation"-message.
private  org.w3c.dom.Element updateNationType(org.w3c.dom.Element element)
          Handles an "updateNationType"-message.
 
Methods inherited from class net.sf.freecol.client.control.InputHandler
disconnect, getFreeColClient, getGame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
Constructor Detail

PreGameInputHandler

public PreGameInputHandler(FreeColClient freeColClient,
                           GUI gui)
The constructor to use.

Parameters:
freeColClient - The main controller.
Method Detail

handle

public org.w3c.dom.Element handle(Connection connection,
                                  org.w3c.dom.Element element)
Deals with incoming messages that have just been received.

Specified by:
handle in interface MessageHandler
Specified by:
handle in class InputHandler
Parameters:
connection - The Connection the message was received on.
element - The root element of the message.
Returns:
The reply.

handle

public void handle(Connection connection,
                   javax.xml.stream.XMLStreamReader in,
                   javax.xml.stream.XMLStreamWriter out)
Handles the main element of an XML message.

Specified by:
handle in interface StreamedMessageHandler
Parameters:
connection - The connection the message came from.
in - The stream containing the message.
out - The output stream for the reply.

accepts

public boolean accepts(java.lang.String tagName)
Checks if the message handler support the given message.

Specified by:
accepts in interface StreamedMessageHandler
Parameters:
tagName - The tag name of the message to check.
Returns:
The result.

addPlayer

private org.w3c.dom.Element addPlayer(org.w3c.dom.Element element)
Handles an "addPlayer"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

removePlayer

private org.w3c.dom.Element removePlayer(org.w3c.dom.Element element)
Handles a "removePlayer"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

updateGameOptions

private org.w3c.dom.Element updateGameOptions(org.w3c.dom.Element element)
Handles an "updateGameOptions"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

updateMapGeneratorOptions

private org.w3c.dom.Element updateMapGeneratorOptions(org.w3c.dom.Element element)
Handles an "updateMapGeneratorOptions"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

chat

private org.w3c.dom.Element chat(org.w3c.dom.Element element)
Handles a "chat"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.
Returns:
Null.

playerReady

private org.w3c.dom.Element playerReady(org.w3c.dom.Element element)
Handles a PlayerReady message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

updateNation

private org.w3c.dom.Element updateNation(org.w3c.dom.Element element)
Handles an "updateNation"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

updateNationType

private org.w3c.dom.Element updateNationType(org.w3c.dom.Element element)
Handles an "updateNationType"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

setAvailable

private org.w3c.dom.Element setAvailable(org.w3c.dom.Element element)
Handles a "setAvailable"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

updateGame

private void updateGame(Connection connection,
                        javax.xml.stream.XMLStreamReader in,
                        javax.xml.stream.XMLStreamWriter out)
Handles an "updateGame"-message.

Parameters:
connection - The Connection the message will be read from.
in - The stream to read the message from.
out - The stream for the reply.

startGame

private org.w3c.dom.Element startGame(org.w3c.dom.Element element)
Handles an "startGame"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

logout

private org.w3c.dom.Element logout(org.w3c.dom.Element element)
Handles an "logout"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

error

private org.w3c.dom.Element error(org.w3c.dom.Element element)
Handles an "error"-message.

Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information.

multiple

public org.w3c.dom.Element multiple(Connection connection,
                                    org.w3c.dom.Element element)
Handle all the children of this element.

Parameters:
connection - Connection
element - The element (root element in a DOM-parsed XML tree) that holds all the information.
Returns:
Element