org.geotoolkit.io
Class NumberedLineWriter

Object
  extended by Writer
      extended by FilterWriter
          extended by IndentedLineWriter
              extended by NumberedLineWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

@ThreadSafe
@Decorator(value=java.io.Writer.class)
public class NumberedLineWriter
extends IndentedLineWriter

A writer that put line number in front of every line.

Since:
2.1
Version:
3.00
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
utility/geotk-utility (download)    View source code for this class

Field Summary
 
Fields inherited from class FilterWriter
out
 
Fields inherited from class Writer
lock
 
Constructor Summary
NumberedLineWriter(Writer out)
          Constructs a stream which will write line number in front of each line.
 
Method Summary
protected  void beginNewLine()
          Invoked when a new line is beginning.
 int getLineNumber()
          Returns the current line number.
static PrintWriter getStandardOutput()
          Returns a default numbered line writer to the standard output stream.
 void setLineNumber(int line)
          Sets the current line number.
 String toString()
          Returns a string representation if this writer.
 
Methods inherited from class IndentedLineWriter
getIdentation, getMargin, setIndentation, setMargin, write, write, write
 
Methods inherited from class FilterWriter
close, flush
 
Methods inherited from class Writer
append, append, append, write, write
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberedLineWriter

public NumberedLineWriter(Writer out)
Constructs a stream which will write line number in front of each line.

Parameters:
out - The underlying stream to write to.
Method Detail

getStandardOutput

public static PrintWriter getStandardOutput()
Returns a default numbered line writer to the standard output stream. The FilterWriter.close() method on this stream will only flush it without closing it.

Returns:
A unique numbered line writer to the standard output stream.

getLineNumber

public int getLineNumber()
Returns the current line number.

Returns:
The current line number.

setLineNumber

public void setLineNumber(int line)
Sets the current line number.

Parameters:
line - The current line number.

beginNewLine

protected void beginNewLine()
                     throws IOException
Invoked when a new line is beginning. The default implementation writes the current line number.

Overrides:
beginNewLine in class IndentedLineWriter
Throws:
IOException - If an I/O error occurs

toString

public String toString()
Returns a string representation if this writer.

Overrides:
toString in class Object


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.