001    /*
002    // $Id: //open/mondrian/src/main/mondrian/olap/StringScanner.java#5 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 1998-2002 Kana Software, Inc.
007    // Copyright (C) 2001-2005 Julian Hyde and others
008    // All Rights Reserved.
009    // You must accept the terms of that agreement to use this software.
010    //
011    // jhyde, 20 January, 1999
012    */
013    
014    package mondrian.olap;
015    
016    
017    /**
018     * Lexical analyzer whose input is a string.
019     */
020    public class StringScanner extends Scanner {
021        private final String s;
022        private int i;
023    
024        public StringScanner(String s, boolean debug) {
025            super(debug);
026            this.s = s;
027            i = 0;
028        }
029    
030        // Override Scanner.getChar().
031        protected int getChar() {
032            return (i >= s.length())
033                ? -1
034                : s.charAt(i++);
035        }
036    }
037    
038    // End StringScanner.java