org.samcrow.io
Class IOBase

java.lang.Object
  extended by org.samcrow.io.IOBase
Direct Known Subclasses:
BasicIO

public abstract class IOBase
extends java.lang.Object

Base class for writing maps to files and reading them from files.

Author:
Sam Crow

Field Summary
protected  java.io.File file
           
 
Constructor Summary
IOBase(java.io.File inFile)
          Constructor with a given File object
IOBase(java.lang.String inFilename)
          Constructor with a given file path
 
Method Summary
abstract  IOResponse read()
          Read the file; get the nodes and links defined in it.
This method is designed to be relatively robust.
abstract  void write(java.util.Collection<Node> nodes, java.util.Collection<Link> links)
          Writes to the file that this instance uses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected java.io.File file
Constructor Detail

IOBase

public IOBase(java.lang.String inFilename)
Constructor with a given file path

Parameters:
inFilename - the name or path of the file

IOBase

public IOBase(java.io.File inFile)
Constructor with a given File object

Parameters:
inFile - the File object
Method Detail

write

public abstract void write(java.util.Collection<Node> nodes,
                           java.util.Collection<Link> links)
Writes to the file that this instance uses

Parameters:
nodes - the nodes to write
links - the links to write

read

public abstract IOResponse read()
                         throws java.text.ParseException
Read the file; get the nodes and links defined in it.
This method is designed to be relatively robust. It will attempt to load data for every data entry that is encountered. It will ignore lines with malformed data. It will throw an exception only if an IOException is encountered. When attempting to read an empty file, it will simply return an IOResponse with empty Collections.

Returns:
IOResponse with the information in the file
Throws:
java.text.ParseException - if the file is invalid