/************************************************************************
*
* SimpleInputBuffer.java
*
* Copyright: 2002-2007 by Henrik Just
*
* This file is part of Writer2LaTeX.
*
* Writer2LaTeX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Writer2LaTeX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Writer2LaTeX. If not, see .
*
* Version 1.0 (2007-11-22)
*
*/
package writer2latex.util;
/** This class provides a simple string input buffer; it can be used as the
* basis of a tokenizer.
*/
public class SimpleInputBuffer {
private String sContent;
private int nIndex, nLen;
/*private static boolean isEndOrLineEnd(char cChar) {
switch (cChar){
case '\0':
case '\n':
case '\r':
return true;
default:
return false;
}
}*/
private static boolean isDigitOrDot(char cChar) {
return (cChar>='0' && cChar<='9') || cChar=='.';
}
private static boolean isDigitOrDotOrComma(char cChar) {
return isDigitOrDot(cChar) || cChar==',';
}
public SimpleInputBuffer(String sContent) {
this.sContent=sContent;
nLen=sContent.length();
nIndex=0;
}
public int getIndex() { return nIndex; }
public boolean atEnd() {
return nIndex>=nLen;
}
public char peekChar() {
return nIndex='0' && sContent.charAt(nIndex)<='9'){
nIndex++;
}
return sContent.substring(nStart,nIndex);
}
public void skipSpaces() {
while (nIndex