Examples of TextToken


Examples of com.barrybecker4.ca.dj.jigo.sgf.tokens.TextToken

            token = new GameNameToken();
        else if( tokenName.equals( "ID" ) )
            token = new GameIDToken();
        else if( tokenName.equals( "CA" ) )
            //  token = new CharsetToken();   // where did this token class go?
            token = new TextToken();

        // If all else fails, fail
        else {
            throw new SGFException("unexpected token name:"+ tokenName);
        }
View Full Code Here

Examples of com.nexirius.util.TextToken

            throw new RuntimeException("Can't open menu file '" + menuFileName + "'");
        }
    }

    private void parse(PushbackInputStream in, MenuCreator creator) throws Exception {
        TextToken textToken = nextToken(in);

        while (textToken != null) {
            if (textToken.isIdentifier(MENUBAR)) {
                creator.newMenuBar();
                parseMenuBar(in, creator);
            } else if (textToken.isIdentifier(TOOLBAR)) {
                creator.newToolBar();
                parseToolBar(in, creator);
            } else {
                throw new Exception("Expecting MENUBAR or TOOLBAR but have: " + textToken);
            }
View Full Code Here

Examples of com.nexirius.util.TextToken

        in.close();
    }

    private void parseMenuBar(PushbackInputStream in, MenuCreator creator) throws Exception {
        TextToken textToken = nextToken(in);

        while (textToken != null) {
            if (textToken.isIdentifier(MENU)) {
                parseMenu(in, creator);
            } else if (textToken.isIdentifier(END)) {
                creator.end();

                return;
            } else {
                throw new Exception("Expecting MENU or END but have: " + textToken);
View Full Code Here

Examples of com.nexirius.util.TextToken

    private void parseToolBar(PushbackInputStream in, MenuCreator creator) throws Exception {
        parseItems(in, creator);
    }

    private void parseMenu(PushbackInputStream in, MenuCreator creator) throws Exception {
        TextToken textToken = nextToken(in);

        if (textToken == null || !textToken.isString()) {
            throw new Exception("Expecting string literal (menu name) but have: " + textToken);
        }

        creator.addMenu(textToken.getString());
        parseItems(in, creator);
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

        creator.addMenu(textToken.getString());
        parseItems(in, creator);
    }

    private void parseToggle(PushbackInputStream in, MenuCreator creator) throws Exception {
        TextToken textToken = nextToken(in);

        if (textToken == null || !textToken.isString()) {
            throw new Exception("Expecting string literal (toggle menu name) but have: " + textToken);
        }

        creator.addToggle(textToken.getString());
        parseItems(in, creator);
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

        creator.addToggle(textToken.getString());
        parseItems(in, creator);
    }

    private void parseItems(PushbackInputStream in, MenuCreator creator) throws Exception {
        TextToken textToken = nextToken(in);

        while (textToken != null) {
            if (textToken.isIdentifier(ITEM)) {
                textToken = nextToken(in);

                if (textToken == null || !textToken.isString()) {
                    throw new Exception("Expecting string literal (menu item name) but have: " + textToken);
                }

                creator.addMenuItem(textToken.getString());
            } else if (textToken.isIdentifier(END)) {
                creator.end();

                return;
            } else if (textToken.isIdentifier(SEPARATOR)) {
                creator.addSeparator();
            } else if (textToken.isIdentifier(MENU)) {
                parseMenu(in, creator);
            } else if (textToken.isIdentifier(TOGGLE)) {
                parseToggle(in, creator);
            } else {
                throw new Exception("Expecting ITEM or SEPARATOR or END but have: " + textToken);
            }
View Full Code Here

Examples of com.nexirius.util.TextToken

            textToken = nextToken(in);
        }
    }

    private TextToken nextToken(PushbackInputStream in) throws Exception {
        TextToken ret = TextToken.nextToken(in);

        while (ret != null && ret.isChar('#')) {
            TextToken.skipLine(in);
            ret = TextToken.nextToken(in);
        }

        return ret;
View Full Code Here

Examples of com.nexirius.util.TextToken

     * @param in The input where the data is read from
     * @throws Exception When the input stream is not readable or corrupt
     */
    public synchronized void readDataFrom(PushbackInputStream in)
            throws Exception {
        TextToken token = TextToken.nextToken(in);

        setHighlightedItem(-1);

        removeChildren();

        if (!token.isChar(OPENB)) {
            throw new Exception("DataModelContainer is not initialized with:'" + OPENB + "' have:" + token);
        }

        while (true) {
            token = TextToken.nextToken(in);

            if (token.isIdentifier(TYPE)) {
                token = TextToken.nextToken(in);
                String type = token.getString();
                token = TextToken.nextToken(in);
                String name = token.getString();
                DataModel m = createMember(type, name);

                m.readDataFrom(in);

                append(m);
            } else if (token.isChar(CLOSEB)) {
                break;
            } else {
                throw new Exception("Expecting " + TYPE + " or " + CLOSEB + " but have:" + token);
            }
        }
View Full Code Here

Examples of com.nexirius.util.TextToken

     * @param out The stream to which the data is written
     * @throws Exception If the stream can not be accessed (write access)
     */
    public void writeDataTo(OutputStream out)
            throws Exception {
        TextToken type = new TextToken(TYPE, TextToken.IDENTIFIER);
        DataModelEnumeration e = getEnumeration();

        out.write('{');
        out.write('\n');

        while (e.hasMore()) {
            DataModel child = e.next();
            TextToken classname = new TextToken(child.getClass().getName());
            TextToken name = new TextToken(child.getFieldName());

            type.writeTo(out);
            out.write(' ');
            classname.writeTo(out);
            out.write(' ');
            name.writeTo(out);
            out.write(' ');

            child.writeDataTo(out);
            out.write('\n');
        }
View Full Code Here

Examples of com.nexirius.util.TextToken

        Style parent_style = default_style;
        TextFile file = new TextFile(stylefile);

        file.openForRead(file_id);

        TextToken token = file.nextToken();

        for (; token != null; token = file.nextToken()) {
            parent_style = default_style;
            String style_name = token.getString();

            if (token.isIdentifier()) {

                token = file.nextToken();

                if (token.isIdentifier("extends")) {
                    token = file.nextToken();

                    Style ps = m_doc.getStyle(token.getString());

                    if (ps != null) {
                        parent_style = ps;
                    }

                    token = file.nextToken();
                }

                Style new_style = m_doc.addStyle(style_name, parent_style);

                error("new style " + style_name);

                if (!token.isChar('{')) {
                    throw new Exception("Can't read style on line " + file.getActLine());
                }

                Attribute attr = readNextAttribute(file);
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.