|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.imageio.ImageReader
org.geotools.image.io.GeographicImageReader
org.geotools.image.io.StreamImageReader
org.geotools.image.io.text.TextImageReader
public abstract class TextImageReader
Base class for text image decoders. "Text images" are usually ASCII files containing pixel
as geophysical values. This base class provides a convenient way to get BufferedReader
for reading lines.
TextImageReader
accepts many input types, including File
, URL
,
Reader
, InputStream
and ImageInputStream
. The TextImageReader.Spi
provider
automatically advises those input types. The above cited Spi
provided also provides
a convenient way to control the character encoding, with the charset
field.
Developer can gain yet more control on character encoding by overriding the getCharset(java.io.InputStream)
method.
Nested Class Summary | |
---|---|
static class |
TextImageReader.Spi
Service provider interface (SPI) for TextImageReader s. |
Field Summary |
---|
Fields inherited from class org.geotools.image.io.StreamImageReader |
---|
closeOnReset |
Fields inherited from class javax.imageio.ImageReader |
---|
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
Constructor Summary | |
---|---|
protected |
TextImageReader(javax.imageio.spi.ImageReaderSpi provider)
Constructs a new image reader. |
Method Summary | |
---|---|
protected void |
close()
Closes the reader created by getReader() . |
protected java.nio.charset.Charset |
getCharset(java.io.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)
Deprecated. Should be specified in metadata instead, and implementations should use SampleConverter . |
protected java.lang.String |
getPositionString(java.lang.String message)
Returns a string representation of the current stream position. |
protected java.io.BufferedReader |
getReader()
Returns the input as an buffered reader. |
protected boolean |
isComment(java.lang.String line)
Returns true if the specified line is a comment. |
Methods inherited from class org.geotools.image.io.StreamImageReader |
---|
dispose, finalize, getInputStream, getStreamLength, reset, setInput |
Methods inherited from class org.geotools.image.io.GeographicImageReader |
---|
checkBandIndex, checkImageIndex, collapseNoDataValues, flipVertically, getDefaultReadParam, getDestination, getDimension, getGeographicMetadata, getImageMetadata, getImageTypes, getNumBands, getNumImages, getRawDataType, getRawImageType, getRawImageType, getStreamMetadata, read, warningOccurred |
Methods inherited from class javax.imageio.ImageReader |
---|
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getHeight, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected TextImageReader(javax.imageio.spi.ImageReaderSpi provider)
provider
- The provider that is invoking this constructor, or null
if none.Method Detail |
---|
protected java.nio.charset.Charset getCharset(java.io.InputStream input) throws java.io.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.
java.io.IOException
- If reading from the input stream failed.TextImageReader.Spi.charset
protected LineFormat getLineFormat(int imageIndex) throws java.io.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.
java.io.IOException
- If reading from the input stream failed.TextImageReader.Spi.locale
protected double getPadValue(int imageIndex) throws java.io.IOException
SampleConverter
.
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.
java.io.IOException
- If reading from the input stream failed.TextImageReader.Spi.padValue
protected java.io.BufferedReader getReader() throws java.lang.IllegalStateException, java.io.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
.
java.lang.IllegalStateException
- if the input is not set.
java.io.IOException
- If the input stream can't be created for an other reason.ImageReader.getInput()
,
StreamImageReader.getInputStream()
protected boolean isComment(java.lang.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 java.lang.String getPositionString(java.lang.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 java.io.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 StreamImageReader
java.io.IOException
- if an error occured while closing the stream.StreamImageReader.closeOnReset
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |