org.ahmadsoft.ropes.impl
Class SubstringRope

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

public class SubstringRope
extends AbstractRope

Represents a lazily-evaluated substring of another rope. For performance reasons, the target rope must be a FlatRope.

Author:
aahmad
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.ahmadsoft.ropes.Rope
BUILDER
 
Constructor Summary
SubstringRope(org.ahmadsoft.ropes.impl.FlatRope rope, int offset, int length)
           
 
Method Summary
 char charAt(int index)
           
 byte depth()
           
 Rope getRope()
          Returns the rope underlying this one.
 java.util.Iterator<java.lang.Character> iterator(int start)
          Returns an iterator positioned to start at the specified index.
 int length()
           
 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()
           
 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, matcher, 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
 

Constructor Detail

SubstringRope

public SubstringRope(org.ahmadsoft.ropes.impl.FlatRope rope,
                     int offset,
                     int length)
Method Detail

charAt

public char charAt(int index)

depth

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

getRope

public Rope getRope()
Returns the rope underlying this one.

Returns:
the rope underlying this one.

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.

Parameters:
start - the start position.
Returns:
an iterator positioned to start at the specified index.

length

public int length()

reverse

public Rope reverse()
Description copied from interface: Rope
Reverses this 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.

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)

toString

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

write

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

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.

Parameters:
out - the writer object.
offset - the range offset.
length - the range length.
Throws:
java.io.IOException


Copyright © 2007 Amin Ahmad. All Rights Reserved.