org.geotools.io
Class IndentedLineWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.FilterWriter
          extended by org.geotools.io.IndentedLineWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Direct Known Subclasses:
NumberedLineWriter

public class IndentedLineWriter
extends java.io.FilterWriter

A writer that put some spaces in front of every lines. The indentation is initially set to 0 spaces. Users must invoke setIndentation(int) in order to set a different value.

Since:
2.4
Version:
$Id: IndentedLineWriter.java 30640 2008-06-12 17:34:32Z acuster $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class java.io.FilterWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
IndentedLineWriter(java.io.Writer out)
          Constructs a stream which will add spaces in front of each line.
 
Method Summary
protected  void beginNewLine()
          Invoked when a new line is begining.
 int getIdentation()
          Returns the current indentation.
 void setIndentation(int width)
          Sets the indentation to the specified value.
 void write(char[] buffer, int offset, int length)
          Writes a portion of an array of characters.
 void write(int c)
          Writes a single character.
 void write(java.lang.String string, int offset, int length)
          Writes a portion of a string.
 
Methods inherited from class java.io.FilterWriter
close, flush
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndentedLineWriter

public IndentedLineWriter(java.io.Writer out)
Constructs a stream which will add spaces in front of each line.

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

getIdentation

public int getIdentation()
Returns the current indentation.

Returns:
The current indentation.

setIndentation

public void setIndentation(int width)
Sets the indentation to the specified value.

Parameters:
width - The new indentation.

beginNewLine

protected void beginNewLine()
                     throws java.io.IOException
Invoked when a new line is begining. The default implementation writes the amount of spaces specified by the last call to setIndentation(int).

Throws:
java.io.IOException - If an I/O error occurs

write

public void write(int c)
           throws java.io.IOException
Writes a single character.

Overrides:
write in class java.io.FilterWriter
Throws:
java.io.IOException - If an I/O error occurs.

write

public void write(char[] buffer,
                  int offset,
                  int length)
           throws java.io.IOException
Writes a portion of an array of characters.

Overrides:
write in class java.io.FilterWriter
Parameters:
buffer - Buffer of characters to be written.
offset - Offset from which to start reading characters.
length - Number of characters to be written.
Throws:
java.io.IOException - If an I/O error occurs.

write

public void write(java.lang.String string,
                  int offset,
                  int length)
           throws java.io.IOException
Writes a portion of a string.

Overrides:
write in class java.io.FilterWriter
Parameters:
string - String to be written.
offset - Offset from which to start reading characters.
length - Number of characters to be written.
Throws:
java.io.IOException - If an I/O error occurs.


Copyright © 1996-2010 Geotools. All Rights Reserved.