Package java.io

Examples of java.io.StreamTokenizer


    }

    public boolean parse(String color) {
        clear();
        StringReader s = new StringReader(color);
        st = new StreamTokenizer(s);
        return parse();
    }
View Full Code Here


        if (!coloursFile.exists()) {
            return;
        }

        Reader cr = new FileReader(coloursFile);
        StreamTokenizer st = new StreamTokenizer(cr);

        st.lowerCaseMode(true);
        st.quoteChar('"');
        st.commentChar('#');

        scan: while (true) {
            red = 0;
            green = 0;
            blue = 0;

            switch (st.nextToken()) {
                case StreamTokenizer.TT_EOF:
                    break scan;
                case StreamTokenizer.TT_EOL:
                    break scan;
                case StreamTokenizer.TT_WORD:
                    // read in
                    String key = st.sval;
                    if (key.equals("unitsize")) { //$NON-NLS-1$
                        st.nextToken();
                        unitSize = (int) st.nval;
                    } else if (key.equals("background")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        BACKGROUND = new Color(red, green, blue);
                    } else if (key.equals("heavywoods")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        HEAVY_WOODS = new Color(red, green, blue);
                    } else if (key.equals("ultraheavywoods")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        ULTRA_HEAVY_WOODS = new Color(red, green, blue);
                    } else if (key.equals("sinkhole")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        SINKHOLE = new Color(red, green, blue);
                    } else if (key.equals("smokeandfire")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        SMOKE_AND_FIRE = new Color(red, green, blue);
                    } else {
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        m_terrainColors[Terrains.getType(key)] = new Color(red,
                                green, blue);
                    }
View Full Code Here

        if (!coloursFile.exists()) {
            return;
        }

        Reader cr = new FileReader(coloursFile);
        StreamTokenizer st = new StreamTokenizer(cr);

        st.lowerCaseMode(true);
        st.quoteChar('"');
        st.commentChar('#');

        scan: while (true) {
            red = 0;
            green = 0;
            blue = 0;

            switch (st.nextToken()) {
                case StreamTokenizer.TT_EOF:
                    break scan;
                case StreamTokenizer.TT_EOL:
                    break scan;
                case StreamTokenizer.TT_WORD:
                    // read in
                    String key = st.sval;
                    if (key.equals("unitsize")) { //$NON-NLS-1$
                        st.nextToken();
                        unitSize = (int) st.nval;
                    } else if (key.equals("background")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        BACKGROUND = new Color(red, green, blue);
                    } else if (key.equals("heavywoods")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        HEAVY_WOODS = new Color(red, green, blue);
                    } else if (key.equals("ultraheavywoods")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        ULTRA_HEAVY_WOODS = new Color(red, green, blue);
                    } else if (key.equals("sinkhole")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        SINKHOLE = new Color(red, green, blue);
                    } else if (key.equals("smokeandfire")) { //$NON-NLS-1$
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        SMOKE_AND_FIRE = new Color(red, green, blue);
                    } else {
                        st.nextToken();
                        red = (int) st.nval;
                        st.nextToken();
                        green = (int) st.nval;
                        st.nextToken();
                        blue = (int) st.nval;

                        m_terrainColors[Terrains.getType(key)] = new Color(red,
                                green, blue);
                    }
View Full Code Here

    }

    public boolean parse(String color) {
        clear();
        StringReader s = new StringReader(color);
        st = new StreamTokenizer(s);
        return parse();
    }
View Full Code Here

    public void loadFromFile(String filename) throws IOException {
        // make inpustream for board
        Reader r = new BufferedReader(new FileReader(dir + filename));
        // read board, looking for "size"
        StreamTokenizer st = new StreamTokenizer(r);
        st.eolIsSignificant(true);
        st.commentChar('#');
        st.quoteChar('"');
        st.wordChars('_', '_');
        while (st.nextToken() != StreamTokenizer.TT_EOF) {
            String name = null;
            String imageName = null;
            if ((st.ttype == StreamTokenizer.TT_WORD)
                    && st.sval.equalsIgnoreCase("include")) { //$NON-NLS-1$
                st.nextToken();
                name = st.sval;
                System.out.print("Loading more unit images from "); //$NON-NLS-1$
                System.out.print(name);
                System.out.println("..."); //$NON-NLS-1$
                try {
                    loadFromFile(name);
                    System.out.print("... finished "); //$NON-NLS-1$
                    System.out.print(name);
                    System.out.println("."); //$NON-NLS-1$
                } catch (IOException ioerr) {
                    System.out.print("... failed: "); //$NON-NLS-1$
                    System.out.print(ioerr.getMessage());
                    System.out.println("."); //$NON-NLS-1$
                }
            } else if ((st.ttype == StreamTokenizer.TT_WORD)
                    && st.sval.equalsIgnoreCase("chassis")) { //$NON-NLS-1$
                st.nextToken();
                name = st.sval;
                st.nextToken();
                imageName = st.sval;
                // add to list
                chassis.put(name.toUpperCase(), new MechEntry(name, imageName));
            } else if ((st.ttype == StreamTokenizer.TT_WORD)
                    && st.sval.equalsIgnoreCase("exact")) { //$NON-NLS-1$
                st.nextToken();
                name = st.sval;
                st.nextToken();
                imageName = st.sval;
                // add to list
                exact.put(name.toUpperCase(), new MechEntry(name, imageName));
            }
        }
View Full Code Here

    public void loadFromFile(String filename) throws IOException {
        // make inpustream for board
        Reader r = new BufferedReader(new FileReader(dir + filename));
        // read board, looking for "size"
        StreamTokenizer st = new StreamTokenizer(r);
        st.eolIsSignificant(true);
        st.commentChar('#');
        st.quoteChar('"');
        st.wordChars('_', '_');
        while (st.nextToken() != StreamTokenizer.TT_EOF) {
            String name = null;
            String imageName = null;
            if (st.ttype == StreamTokenizer.TT_WORD
                    && st.sval.equalsIgnoreCase("include")) { //$NON-NLS-1$
                st.nextToken();
                name = st.sval;
                System.out.print("Loading more unit images from "); //$NON-NLS-1$
                System.out.print(name);
                System.out.println("..."); //$NON-NLS-1$
                try {
                    this.loadFromFile(name);
                    System.out.print("... finished "); //$NON-NLS-1$
                    System.out.print(name);
                    System.out.println("."); //$NON-NLS-1$
                } catch (IOException ioerr) {
                    System.out.print("... failed: "); //$NON-NLS-1$
                    System.out.print(ioerr.getMessage());
                    System.out.println("."); //$NON-NLS-1$
                }
            } else if (st.ttype == StreamTokenizer.TT_WORD
                    && st.sval.equalsIgnoreCase("chassis")) { //$NON-NLS-1$
                st.nextToken();
                name = st.sval;
                st.nextToken();
                imageName = st.sval;
                // add to list
                chassis.put(name.toUpperCase(), new MechEntry(name, imageName));
            } else if (st.ttype == StreamTokenizer.TT_WORD
                    && st.sval.equalsIgnoreCase("exact")) { //$NON-NLS-1$
                st.nextToken();
                name = st.sval;
                st.nextToken();
                imageName = st.sval;
                // add to list
                exact.put(name.toUpperCase(), new MechEntry(name, imageName));
            }
        }
View Full Code Here

  public String[] split(final String commandLine) {
    ArrayList<String> parts = new ArrayList<String>();

    Reader r = new StringReader(commandLine);
    StreamTokenizer st = new StreamTokenizer(r);
    st.resetSyntax();
    st.wordChars(32, 255);
    st.whitespaceChars(0, ' ');
    st.quoteChar('"');
    st.quoteChar('\'');

    int token = TT_EOF;
    try {
      while ((token = st.nextToken()) != TT_EOF) {
        switch (token) {
          case TT_WORD:
            parts.add(st.sval);
            break;
          case '\'':
View Full Code Here

     * @param words Accepted keywords
     * @param in InputStream where to read from
     */
    public SimpleParser(String[] words, InputStream in) {
        Reader r = new BufferedReader(new InputStreamReader(in));
        tokenizer = new StreamTokenizer(r);
        tokenizer.slashSlashComments(true);
        tokenizer.slashStarComments(true);
        initKeywords(words);
    }
View Full Code Here

     *
     * @param in InputStream where to read from
     */
    public void open(InputStream in) {
        Reader r = new BufferedReader(new InputStreamReader(in));
        tokenizer = new StreamTokenizer(r);
        tokenizer.slashSlashComments(true);
        tokenizer.slashStarComments(true);

    }
View Full Code Here

        try {
            // make inpustream for board
            Reader r = new BufferedReader(new FileReader("data/boards"
                    + File.separator + filename));
            // read board, looking for "size"
            StreamTokenizer st = new StreamTokenizer(r);
            st.eolIsSignificant(true);
            st.commentChar('#');
            st.quoteChar('"');
            st.wordChars('_', '_');
            while (st.nextToken() != StreamTokenizer.TT_EOF) {
                if (st.ttype == StreamTokenizer.TT_WORD
                        && st.sval.equalsIgnoreCase("size")) {
                    st.nextToken();
                    boardx = (int) st.nval;
                    st.nextToken();
                    boardy = (int) st.nval;
                    break;
                }
            }
            r.close();
View Full Code Here

TOP

Related Classes of java.io.StreamTokenizer

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.