Package com.barrybecker4.ca.dj.jigo.sgf
Class SGFLoader
- java.lang.Object
-
- com.barrybecker4.ca.dj.jigo.sgf.SGFLoader
-
public class SGFLoader extends java.lang.ObjectA way to load SGF files. This class handles SGF File Formats 3 and 4. The API is extremely simple, so subclassing to handle different file formats shouldn't be difficult.
-
-
Constructor Summary
Constructors Constructor Description SGFLoader()constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SGFGameload(java.io.InputStream is)Returns a new SGFGame, provided a valid (and open) InputStream.protected SGFTokenreadToken(java.io.StreamTokenizer st)Reads an SGF token, provided a StreamTokenizer to help with parsing the text into SGFTokens.
-
-
-
Method Detail
-
load
public SGFGame load(java.io.InputStream is) throws java.io.IOException, SGFException
Returns a new SGFGame, provided a valid (and open) InputStream.Given an input stream, this method will parse its contents and return a full SGFGame, complete with board markings, comments, and variations. On some minor errors (like syntax problems with the file), the parsing will stop and return whatever was parsed to that point.
Since everything is static, only one thread at a time may load a game.
- Parameters:
is- - The InputStream from which contains SGF 3 or SGF 4 data.- Returns:
- A complete SGFGame, or null on unrecoverable errors.
- Throws:
java.io.IOExceptionSGFException
-
readToken
protected SGFToken readToken(java.io.StreamTokenizer st) throws java.io.IOException, SGFException
Reads an SGF token, provided a StreamTokenizer to help with parsing the text into SGFTokens. In order to support importing of game types other than go, I have made this method abstract. See implementations in derived classes. (Barry 2007) Barry: I would really like this method to be Abstract, but jigo classes need to use this- Parameters:
st- - The StreamTokenizer from which to read an SGF token.- Returns:
- An SGFToken representing a piece of information about the game.
- Throws:
java.io.IOExceptionSGFException
-
-