de.saar.chorus.domgraph.codec
Class InputCodec

Object
  extended by InputCodec
Direct Known Subclasses:
Chain, DomconOzInputCodec, DomgraphGxlInputCodec, GlueInputCodec, HolesemComsemInputCodec, MrsPrologInputCodec, MrsXmlInputCodec

public abstract class InputCodec
extends Object

The abstract base class for all input codecs. Derived classes should implement the method decode and set the codec's name and extension in the constructor.

Author:
Alexander Koller

Constructor Summary
InputCodec()
           
 
Method Summary
abstract  void decode(Reader reader, DomGraph graph, NodeLabels labels)
          Reads an USR representation from a Reader.
 Reader getReaderForSpecification(String spec)
          Determines a Reader from which the USR specified by the spec will be read.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputCodec

public InputCodec()
Method Detail

decode

public abstract void decode(Reader reader,
                            DomGraph graph,
                            NodeLabels labels)
                     throws IOException,
                            ParserException,
                            MalformedDomgraphException
Reads an USR representation from a Reader. This method converts the USR into an equivalent labelled dominance graph and stores this graph in a DomGraph and the labels in a NodeLabels object. You must implement this method in every concrete input codec.

The graph and labels objects passed to this method need not be empty; it is the responsibility of this method to clear them first.

Parameters:
reader - the reader from which the USR is read
graph - the dominance graph into which the USR is converted
labels - the node labels of the labelled dominance graph
Throws:
IOException - if an I/O error occurred while reading from reader
ParserException - if a syntactic error occurred while parsing the USR
MalformedDomgraphException - if a semantic error occurred, i.e. the USR cannot be converted into a dominance graph

getReaderForSpecification

public Reader getReaderForSpecification(String spec)
                                 throws IOException
Determines a Reader from which the USR specified by the spec will be read. In this default implementation, spec is a filename, and the reader will be a FileReader for this file. You may override this method with your own implementation; the spec that is passed to your method will then be what the user specified in the command-line call "utool solve -I yourcodec <spec>". See the Chain for an example.

Parameters:
spec - a filename
Returns:
a reader for reading from this file
Throws:
IOException - no file with the given name exists