org.foray.common
Class CharSequenceSubset
java.lang.Object
org.foray.common.CharSequenceSubset
- All Implemented Interfaces:
- Serializable, CharSequence
public class CharSequenceSubset
- extends Object
- implements Serializable, CharSequence
A wrapper around another CharSequence, providing a view of a subset of that sequence.
Caveat: One of the weaknesses of CharSequence
interface is its lack of a method
indicating whether the instance is mutable or immutable.
This class tests dimensions at construction time, but if the wrapped CharSequence changes its
size, this class will have no way of knowing it.
- See Also:
- Serialized Form
CharSequenceSubset
public CharSequenceSubset(CharSequence wrappedSequence,
int start,
int length)
- Constructor.
- Parameters:
wrappedSequence
- The encapsulated sequence, a subset of which is the content for this
sequence.start
- The index to the first element in wrappedSequence
that is
considered to be part of this sequence.length
- The number of chars in wrappedSequence
that is considered to be
part of this sequence.
length
public int length()
- Specified by:
length
in interface CharSequence
toString
public String toString()
-
Overrides method in
Object
to properly conform to the CharSequence
interface.
- Specified by:
toString
in interface CharSequence
- Overrides:
toString
in class Object
subSequence
public CharSequence subSequence(int start,
int end)
- Specified by:
subSequence
in interface CharSequence
charAt
public char charAt(int index)
- Specified by:
charAt
in interface CharSequence
Copyright © 2017. All rights reserved.