jwo.utils.dbase
Class NumberParser

java.lang.Object
  extended by jwo.utils.dbase.NumberParser

public final class NumberParser
extends Object

Various number parsing utilities. This code is based on the class provided as part of the Geotools OpenSource mapping toolkit - www.geotools.org/ under the GNU Lesser General Public License.

Version:
2.3, 11th April 2006.
Author:
Geotools/GISToolkit modified by Jo Wood.

Constructor Summary
NumberParser()
          Creates a new parser.
 
Method Summary
 double parseDouble(CharSequence s, int start, int end)
          Parses a given block of text represented as a character sequence and extracts a double value from it.
 double parseDouble(String s)
          Parses a given block of text and extracts a double value from it.
 int parseInt(CharSequence s, int start, int end)
          Parses a given block of text represented as a character sequence and extracts an integer value from it.
 int parseInt(String s)
          Parses a given block of text and extracts an integer value from it.
 long parseLong(CharSequence s, int start, int end)
          Parses a given block of text represented as a character sequence and extracts a long value from it.
 long parseLong(String s)
          Parses a given block of text and extracts a long value from it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberParser

public NumberParser()
Creates a new parser.

Method Detail

parseInt

public int parseInt(String s)
             throws NumberFormatException
Parses a given block of text and extracts an integer value from it.

Parameters:
s - String to parse.
Returns:
Integer representation of the text.
Throws:
NumberFormatException - If problem extracting integer from text.

parseInt

public int parseInt(CharSequence s,
                    int start,
                    int end)
             throws NumberFormatException
Parses a given block of text represented as a character sequence and extracts an integer value from it.

Parameters:
s - Character sequence to parse.
start - Index of start of character sequence marking section to parse.
end - Index of end of character sequence marking section to parse.
Returns:
Integer representation of the text.
Throws:
NumberFormatException - If problem extracting integer from character sequence.

parseLong

public long parseLong(String s)
Parses a given block of text and extracts a long value from it.

Parameters:
s - String to parse.
Returns:
Long representation of the text.
Throws:
NumberFormatException - If problem extracting long from text.

parseLong

public long parseLong(CharSequence s,
                      int start,
                      int end)
               throws NumberFormatException
Parses a given block of text represented as a character sequence and extracts a long value from it.

Parameters:
s - Character sequence to parse.
start - Index of start of character sequence marking section to parse.
end - Index of end of character sequence marking section to parse.
Returns:
Long representation of the text.
Throws:
NumberFormatException - If problem extracting long from character sequence.

parseDouble

public double parseDouble(String s)
                   throws NumberFormatException
Parses a given block of text and extracts a double value from it.

Parameters:
s - String to parse.
Returns:
Double representation of the text.
Throws:
NumberFormatException - If problem extracting double from text.

parseDouble

public double parseDouble(CharSequence s,
                          int start,
                          int end)
                   throws NumberFormatException
Parses a given block of text represented as a character sequence and extracts a double value from it.

Parameters:
s - Character sequence to parse.
start - Index of start of character sequence marking section to parse.
end - Index of end of character sequence marking section to parse.
Returns:
Double representation of the text.
Throws:
NumberFormatException - If problem extracting double from character sequence.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009