/* java.util.Scanner -- Parses primitive types and strings using regexps
Copyright (C) 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath 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 2, or (at your option)
any later version.
GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.util;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.ReadableByteChannel;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Iterator;
import java.util.Locale;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author E0327023 Hernadi Laszlo
*/
public class Scanner
implements Iterator <String>
{
private static final String NOT_LONG = "\" is not a long"; //$NON-NLS-1$
private static final String ERR_PREFIX = "\""; //$NON-NLS-1$
private static final String NOT_INT = "\" is not an integer"; //$NON-NLS-1$
private static final String NOT_DOUBLE = "\" is not a double"; //$NON-NLS-1$
private static final String NOT_BYTE = "\" is not a byte"; //$NON-NLS-1$
private static final String NOT_BOOLEAN = "\" is not a boolean"; //$NON-NLS-1$
private static final String IS_NOT = "\" is not "; //$NON-NLS-1$
private static final String DEFAULT_PATTERN_S = "\\p{javaWhitespace}+"; //$NON-NLS-1$
private static final Pattern DEFAULT_PATTERN =
Pattern.compile (DEFAULT_PATTERN_S);
private static final String BIG_INTEGER = "BigInteger"; //$NON-NLS-1$
private final static String NEW_LINE =
System.getProperty ("line.separator");
private IOException lastIOException = null;
/**
* An InputStream source if a Constructor with an InputStream source is called, otherwise it
* stays <source> null </source>.
*/
private InputStream bIS = null;
/**
* Length of the input Buffer, which is the maximum bytes to be read at once.
*/
private final int MaxBufferLen = 1000000;
/**
* Minimum buffer length. If there are less chars in the Buffer than this value reading from
* source is tried.
*/
private final int MIN_BUF_LEN = 100;
/**
* Maximum number of processed chars in the Buffer. If exeeded, all processed chars from the
* beginning of the Buffer will be discarded to save space. The bytes left are copyed into a new
* Buffer.
|