org.xeril.xml
Class Indent

java.lang.Object
  |
  +--org.xeril.xml.Indent

public class Indent
extends java.lang.Object

This class encapsulates the notion of indentation. It maintains internally a 'level' of indentation that you should modify with inc or dec. You can also specify which characters will be used to display the indentation (most of the time it will be spaces).


Constructor Summary
Indent()
          Constructor.
Indent(int level)
          Constructor.
Indent(java.lang.String indent_string)
          Constructor.
Indent(java.lang.String indent_string, int level)
          Constructor.
 
Method Summary
 void dec()
          Decrements the level of indentation
 java.lang.String getIndentation()
          Returns the indentation depending on the level.
 java.lang.String getIndentString()
          Access function.
 int getLevel()
          Access function.
 void inc()
          Increments the level of indentation
static java.lang.String indentBlock(java.lang.String block, Indent indent)
          Indents a block of text.
 void setIndentString(java.lang.String indent_string)
          Access function.
 void setLevel(int level)
          Access function.
 java.lang.String toString()
          Convenient method : returns the indentation depending on the level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Indent

public Indent()
Constructor. Initializes the indentation to start at level 0 and to have a display of 2 spaces for each level.


Indent

public Indent(java.lang.String indent_string)
Constructor. Initializes with the specified string and a starting level of 0.

Parameters:
indent_string - the indentation representation

Indent

public Indent(int level)
Constructor. Initializes with the specified level and a 2 spaces string.

Parameters:
level - the level of indetation to start

Indent

public Indent(java.lang.String indent_string,
              int level)
Constructor. Initializes with provided values.

Parameters:
indent_string - the indentation representation
level - the level of indetation to start
Method Detail

getIndentString

public java.lang.String getIndentString()
Access function.

Returns:
the string representation of the indentation

setIndentString

public void setIndentString(java.lang.String indent_string)
Access function.

Parameters:
indent_string - the string representation of the indentation

getLevel

public int getLevel()
Access function.

Returns:
the indentation level

setLevel

public void setLevel(int level)
Access function. You should not use this method to modify the level of indentation but use inc or dec instead.

Parameters:
level - the indentation level

inc

public void inc()
Increments the level of indentation


dec

public void dec()
Decrements the level of indentation


getIndentation

public java.lang.String getIndentation()
Returns the indentation depending on the level.

Returns:
the indentation

toString

public java.lang.String toString()
Convenient method : returns the indentation depending on the level.

Overrides:
toString in class java.lang.Object
Returns:
the indentation

indentBlock

public static java.lang.String indentBlock(java.lang.String block,
                                           Indent indent)
Indents a block of text. You provide the block of text as a String and the indent object and it returns another String with each line properly indented.

Parameters:
block - the block of text to indent
indent - the indentation object to use
Returns:
the indented block