de.saar.chorus.domgraph.codec.term
Class TermOutputCodec

Object
  extended by OutputCodec
      extended by MultiOutputCodec
          extended by TermOutputCodec
Direct Known Subclasses:
OzTermOutputCodec, PrologTermOutputCodec

public class TermOutputCodec
extends MultiOutputCodec

A generic output codec for terms. This codec assumes that the graph that is to be output is

That is, the graph must be a forest, and a node has an outgoing dominance edge iff it is a hole (and exactly one dominance edge in this case). Such solved forms can be output as terms; this is what this codec does.

This codec can be used to compute terms both in Oz and in Prolog syntax. The difference between these two concrete syntaxes is that Prolog inserts a comma between subterms, whereas Oz uses whitespace for the same purpose.

Author:
Alexander Koller

Field Summary
static int ERROR_NOT_SIMPLE_SOLVED_FORM
           
 
Constructor Summary
TermOutputCodec(String separator)
          Construct a new term output codec with the given subterm separator (e.g.
 
Method Summary
 void encode(DomGraph graph, NodeLabels labels, Writer writer)
          Encodes a dominance graph into a string representation for this output codec.
 void print_end_list(Writer writer)
          Prints the end of a list in the concrete syntax which the USR uses.
 void print_footer(Writer writer)
          Prints a footer at the end of a file to which the USR is written.
 void print_header(Writer writer)
          Prints a header at the beginning of a file to which the USR is written.
 void print_list_separator(Writer writer)
          Prints the separator for separating different items of a list in the concrete syntax which the USR uses.
 void print_start_list(Writer writer)
          Prints the beginning of a list in the concrete syntax which the USR uses.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_NOT_SIMPLE_SOLVED_FORM

public static final int ERROR_NOT_SIMPLE_SOLVED_FORM
See Also:
Constant Field Values
Constructor Detail

TermOutputCodec

public TermOutputCodec(String separator)
Construct a new term output codec with the given subterm separator (e.g. "," for Prolog, " " for Oz).

Parameters:
separator - the subterm separator
Method Detail

encode

public void encode(DomGraph graph,
                   NodeLabels labels,
                   Writer writer)
            throws IOException,
                   MalformedDomgraphException
Description copied from class: OutputCodec
Encodes a dominance graph into a string representation for this output codec. The dominance graph is defined by the arguments graph and labels. The USR is written to the writer.

Specified by:
encode in class OutputCodec
Parameters:
graph - the dominance graph
labels - the node labels for this dominance graph
writer - the writer to which the encoded USR will be written
Throws:
IOException - if an I/O error occurred while writing to the writer
MalformedDomgraphException - if the graph cannot be encoded by this codec

print_header

public void print_header(Writer writer)
Description copied from class: OutputCodec
Prints a header at the beginning of a file to which the USR is written.

Specified by:
print_header in class OutputCodec
Parameters:
writer - the writer

print_footer

public void print_footer(Writer writer)
Description copied from class: OutputCodec
Prints a footer at the end of a file to which the USR is written.

Specified by:
print_footer in class OutputCodec
Parameters:
writer - the writer

print_start_list

public void print_start_list(Writer writer)
                      throws IOException
Description copied from class: MultiOutputCodec
Prints the beginning of a list in the concrete syntax which the USR uses. This method is called after print_header, but before any of the USRs. It is only called if we print more than one graph (e.g. in the solve command, but not the convert command).

Specified by:
print_start_list in class MultiOutputCodec
Parameters:
writer - the writer
Throws:
IOException - if an I/O error occurred

print_end_list

public void print_end_list(Writer writer)
                    throws IOException
Description copied from class: MultiOutputCodec
Prints the end of a list in the concrete syntax which the USR uses. This method is called before print_footer, but after any of the USRs. It is only called if we print more than one graph (e.g. in the solve command, but not the convert command).

Specified by:
print_end_list in class MultiOutputCodec
Parameters:
writer - the writer
Throws:
IOException - if an I/O error occurred

print_list_separator

public void print_list_separator(Writer writer)
                          throws IOException
Description copied from class: MultiOutputCodec
Prints the separator for separating different items of a list in the concrete syntax which the USR uses.

Specified by:
print_list_separator in class MultiOutputCodec
Parameters:
writer - the writer
Throws:
IOException - if an I/O error occurred