| org.geotools.image.io.StreamImageReader org.geotools.image.io.text.TextImageReader
All known Subclasses: org.geotools.image.io.text.TextRecordImageReader, org.geotools.image.io.text.TestReader, org.geotools.image.io.text.TextMatrixImageReader,
TextImageReader | abstract public class TextImageReader extends StreamImageReader (Code) | | 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
Spi provider
automatically advises those input types. The above cited
Spi provided also provides
a convenient way to control the character encoding, with the
Spi.charset charset field.
Developer can gain yet more control on character encoding by overriding the
TextImageReader.getCharset method.
since: 2.4 version: $Id: TextImageReader.java 26761 2007-08-29 21:25:45Z desruisseaux $ author: Martin Desruisseaux |
TextImageReader | protected TextImageReader(ImageReaderSpi provider)(Code) | | Constructs a new image reader.
Parameters: provider - The provider that is invoking this constructor, or null if none. |
getCharset | protected Charset getCharset(InputStream input) throws IOException(Code) | | Returns the character set to use for decoding the string from the input stream. The default
implementation returns the
specified to the
Spi object given to this
TextImageReader constructor. Subclasses can
override this method if they want to detect the character encoding in some other way.
Parameters: input - The input stream. The character encoding, or null for the platform default encoding. throws: IOException - If reading from the input stream failed. See Also: Spi.charset |
getLineFormat | protected LineFormat getLineFormat(int imageIndex) throws IOException(Code) | | Returns the line format to use for parsing every lines in the input stream. The default
implementation creates a new
LineFormat instance using the locale specified by
Spi.locale . Subclasses should override this method if they want more control
on the parser to be created.
Parameters: imageIndex - the index of the image to be queried. throws: IOException - If reading from the input stream failed. See Also: Spi.locale |
getPadValue | protected double getPadValue(int imageIndex) throws IOException(Code) | | Returns the pad value for missing data, or
Double.NaN if none. The pad value will
applies to all columns except the one for
TextRecordImageReader.getColumnX x and
TextRecordImageReader.getColumnY y values, if any.
The default implementation returns the pad value specified to the
Spi object given
to this
TextImageReader constructor. Subclasses can override this method if they
want to detect the pad value in some other way.
Parameters: imageIndex - the index of the image to be queried. throws: IOException - If reading from the input stream failed. See Also: Spi.padValue SampleConverter |
getPositionString | protected String getPositionString(String message)(Code) | | Returns a string representation of the current stream position. For example this method
may returns something like
"Line 14 in file HUV18204.asc" . This method returns
null if the stream position is unknown.
Parameters: message - An optional message to append to the stream position, or null if none. |
getStreamLength | final long getStreamLength(int fromImage, int toImage) throws IOException(Code) | | Retourne une approximation du nombre d'octets du flot occupés par les
images
fromImage inclusivement jusqu'à
toImage exclusivement. L'implémentation par défaut calcule cette longueur en
supposant que toutes les images se divisent la longueur totale du flot
en parts égales.
Parameters: fromImage - Index de la première image à prendre en compte. Parameters: toImage - Index suivant celui de la dernière image à prendre encompte, ou -1 pour prendre en compte toutes les imagesrestantes jusqu'à la fin du flot. Le nombre d'octets occupés par les images spécifiés, ou -1 sicette longueur n'a pas pu être calculée. Si le calcul précis decette longueur serait prohibitif, cette méthode est autorisée àretourner une simple approximation ou même à retourner la longueurtotale du flot. throws: IOException - si une erreur est survenue lors de la lecture du flot. |
getStreamPosition | static long getStreamPosition(Reader reader) throws IOException(Code) | | Retourne la position du flot spécifié, ou
-1 si cette position est
inconnue. Note: la position retournée est approximative.
Elle est utile pour afficher un rapport des progrès, mais sans plus.
Parameters: reader - Flot dont on veut connaître la position. Position approximative du flot, ou -1 si cette position n'a pas pu être obtenue. throws: IOException - si l'opération a échouée. |
isComment | protected boolean isComment(String line)(Code) | | Returns
true if the specified line is a comment. This method is invoked automatically
during a
TextImageReader.read 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.
Parameters: line - A line to be parsed. true if the line is a comment and should be ignored, or false if itshould be parsed. |
|
|