|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectImageReader
SpatialImageReader
StreamImageReader
TextImageReader
public abstract class TextImageReader
Base class for image readers that expect a BufferedReader input source.
"Text images" are usually ASCII files where pixels values are actually
the geophysical values. This base class provides the following conveniences:
BufferedReader from the input types, which may be a any type documented
in the super-class plus Reader.LineFormat for parsing a whole line as a record. Subclasses can override
this method for parsing text files having non-numeric columns (angles, dates, etc.).getCharset(InputStream) method.
TextImageWriter
| coverage/geotk-coverageio (download) | View source code for this class |
| Nested Class Summary | |
|---|---|
protected static class |
TextImageReader.Spi
Service provider interface (SPI) for TextImageReaders. |
| Field Summary |
|---|
| Fields inherited from class StreamImageReader |
|---|
closeOnReset |
| Fields inherited from class ImageReader |
|---|
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
| Fields inherited from interface WarningProducer |
|---|
LOGGER |
| Constructor Summary | |
|---|---|
protected |
TextImageReader(TextImageReader.Spi provider)
Constructs a new image reader. |
| Method Summary | |
|---|---|
protected void |
close()
Closes the reader created by getReader(). |
protected Charset |
getCharset(InputStream input)
Returns the character set to use for decoding the string from the input stream. |
protected LineFormat |
getLineFormat(int imageIndex)
Returns the line format to use for parsing every lines in the input stream. |
protected double |
getPadValue(int imageIndex)
Returns the pad value for missing data, or Double.NaN if none. |
protected String |
getPositionString(String message)
Returns a string representation of the current stream position. |
protected BufferedReader |
getReader()
Returns the input as an buffered reader. |
protected boolean |
isComment(String line)
Returns true if the specified line is a comment. |
| Methods inherited from class StreamImageReader |
|---|
finalize, getChannel, getInputStream, getStreamLength, setInput |
| Methods inherited from class Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface Localized |
|---|
getLocale |
| Constructor Detail |
|---|
protected TextImageReader(TextImageReader.Spi provider)
provider - The ImageReaderSpi that is constructing this object, or null.| Method Detail |
|---|
protected Charset getCharset(InputStream input)
throws IOException
TextImageReader.Spi object given to this TextImageReader constructor. Subclasses can
override this method if they want to detect the character encoding in some other way.
input - The input stream.
null for the platform default encoding.
IOException - If reading from the input stream failed.TextImageReader.Spi.charset
protected LineFormat getLineFormat(int imageIndex)
throws IOException
LineFormat instance using the locale specified by
TextImageReader.Spi.locale. Subclasses should override this method if they want more control
on the parser to be created.
imageIndex - the index of the image to be queried.
IOException - If reading from the input stream failed.TextImageReader.Spi.locale
protected double getPadValue(int imageIndex)
throws IOException
Double.NaN if none. The pad value will
applies to all columns except the one for
x and
y values, if any.
The default implementation returns the pad value specified to the TextImageReader.Spi object given
to this TextImageReader constructor. Subclasses can override this method if they
want to detect the pad value in some other way.
imageIndex - the index of the image to be queried.
Double.NaN if none.
IOException - If reading from the input stream failed.TextImageReader.Spi.padValue
protected BufferedReader getReader()
throws IllegalStateException,
IOException
File, URL, URLConnection, Reader,
InputStream and ImageInputStream.
This method creates a new reader only when first invoked.
All subsequent calls will returns the same instance. Consequently, the returned reader
should never be closed by the caller. It may be closed automatically
when setInput(...), reset() or dispose() methods are invoked.
ImageReader.getInput() as a BufferedReader.
IllegalStateException - if the input is not set.
IOException - If the input stream can't be created for an other reason.ImageReader.getInput(),
StreamImageReader.getInputStream()protected boolean isComment(String line)
true if the specified line is a comment. This method is invoked automatically
during a read operation. The default implementation returns true if the
line is empty or if the first non-whitespace character is '#', and false
otherwise. Override this method if comment lines should be determined in a different way.
line - A line to be parsed.
true if the line is a comment and should be ignored, or false if it
should be parsed.protected String getPositionString(String message)
"Line 14 in file HUV18204.asc". This method returns
null if the stream position is unknown.
message - An optional message to append to the stream position, or null
if none.
protected void close()
throws IOException
getReader(). This method does nothing if
the reader is the input instance given by the user rather
than a reader created by this class from a File or URL input.
close in class StreamImageReaderIOException - If an error occurred while closing the reader.StreamImageReader.closeOnReset
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||