org.sitemesh.tagprocessor.util
Class CharSequenceList

java.lang.Object
  extended by org.sitemesh.tagprocessor.util.CharSequenceList
All Implemented Interfaces:
Appendable, CharSequence, Iterable<CharSequence>, CharSequenceBuffer

public class CharSequenceList
extends Object
implements CharSequenceBuffer

An Appendable buffer of character data,similar to StringBuilder and StringBuffer), except rather than copying the contents to an array of characters, it keeps a list of references to the original CharSequences.

This offers a few advantages:

With these advantages, come some disadvantages:

Author:
Joe Walnes

Constructor Summary
CharSequenceList()
           
 
Method Summary
 Appendable append(char c)
          Warning: Each time this method is called, a new String of length 1 is constructed and added to a LinkedList - this is not optimal.
 Appendable append(CharSequence csq)
           
 Appendable append(CharSequence csq, int start, int end)
           
 char charAt(int index)
           
 Iterator<CharSequence> iterator()
           
 int length()
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 void writeTo(Appendable out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharSequenceList

public CharSequenceList()
Method Detail

append

public Appendable append(CharSequence csq)
Specified by:
append in interface Appendable

append

public Appendable append(CharSequence csq,
                         int start,
                         int end)
Specified by:
append in interface Appendable

append

public Appendable append(char c)
Warning: Each time this method is called, a new String of length 1 is constructed and added to a LinkedList - this is not optimal. If building up strings, it is more efficient to build these up externally in a StringBuilder, and then pass that to append(CharSequence).

Specified by:
append in interface Appendable

length

public int length()
Specified by:
length in interface CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

iterator

public Iterator<CharSequence> iterator()
Specified by:
iterator in interface Iterable<CharSequence>

toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

writeTo

public void writeTo(Appendable out)
             throws IOException
Specified by:
writeTo in interface CharSequenceBuffer
Throws:
IOException


Copyright © 2011. All Rights Reserved.