antichess
Class GameReader

java.lang.Object
  extended by antichess.GameReader

public class GameReader
extends Object

The GameReader class reads XML game files for antichess games.

Specification Fields

Constructor Summary
GameReader(File gameFile)
           
GameReader(InputStream stream)
           
GameReader(String xmlData)
           
 
Method Summary
 GameTimer getBlackTimer()
           
 AntichessBoard getBoard()
           
 GameTimer getWhiteTimer()
           
 boolean isTimed()
           
static void loadBoard(ChessBoard board, String xml, Player player)
           
static ChessMove parseMove(String value, ChessBoard board)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameReader

public GameReader(InputStream stream)
           throws InvalidGameFileException,
                  IOException
Throws:
InvalidGameFileException - if the stream is not a valid game (e.g. it does not validate)
IOException
Effects:
constructs a new GameReader containing the data in the given XML stream

GameReader

public GameReader(File gameFile)
           throws InvalidGameFileException,
                  IOException
Throws:
IOException - if there is an IO error reading the file
InvalidGameFileException - if the file is not valid game file (e.g. it does not validate)
Effects:
constructs a new GameReader containing the data in the given XML file

GameReader

public GameReader(String xmlData)
           throws InvalidGameFileException
Throws:
InvalidGameFileException - if the file is not valid game file (e.g. it does not validate)
Effects:
constructs a new GameReader by reading the given string of XML
Method Detail

loadBoard

public static void loadBoard(ChessBoard board,
                             String xml,
                             Player player)
                      throws InvalidGameFileException
Throws:
InvalidGameFileException - if the XML is invalid
Effects:
Load the given board with the data parsed from an XML <pieces> tag, including both the start and end tags, and set the specified player.

parseMove

public static ChessMove parseMove(String value,
                                  ChessBoard board)
Returns:
a ChessMove by parsing the string description of a move (e.g e2-e4) on the given board.
Throws:
IllegalArgumentException - if the move is ill-formed, or tries to move a piece that doesn't exist

getBoard

public AntichessBoard getBoard()
Returns:
this.board

isTimed

public boolean isTimed()
Returns:
this.timed

getWhiteTimer

public GameTimer getWhiteTimer()
Returns:
this.whiteTimer

getBlackTimer

public GameTimer getBlackTimer()
Returns:
this.blackTimer