infovis.io
Class AbstractReader

java.lang.Object
  extended by infovis.io.AbstractReader
Direct Known Subclasses:
AbstractTableReader, AbstractXMLReader

public abstract class AbstractReader
extends Object

Base class for all the readers.

Version:
$Revision: 1.23 $
Author:
Jean-Daniel Fekete

Constructor Summary
AbstractReader(InputStream in, String name)
          Constructor for AbstractReader.
 
Method Summary
 void close()
          Closes the reader.
static Column createColumn(String type, String label)
          Creates a column of the specified type and name.
 BufferedReader getBufferedReader()
          Returns a BufferedReader associated with this stream, creating it if it does not exist yet.
 String getEncoding()
          Returns the default encoding of this reader.
 InputStream getIn()
          Returns the input InputStream.
 String getName()
          Returns the resource name.
static String guessFieldType(String field)
          Guess the field class from a value.
abstract  boolean load()
          Main method for loading the file.
 void setEncoding(String encoding)
          Sets the default encoding of this reader.
 void setIn(InputStream in)
          Sets the InputStream.
 void setName(String name)
          Sets the name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractReader

public AbstractReader(InputStream in,
                      String name)
Constructor for AbstractReader.

Parameters:
in - the InputStream for input.
name - the resource name.
Method Detail

getIn

public InputStream getIn()
Returns the input InputStream.

Returns:
the input InputStream.

getName

public String getName()
Returns the resource name.

Returns:
the resource name.

setIn

public void setIn(InputStream in)
Sets the InputStream.

Parameters:
in - the InputStream

close

public void close()
           throws IOException
Closes the reader.

Throws:
IOException - when the underlying stream does so

setName

public void setName(String name)
Sets the name.

Parameters:
name - The name to set

guessFieldType

public static String guessFieldType(String field)
Guess the field class from a value.

Parameters:
field - the value.
Returns:
A field class.

createColumn

public static Column createColumn(String type,
                                  String label)
Creates a column of the specified type and name.

Parameters:
type - the type name
label - the column name
Returns:
a column of the specified type and name

getBufferedReader

public BufferedReader getBufferedReader()
Returns a BufferedReader associated with this stream, creating it if it does not exist yet.

Returns:
a BufferedReader associated with this stream.

load

public abstract boolean load()
                      throws WrongFormatException
Main method for loading the file. The loading may fail at any point, leaving the table in an indefinite state if the methods returns false.

Returns:
true if the file has been loaded without error, false otherwise.
Throws:
WrongFormatException - if the format is not the one expected.

getEncoding

public String getEncoding()
Returns the default encoding of this reader.

Returns:
the default encoding of this reader

setEncoding

public void setEncoding(String encoding)
Sets the default encoding of this reader.

Parameters:
encoding - the default encoding of this reader.


Copyright 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.