org.ahmadsoft.ropes.impl
Class FlatCharSequenceRope

java.lang.Object
  extended by org.ahmadsoft.ropes.impl.AbstractRope
      extended by org.ahmadsoft.ropes.impl.FlatCharSequenceRope
All Implemented Interfaces:
java.io.Serializable, java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>, java.lang.Iterable<java.lang.Character>, Rope

public final class FlatCharSequenceRope
extends AbstractRope

A rope constructed from an underlying character sequence.

Author:
Amin Ahmad
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.ahmadsoft.ropes.Rope
BUILDER
 
Constructor Summary
FlatCharSequenceRope(java.lang.CharSequence sequence)
          Constructs a new rope from an underlying character sequence.
 
Method Summary
 char charAt(int index)
           
 byte depth()
           
 java.util.Iterator<java.lang.Character> iterator(int start)
          Returns an iterator positioned to start at the specified index.
 int length()
           
 java.util.regex.Matcher matcher(java.util.regex.Pattern pattern)
          Creates a matcher that will match this rope against the specified pattern.
 Rope reverse()
          Reverses this rope.
 java.util.Iterator<java.lang.Character> reverseIterator(int start)
          Returns a reverse iterator positioned to start at the specified index.
 Rope subSequence(int start, int end)
           
 java.lang.String toString()
           
 java.lang.String toString(int offset, int length)
          Returns a String representation of a range in this rope.
 void write(java.io.Writer out)
          Write this rope to a Writer.
 void write(java.io.Writer out, int offset, int length)
          Write a range of this rope to a Writer.
 
Methods inherited from class org.ahmadsoft.ropes.impl.AbstractRope
append, append, append, compareTo, delete, endsWith, endsWith, equals, hashCode, indexOf, indexOf, indexOf, indexOf, insert, isEmpty, iterator, matches, matches, padEnd, padEnd, padStart, padStart, rebalance, reverseIterator, startsWith, startsWith, trim, trimEnd, trimStart, writeReplace
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ahmadsoft.ropes.Rope
append, append, append, delete, endsWith, endsWith, indexOf, indexOf, indexOf, indexOf, insert, isEmpty, matches, matches, padEnd, padEnd, padStart, padStart, rebalance, reverseIterator, startsWith, startsWith, trim, trimEnd, trimStart
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

FlatCharSequenceRope

public FlatCharSequenceRope(java.lang.CharSequence sequence)
Constructs a new rope from an underlying character sequence.

Parameters:
sequence -
Method Detail

charAt

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

depth

public byte depth()
Specified by:
depth in class AbstractRope

iterator

public java.util.Iterator<java.lang.Character> iterator(int start)
Description copied from interface: Rope
Returns an iterator positioned to start at the specified index.

Specified by:
iterator in interface Rope
Parameters:
start - the start position.
Returns:
an iterator positioned to start at the specified index.

length

public int length()
Specified by:
length in interface java.lang.CharSequence

matcher

public java.util.regex.Matcher matcher(java.util.regex.Pattern pattern)
Description copied from interface: Rope
Creates a matcher that will match this rope against the specified pattern. This method produces a higher performance matcher than:
 Matcher m = pattern.matcher(this);
 
The difference may be asymptotically better in some cases.

Specified by:
matcher in interface Rope
Overrides:
matcher in class AbstractRope
Parameters:
pattern - the pattern to match this rope against.
Returns:
a matcher.

reverse

public Rope reverse()
Description copied from interface: Rope
Reverses this rope.

Specified by:
reverse in interface Rope
Returns:
a reversed copy of this rope.

reverseIterator

public java.util.Iterator<java.lang.Character> reverseIterator(int start)
Description copied from interface: Rope
Returns a reverse iterator positioned to start at the specified index. A reverse iterator moves backwards instead of forwards through a rope.

Specified by:
reverseIterator in interface Rope
Parameters:
start - the start position.
Returns:
a reverse iterator positioned to start at the specified index from the end of the rope. For example, a value of 1 indicates the iterator should start 1 character before the end of the rope.
See Also:
Rope.reverseIterator()

subSequence

public Rope subSequence(int start,
                        int end)
Specified by:
subSequence in interface java.lang.CharSequence
Specified by:
subSequence in interface Rope

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class AbstractRope

toString

public java.lang.String toString(int offset,
                                 int length)
Returns a String representation of a range in this rope.

Parameters:
offset - the offset.
length - the length.
Returns:
a String representation of a range in this rope.

write

public void write(java.io.Writer out)
           throws java.io.IOException
Description copied from interface: Rope
Write this rope to a Writer.

Specified by:
write in interface Rope
Parameters:
out - the writer object.
Throws:
java.io.IOException

write

public void write(java.io.Writer out,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from interface: Rope
Write a range of this rope to a Writer.

Specified by:
write in interface Rope
Parameters:
out - the writer object.
offset - the range offset.
length - the range length.
Throws:
java.io.IOException


Copyright © 2007 Amin Ahmad. All Rights Reserved.