net.dpml.lang
Class Buffer

java.lang.Object
  extended by net.dpml.lang.Buffer

public final class Buffer
extends Object

Utility class used as a destination during generalized object encoding.

Version:
2.1.0
Author:
Digital Product Management Library

Constructor Summary
Buffer(Writer writer, String namespace, String pad)
          Construct a new encoding buffer.
 
Method Summary
 String getEnclosingNamespace()
          Get the current namespace.
 String getOffset()
          Get the space indent offset.
 Buffer indent()
          Indent the current offset value by 2 space characters.
 Buffer indent(String indent)
          Indent the current offset value by a supplied value.
 boolean isNamespace(String namespace)
          Test id the supplied namespace is the current namesapce.
 Buffer namespace(String namespace)
          Creation of a new buffer mapped to the supplied namespace.
 void nl(char[] array)
          Write an character array value to the buffer following a nl character.
 void nl(int n)
          Write an int value to the buffer following a nl character.
 void nl(String value)
          Write a value to the buffer following a nl character.
 void write(char[] array)
          Write an character array value to the buffer.
 void write(int n)
          Write an int value to the buffer.
 void write(String value)
          Write a value to the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Buffer

public Buffer(Writer writer,
              String namespace,
              String pad)
       throws NullPointerException
Construct a new encoding buffer.

Parameters:
writer - the output stream writer
namespace - the current namespace
pad - the current offset
Throws:
NullPointerException - of the writer or namespace arguments are null
Method Detail

getEnclosingNamespace

public String getEnclosingNamespace()
Get the current namespace.

Returns:
the namespace

getOffset

public String getOffset()
Get the space indent offset.

Returns:
the offset value

write

public void write(String value)
           throws IOException
Write a value to the buffer.

Parameters:
value - the value to write to the buffer
Throws:
IOException - if an IO error occurs

write

public void write(int n)
           throws IOException
Write an int value to the buffer.

Parameters:
n - the int value to write to the buffer
Throws:
IOException - if an IO error occurs

write

public void write(char[] array)
           throws IOException
Write an character array value to the buffer.

Parameters:
array - the array value to write to the buffer
Throws:
IOException - if an IO error occurs

nl

public void nl(String value)
        throws IOException
Write a value to the buffer following a nl character.

Parameters:
value - the value to write to the buffer
Throws:
IOException - if an IO error occurs

nl

public void nl(int n)
        throws IOException
Write an int value to the buffer following a nl character.

Parameters:
n - the int value to write to the buffer
Throws:
IOException - if an IO error occurs

nl

public void nl(char[] array)
        throws IOException
Write an character array value to the buffer following a nl character.

Parameters:
array - the array value to write to the buffer
Throws:
IOException - if an IO error occurs

indent

public Buffer indent()
Indent the current offset value by 2 space characters.

Returns:
a buffer

indent

public Buffer indent(String indent)
Indent the current offset value by a supplied value.

Parameters:
indent - the indent value
Returns:
a new buffer

isNamespace

public boolean isNamespace(String namespace)
Test id the supplied namespace is the current namesapce.

Parameters:
namespace - to namespace to compare with the current namespace
Returns:
true if the namesapce is current

namespace

public Buffer namespace(String namespace)
Creation of a new buffer mapped to the supplied namespace.

Parameters:
namespace - the namespace
Returns:
a buffer