net.sf.japaki.text
Class WriterWithPosition

java.lang.Object
  extended by net.sf.japaki.text.ParseWriter
      extended by net.sf.japaki.text.WriterWithPosition
All Implemented Interfaces:
Closeable, Flushable, Appendable, RestorableIO<ParseWriter>, PathTracker

public class WriterWithPosition
extends ParseWriter
implements Flushable

The default implementation for a ParseWriter.


Constructor Summary
WriterWithPosition(String fileName)
          Creates a new WriterWithPosition based on the specified file.
WriterWithPosition(Writer writer)
          Creates a new WriterWithPosition based on the specified writer.
 
Method Summary
 Appendable append(char c)
           
 Appendable append(CharSequence scq)
           
 Appendable append(CharSequence scq, int start, int end)
           
 void close()
           
 void copyFrom(ParseWriter source)
          Copies all values from the source object After the copy, this object behaves like the source.
 ParseWriter deepCopy()
          Provides a deep copy of this object.
 void flush()
           
 Deque<Parser> getPath()
          Returns the path of parsers in the parser network.
 Writer getWriter()
          Returns the underlying writer.
 void newLine()
          Inserts a line break in the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriterWithPosition

public WriterWithPosition(Writer writer)
Creates a new WriterWithPosition based on the specified writer.

Parameters:
writer - base writer
Throws:
NullPointerException - if writer is null

WriterWithPosition

public WriterWithPosition(String fileName)
                   throws IOException
Creates a new WriterWithPosition based on the specified file.

Parameters:
fileName - name of the output file
Throws:
IOException - see FileWriter.FileWriter(String)
Method Detail

getWriter

public Writer getWriter()
Returns the underlying writer.

Returns:
the underlying writer

newLine

public void newLine()
             throws IOException
Description copied from class: ParseWriter
Inserts a line break in the output stream.

Specified by:
newLine in class ParseWriter
Throws:
IOException - if an I/O error occurs

getPath

public Deque<Parser> getPath()
Description copied from interface: PathTracker
Returns the path of parsers in the parser network.

Specified by:
getPath in interface PathTracker
Returns:
the path of parsers in the parser network.

deepCopy

public ParseWriter deepCopy()
Description copied from interface: RestorableIO
Provides a deep copy of this object.

Specified by:
deepCopy in interface RestorableIO<ParseWriter>
Returns:
a deep copy of this object

copyFrom

public void copyFrom(ParseWriter source)
              throws IOException
Description copied from interface: RestorableIO
Copies all values from the source object After the copy, this object behaves like the source.

Specified by:
copyFrom in interface RestorableIO<ParseWriter>
Parameters:
source - the source instance. Compatibility depends on the implementing class. In the standard case it should be the result of a prior call to RestorableIO.deepCopy().
Throws:
IOException - if an I/O error occurs

append

public Appendable append(CharSequence scq)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Appendable append(CharSequence scq,
                         int start,
                         int end)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Appendable append(char c)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Throws:
IOException