org.geotools.image.io.text
Class TextImageReader.Spi

java.lang.Object
  extended by javax.imageio.spi.IIOServiceProvider
      extended by javax.imageio.spi.ImageReaderWriterSpi
          extended by javax.imageio.spi.ImageReaderSpi
              extended by org.geotools.image.io.StreamImageReader.Spi
                  extended by org.geotools.image.io.text.TextImageReader.Spi
All Implemented Interfaces:
javax.imageio.spi.RegisterableService
Direct Known Subclasses:
TextMatrixImageReader.Spi, TextRecordImageReader.Spi
Enclosing class:
TextImageReader

public abstract static class TextImageReader.Spi
extends StreamImageReader.Spi

Service provider interface (SPI) for TextImageReaders. This SPI provides a convenient way to control the TextImageReader character encoding: the charset field. For example, many Spi subclasses will put the following line in their constructor:

 charset = Charset.forName("ISO-LATIN-1"); // ISO Latin Alphabet No. 1 (ISO-8859-1)
 

Since:
2.4
Version:
$Id: TextImageReader.java 33694 2009-08-06 13:23:57Z aaime $
Author:
Martin Desruisseaux (IRD)

Field Summary
protected  java.nio.charset.Charset charset
          Character encoding, or null for the default.
protected  java.util.Locale locale
          The locale for numbers or dates parsing.
protected  double padValue
          The pad value, or Double.NaN if none.
 
Fields inherited from class javax.imageio.spi.ImageReaderSpi
inputTypes, STANDARD_INPUT_TYPE, writerSpiNames
 
Fields inherited from class javax.imageio.spi.ImageReaderWriterSpi
extraImageMetadataFormatClassNames, extraImageMetadataFormatNames, extraStreamMetadataFormatClassNames, extraStreamMetadataFormatNames, MIMETypes, names, nativeImageMetadataFormatClassName, nativeImageMetadataFormatName, nativeStreamMetadataFormatClassName, nativeStreamMetadataFormatName, pluginClassName, suffixes, supportsStandardImageMetadataFormat, supportsStandardStreamMetadataFormat
 
Fields inherited from class javax.imageio.spi.IIOServiceProvider
vendorName, version
 
Constructor Summary
TextImageReader.Spi()
          Constructs a quasi-blank TextImageReader.Spi.
 
Method Summary
 boolean canDecodeInput(java.lang.Object source)
          Returns true if the supplied source object appears to be of the format supported by this reader.
protected  boolean canDecodeInput(java.lang.Object source, int readAheadLimit)
          Returns true if the supplied source object appears to be of the format supported by this reader.
protected  boolean isValidContent(double[][] rows)
          Returns true if the content of the first few rows seems valid, or false otherwise.
 
Methods inherited from class javax.imageio.spi.ImageReaderSpi
createReaderInstance, createReaderInstance, getImageWriterSpiNames, getInputTypes, isOwnReader
 
Methods inherited from class javax.imageio.spi.ImageReaderWriterSpi
getExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getImageMetadataFormat, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, getStreamMetadataFormat, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupported
 
Methods inherited from class javax.imageio.spi.IIOServiceProvider
getDescription, getVendorName, getVersion, onDeregistration, onRegistration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

charset

protected java.nio.charset.Charset charset
Character encoding, or null for the default. This field is initially null. A value shall be set by subclasses if the files to be decoded use some specific character encoding.

See Also:
TextImageReader.getCharset(java.io.InputStream)

locale

protected java.util.Locale locale
The locale for numbers or dates parsing. For example Locale.US means that numbers are expected to use dot as decimal separator. This field is initially null, which means that default locale should be used.

See Also:
TextImageReader.getLineFormat(int), TextRecordImageReader#parseLine

padValue

protected double padValue
The pad value, or Double.NaN if none. Every occurences of pixel value equals to this pad value will be replaced by Double.NaN during read operation. Note that this replacement doesn't apply to non-pixel values (for example x, y coordinates in some file format).

See Also:
TextImageReader.getPadValue(int), TextRecordImageReader#parseLine
Constructor Detail

TextImageReader.Spi

public TextImageReader.Spi()
Constructs a quasi-blank TextImageReader.Spi. It is up to the subclass to initialize instance variables in order to provide working versions of all methods. This constructor provides the following defaults: For efficienty reasons, the above fields are initialized to shared arrays. Subclasses can assign new arrays, but should not modify the default array content.

Method Detail

canDecodeInput

public boolean canDecodeInput(java.lang.Object source)
                       throws java.io.IOException
Returns true if the supplied source object appears to be of the format supported by this reader. The default implementation tries to parse the first few lines up to 1024 characters.

Specified by:
canDecodeInput in class javax.imageio.spi.ImageReaderSpi
Parameters:
source - The object (typically an ImageInputStream) to be decoded.
Returns:
true if the source seems readable.
Throws:
java.io.IOException - If an error occured during reading.

canDecodeInput

protected boolean canDecodeInput(java.lang.Object source,
                                 int readAheadLimit)
                          throws java.io.IOException
Returns true if the supplied source object appears to be of the format supported by this reader. The default implementation tries to parse the first few lines up to the specified number of characters.

Parameters:
source - The object (typically an ImageInputStream) to be decoded.
readAheadLimit - Maximum number of characters to read. If this amount is reached but this method still unable to make a choice, then it conservatively returns false.
Returns:
true if the source seems readable.
Throws:
java.io.IOException - If an error occured during reading.

isValidContent

protected boolean isValidContent(double[][] rows)
Returns true if the content of the first few rows seems valid, or false otherwise. The number of rows depends on the row length and the readAheadLimit argument given to canDecodeInput.

The default implementation returns true if there is at least one row and every row have the same number of columns.



Copyright © 1996-2010 Geotools. All Rights Reserved.