com.c5corp.c5dem
Class Reader

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by com.c5corp.c5dem.Reader
All Implemented Interfaces:
java.io.Closeable

public class Reader
extends java.io.BufferedInputStream

Reader.java is a general purpose text file reader that has methods for reading different data types out of the same file. It was designed for use with USGS DEM files and the data types found in that particular file format. It extends java.io.BufferedInputStream.

Since:
1.0
Author:
Brett Stalbaum Copyright 2002-2006 see LICENSE.txt and UCSD_LICENSE.txt

Field Summary
protected  boolean eof
           
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
protected Reader(java.lang.String str)
          Constructor for a reader accepts a String specifying the path to the DEM file.
protected Reader(java.lang.String str, int buf)
          Constructor for a reader accepts a String specifying the path to the DEM file.
protected Reader(java.net.URL url)
          Constructor for a reader accepts a java.net.URL specifying the path to the dem file.
 
Method Summary
 long getReaderPosition()
          Returns the position of the internal reader
 char readCharRange(int from, int to)
          public char readCharRange(InputStream in, int from, int to); reader that counts from (from) to in, grabing the chars in the range public int from (which is the previous to) int to if there is no input (just space), a single space is returned
 double[] ReadDataElementsDouble(int number_of_elements)
          public double[] ReadDataElementsDouble(int number_of_elements); reader that reads in a stream of Data from a Dem file and converts the space separated input into elements of an array...
 int[] ReadDataElementsInt(int number_of_elements)
          public int[] ReadDataElementsInt(int number_of_elements); reader that reads in a stream of Data from a Dem file and converts the space separated input into elements of an array...
 short[] ReadDataElementsShort(int number_of_elements)
          public short[] ReadDataElementsShort(int number_of_elements); A reader method that reads in a stream of Data from a Dem file and converts the space separated input into elements of an array...
 double readDoubleRange(int from, int to)
          public double readDoubleRangeRange(int from, int to) reader that takes the current count from in, grabs the chars in that range, and if there is no input (just space), NaN is returned.
 short readShortRange(int from, int to)
          public short readShortRange(InputStream in, int from, int to) reader that takes the current count from in, grabs the chars in that range, and if there is no input (just space), -1 is returned
 java.lang.String readStringRange(int from, int to)
          public String readStringRange(int from, int to); reader that takes the current count from in, grabs the chars in the range public int from (typically the previous to) int to if there is no input (just space), a single space is returned
 java.lang.String toString()
          overrides java.lang.Object.toString()
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

eof

protected boolean eof
Constructor Detail

Reader

protected Reader(java.lang.String str)
          throws java.io.IOException
Constructor for a reader accepts a String specifying the path to the DEM file.

Parameters:
str - String representation of a DEM file
Throws:
java.io.IOException

Reader

protected Reader(java.lang.String str,
                 int buf)
          throws java.io.IOException
Constructor for a reader accepts a String specifying the path to the DEM file. Allows the specification of a buffer size for BufferedInputStream class.

Parameters:
str - String representation of a DEM file
buf - the buffer size
Throws:
java.io.IOException
See Also:
BufferedInputStream

Reader

protected Reader(java.net.URL url)
          throws java.io.IOException
Constructor for a reader accepts a java.net.URL specifying the path to the dem file. Allows the specification of a buffer size for BufferedInputStream class.

Parameters:
url - the URL pointing to a DEM
Throws:
java.io.IOException
Since:
1.0.3
Method Detail

ReadDataElementsShort

public short[] ReadDataElementsShort(int number_of_elements)
public short[] ReadDataElementsShort(int number_of_elements); A reader method that reads in a stream of Data from a Dem file and converts the space separated input into elements of an array... has ability to stop at eof (also sets eof to true)

Parameters:
number_of_elements - the number of elements to parse
Returns:
an array containing the elements

ReadDataElementsInt

public int[] ReadDataElementsInt(int number_of_elements)
public int[] ReadDataElementsInt(int number_of_elements); reader that reads in a stream of Data from a Dem file and converts the space separated input into elements of an array... has ability to stop at eof (also sets eof to true). Added in version 1.0.2 because dem files denominated in meters actually contain decimeters.

Parameters:
number_of_elements - the number of elements to parse
Returns:
an array containing the elements

ReadDataElementsDouble

public double[] ReadDataElementsDouble(int number_of_elements)
public double[] ReadDataElementsDouble(int number_of_elements); reader that reads in a stream of Data from a Dem file and converts the space separated input into elements of an array... has ability to stop at eof (also sets eof to true)

Parameters:
number_of_elements - the number of elements to parse
Returns:
an array containing the elements

readStringRange

public java.lang.String readStringRange(int from,
                                        int to)
public String readStringRange(int from, int to); reader that takes the current count from in, grabs the chars in the range public int from (typically the previous to) int to if there is no input (just space), a single space is returned

Parameters:
from - here
to - here
Returns:
the String representation of the chars

readCharRange

public char readCharRange(int from,
                          int to)
public char readCharRange(InputStream in, int from, int to); reader that counts from (from) to in, grabing the chars in the range public int from (which is the previous to) int to if there is no input (just space), a single space is returned

Parameters:
from - here
to - here
Returns:
the String representation of the chars

readShortRange

public short readShortRange(int from,
                            int to)
public short readShortRange(InputStream in, int from, int to) reader that takes the current count from in, grabs the chars in that range, and if there is no input (just space), -1 is returned

Parameters:
from - here
to - here
Returns:
the String representation of the chars

readDoubleRange

public double readDoubleRange(int from,
                              int to)
public double readDoubleRangeRange(int from, int to) reader that takes the current count from in, grabs the chars in that range, and if there is no input (just space), NaN is returned.

Parameters:
from - here
to - here
Returns:
the String representation of the chars

getReaderPosition

public long getReaderPosition()
Returns the position of the internal reader

Returns:
the position of the internal reader

toString

public java.lang.String toString()
overrides java.lang.Object.toString()

Overrides:
toString in class java.lang.Object