Examples of TextToken


Examples of com.nexirius.util.TextToken

     */
    public void readDataFrom(PushbackInputStream in)
            throws Exception {
        super.readDataFrom(in);

        TextToken token = TextToken.nextToken(in);

        if (token.isString()) {
            String value = token.getString();
            SimpleType v = getSimpleType().duplicate();

            v.set(value);

            assignValue(v);
View Full Code Here

Examples of com.nexirius.util.TextToken

     */
    public void writeDataTo(OutputStream out)
            throws Exception {
        super.writeDataTo(out);

        TextToken value = new TextToken(getSimpleType().toString());

        value.writeTo(out);
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

        file.close();
    }

    private Attribute readNextAttribute(TextFile file)
            throws Exception {
        TextToken token = file.nextToken();

        if (token != null && token.isChar('}')) {
            return null;
        }

        if (token != null && token.isIdentifier()) {
            for (int i = 0; i < attribute.length; ++i) {

                if (token.isIdentifier(attribute[i].getIdentifier())) {
                    token = file.nextToken();

                    if (token != null && token.isChar('=')) {
                        token = file.nextToken();

                        if (token != null) {
                            return attribute[i].createFrom(token);
                        }
View Full Code Here

Examples of com.nexirius.util.TextToken

     * @param in The input stream
     * @throws Exception If the stream cannot be read or the data is corrupt
     */
    public void readDataFrom(PushbackInputStream in)
            throws Exception {
        TextToken token = TextToken.nextToken(in);

        if (token.isIdentifier("T") || token.isIdentifier("F")) {
            if (token.isIdentifier("T")) {
                setBoolean(true);
            } else {
                setBoolean(false);
            }
        } else {
View Full Code Here

Examples of com.nexirius.util.TextToken

     * @param out The output stream
     * @throws Exception If the stream cannot be written
     */
    public void writeDataTo(OutputStream out)
            throws Exception {
        TextToken value = new TextToken((getBoolean() ? "T" : "F"), TextToken.IDENTIFIER);

        value.writeTo(out);
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

    public String toString() {
        int len = getLength();
        StringBuffer sb = new StringBuffer();

        sb.append(new TextToken(getComponentType().getName()).toString());

        for (int i = 0; i < len; ++i) {
            Object o = getItem(i);

            if (o == null) {
                sb.append(new TextToken("").toString());
            } else {
                sb.append(new TextToken(o.toString()).toString());
            }

            if (i < len - 1) {
                sb.append(SEPARATOR);
            }
View Full Code Here

Examples of com.nexirius.util.TextToken

        return sb.toString();
    }

    public void set(String value) {
        try {
            TextToken t[] = TextToken.getTokensFrom(value);
            Class type = Class.forName(t[0].getString());
            Object newValue[] = (Object[]) Array.newInstance(type, t.length - 1);
            Class param[] = {new String("").getClass()};

            Constructor constr = type.getConstructor(param);
View Full Code Here

Examples of com.nexirius.util.TextToken

        }
    }

    public static DataModelRemoteEvent createEvent(PushbackInputStream in)
            throws Exception {
        TextToken t = TextToken.nextToken(in);

        if (t == null) {

            return null;
        }

        if (t.isIdentifier(COMMAND_UPDATE)) {
            return new DataModelUpdateEvent(in);
        } else if (t.isIdentifier(COMMAND_GET)) {
            return new DataModelGetEvent(in);
        } else if (t.isIdentifier(COMMAND_METHOD)) {
            return new DataModelMethodEvent(in);
        }

        throw new Exception("No command '" + t + "'");
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

    boolean parseType()
            throws Exception {
        try {
            // check whether the next token is a 'class' or 'enum'
            TextToken t = nextToken();

            if (t.isIdentifier(CLASS)) {
                pushbackToken();

                return parseClass();
            }

            if (t.isIdentifier(ENUM)) {
                pushbackToken();

                return parseEnum();
            }

            throw new SyntaxException("class or enum", t.debugString());
        } catch (NoMoreTokensException ex) {
            return false;
        }
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

    boolean parseEnum()
            throws Exception {
        try {
            // check whether the next token is a 'enum'
            TextToken t = nextToken();

            if (!t.isIdentifier(ENUM)) {
                throw new SyntaxException(ENUM, t.debugString());
            }

            t = nextToken();

            if (!t.isIdentifier()) {
                throw new SyntaxException("enum name", t.debugString());
            }
//System.out.println("parsing enum " + t.getString());
            DataModelTypeEnum e = new DataModelTypeEnum(t.getString());


            t = nextToken();

            if (!t.isChar(OCURLY)) {
                throw new SyntaxException(OCURLY, t.debugString());
            }

            t = nextToken();

            while (true) {
                if (t.isChar(CCURLY)) {
                    break;
                }

                if (!t.isString()) {
                    throw new SyntaxException("enum value (string literal)", t.debugString());
                }

                e.addValue(t.getString());

                t = nextToken();
            }

            types.add(e);
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.