Interface Parseable


public interface Parseable

Interface for objects which support parsing from and output to a character stream. Although Java provides no way to specify it, all objects implementing this interface must provide a method with one or both of the following exact signatures:

public static Parseable loadYourself(TokenStream s) throws IOException;
public static Parseable loadYourself(Reader r) throws IOException;

These methods support input from a Reader object or, if the implementer prefers, a TokenStream object. TokenStream is not specified here and must be provided by the implementer, but the intention is that it should translate a raw character input stream into a sequence of tokens, provide a pushback facility, etc.

Note: This interface provides a printLastMove(java.io.Writer) method that is specific to the PuzzleMuncher project. To use this code elsewhere, please remove that method from this interface. Its inclusion here is something of a sub-optimal design choice...


Method Summary
 void printLastMove(java.io.Writer w)
          Print a formatted representation of a move (action) to an output stream.
 void printYourself(java.io.Writer w)
          Print a formatted representation of the current object to an output stream.
 

Method Detail

printYourself

public void printYourself(java.io.Writer w)
                   throws java.io.IOException
Print a formatted representation of the current object to an output stream. The output format should be a human-readable form, ideally corresponding to the input format defined by the loadYourself() method(s).

Parameters:
w - Output stream onto which the object will be formatted.
Throws:
java.io.IOException - In case of an error while writing to the output stream.

printLastMove

public void printLastMove(java.io.Writer w)
                   throws java.io.IOException
Print a formatted representation of a move (action) to an output stream. The move printed is the move that generated the current state; for the START state (or any other state posessing no PREDECESSOR state), this should return without printing anything. The output should be a human-readable form.

Note: This method is specific to the PuzzleMuncher project and to PuzState objects in particular. If you wish to apply the Parseable interface to other applications, please remove this method from the interface.

Parameters:
w - Output stream onto which the object will be formatted.
Throws:
java.io.IOException - if an error occurs