Package com.nexirius.util

Examples of com.nexirius.util.TextToken


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

        TextToken token = TextToken.nextToken(in);

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

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

            if (token.isChar(CLOSEB)) {
                break;
            } else if (token.isString()) {
                String name = token.getString();

                try {
                    DataModel m = getChild(name);

                    m.readDataFrom(in);
View Full Code Here


        while (e.hasMore()) {
            DataModel child = e.next();

            if (!child.isTransient()) {
                TextToken name = new TextToken(child.getFieldName());

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

        out.write('\n');
    }

    public void ignoreChild(String name, PushbackInputStream in)
            throws Exception {
        TextToken token;
        int nest = 0;

        FWLog.debug("Ignoring child " + name);

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

            if (token == null) {

                break;
            }

            if (token.isChar(OPENB)) {
                ++nest;
            } else if (token.isChar(CLOSEB)) {
                --nest;
            }

            if (nest == 0) {
                break;
View Full Code Here

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

        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);

                if (m instanceof DataModelContainer) {
                    ((DataModelContainer) m).readInitDataFrom(in);
                } else {
                    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

     * @param out The stream to which the data is written
     * @throws Exception If the stream can not be accessed (write access)
     */
    public void writeInitDataTo(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(' ');

            if (child instanceof DataModelContainer) {
                ((DataModelContainer) child).writeInitDataTo(out);
            } else {
View Full Code Here

     */
    public void readDataFrom(PushbackInputStream in)
            throws Exception {
        getStatus().readDataFrom(in, this);

        TextToken token = TextToken.nextToken(in);

        if (token.isString()) {
            String s = token.getString();

            setTime(Long.parseLong(s));
        } else {
            throw new Exception("Expecting String token but have:" + token);
        }
View Full Code Here

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

        TextToken value = new TextToken(Long.toString(getTime()));

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

TOP

Related Classes of com.nexirius.util.TextToken

Copyright © 2018 www.massapicom. 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.