org.ahmadsoft.ropes.impl
Class ConcatenationRope

java.lang.Object
  extended by org.ahmadsoft.ropes.impl.AbstractRope
      extended by org.ahmadsoft.ropes.impl.ConcatenationRope
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 ConcatenationRope
extends AbstractRope

A rope that represents the concatenation of two other ropes.

Author:
Amin Ahmad
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.ahmadsoft.ropes.Rope
BUILDER
 
Constructor Summary
ConcatenationRope(Rope left, Rope right)
          Create a new concatenation rope from two ropes.
 
Method Summary
 char charAt(int index)
           
 byte depth()
           
 java.lang.CharSequence getForSequentialAccess()
          A utility method that returns an instance of this rope optimized for sequential access.
 Rope getLeft()
          Return the left-hand rope.
 Rope getRight()
          Return the right-hand rope.
 java.util.Iterator<java.lang.Character> iterator(int start)
          Returns an iterator positioned to start at the specified index.
 int length()
           
 Rope rebalance()
          Rebalances the current rope, returning the rebalanced rope.
 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)
           
 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, reverseIterator, startsWith, startsWith, toString, trim, trimEnd, trimStart, writeReplace
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConcatenationRope

public ConcatenationRope(Rope left,
                         Rope right)
Create a new concatenation rope from two ropes.

Parameters:
left - the first rope.
right - the second rope.
Method Detail

charAt

public char charAt(int index)

depth

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

getForSequentialAccess

public java.lang.CharSequence getForSequentialAccess()
Description copied from class: AbstractRope
A utility method that returns an instance of this rope optimized for sequential access.

Returns:

getLeft

public Rope getLeft()
Return the left-hand rope.

Returns:
the left-hand rope.

getRight

public Rope getRight()
Return the right-hand rope.

Returns:
the right-hand rope.

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()

rebalance

public Rope rebalance()
Description copied from interface: Rope
Rebalances the current rope, returning the rebalanced rope. In general, rope rebalancing is handled automatically, but this method is provided to give users more control.

Specified by:
rebalance in interface Rope
Overrides:
rebalance in class AbstractRope
Returns:
a rebalanced rope.

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)

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.