org.milyn.delivery.sax
Class SAXText

java.lang.Object
  extended by org.milyn.delivery.sax.SAXText

public class SAXText
extends Object

SAX Text.

This class provides a wrapper around the char array supplied by the SAXParser/XMLReader. It help provide an optimization by allowing the process to avoid String construction where possible.

NOTE: References to instances of this type should not be cached. If you need to cache the character data housed in this class, you should use either the getText() or toString() methods.

Author:
tom.fennelly@gmail.com

Constructor Summary
protected SAXText()
           
  SAXText(char[] characters, int offset, int length, TextType type)
           
 
Method Summary
 String getText()
          Get the raw text, unwrapped.
 TextType getType()
          Get the text type (comment, cdata etc).
protected  void setText(char[] characters, int offset, int length, TextType type)
           
 String toString()
          Get the "wrapped" text as a String.
 void toWriter(Writer writer)
          Write the text to the supplied writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SAXText

protected SAXText()

SAXText

public SAXText(char[] characters,
               int offset,
               int length,
               TextType type)
Method Detail

setText

protected void setText(char[] characters,
                       int offset,
                       int length,
                       TextType type)

getText

public String getText()
Get the raw text, unwrapped.

This method differs from the toString() implementation because it doesn't wrap the test based on it's type.

Returns:
The raw (unwrapped) text.

getType

public TextType getType()
Get the text type (comment, cdata etc).

Returns:
The text type.

toString

public String toString()
Get the "wrapped" text as a String.

Wraps the underlying characters based on the text type. See getType().

Overrides:
toString in class Object
Returns:
The "wrapped" text String.

toWriter

public void toWriter(Writer writer)
              throws IOException
Write the text to the supplied writer.

It wraps the text based on its type.

Parameters:
writer - The writer.
Throws:
IOException - Write exception.


Copyright © 2008. All Rights Reserved.