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.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>, java.lang.Iterable<java.lang.Character>, Rope

public class ConcatenationRope
extends AbstractRope

A rope that represents the concatenation of two other ropes.

Author:
Amin Ahmad

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()
           
 Rope getLeft()
          Return the left-hand rope.
 java.lang.CharSequence getRegexpCharSeq(Rope 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()
           
 java.util.regex.Matcher matcher(java.util.regex.Pattern pattern)
          Creates a matcher that will match this rope against the specified pattern.
 Rope rebalance()
          Rebalances the current rope, returning the rebalanced rope.
 Rope subSequence(int start, int end)
           
 void write(java.io.Writer out)
          Write this rope.
 void write(java.io.Writer out, int offset, int length)
          Write this rope.
 
Methods inherited from class org.ahmadsoft.ropes.impl.AbstractRope
append, append, append, compareTo, delete, equals, hashCode, indexOf, insert, iterator, toString
 
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

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

subSequence

public Rope subSequence(int start,
                        int end)

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.

Returns:
a rebalanced rope.

write

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

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 this rope.

Throws:
java.io.IOException

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 many cases.

Parameters:
pattern - the pattern to match this rope against.
Returns:
a matcher.

getRegexpCharSeq

public java.lang.CharSequence getRegexpCharSeq(Rope rope)