Examples of SGFParser


Examples of com.sgfj.SGFParser

        DocumentedGame newGame = null;
        try {
            String sgf = din.readUTF();

            if (sgf.length() > 0) {
                SGFParser parser = new SGFParser(sgf);
                SGFNode newTree = parser.parse();
                newGame = new DocumentedGame(newTree);

                int depth = din.readShort();
                while (depth-- > 0) {
                    int varNumber = din.readShort();
View Full Code Here

Examples of com.sgfj.SGFParser

public class SGFWriterTest extends TestCase {

    public void testWrite() {
        try {
            String data = "(;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2]RU[Japanese]SZ[9]HA[3]KM[5.50]PW[Белые]PB[Черные]AB[gc][cg][gg];W[ed]CR[ee]TR[cc][gc](;B[ec]CR[ec]LB[dd:A])(;B[eg]CR[eg];W[];B[ge]))";
            SGFParser reader = new SGFParser(data);
            SGFNode tree = reader.parse();
            assertNotNull("Emty tree received.", tree);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            OutputStreamWriter w = new OutputStreamWriter(baos);
            SGFWriter.write(w, tree);
            w.close();

            //System.out.println(baos.toString());
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            reader = new SGFParser(new InputStreamReader(bais));
            SGFNode tree2 = reader.parse();

            assertEquals(tree, tree2);
            assertEquals(SGFWriter.toString(tree), SGFWriter.toString(tree2));
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.sgfj.SGFParser

            path = topDir;
            subPath = filePath.substring(topDir.length());
        }

        InputStreamReader isr = new InputStreamReader(is);
        SGFParser parser = new SGFParser(isr);

        while (true) {
            int offset = parser.getCharsConsumed();

            // parse file to get tree
            SGFNode tree = null;
            try {
                tree = parser.parse();
            } catch (SGFEOFException e) {
                // DO NOTHING
                break;
            } catch (SGFParseError e) {
                System.out.println("Parse error " + filePath + ":" + e.getMessage());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.