J avolution v5.4 (J2SE 1.6+)

javolution.text
Class Text

java.lang.Object
  extended by javolution.text.Text
All Implemented Interfaces:
java.io.Serializable, java.lang.CharSequence, java.lang.Comparable, Immutable, Realtime, ValueType, XMLSerializable

public final class Text
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Comparable, XMLSerializable, ValueType, Realtime

This class represents an immutable character sequence with fast concatenation, insertion and deletion capabilities (O[Log(n)]) instead of O[n] for StringBuffer/StringBuilder).

This class has the same methods as Java String and .NET String with the following benefits:

Text literals should be explicitly interned. Unlike strings literals and strings-value constant expressions, interning is not implicit. For example:

         final static Text TRUE = Text.intern("true");
         final static Text FALSE = Text.intern("false");
     
Interned texts are always allocated in ImmortalMemory (RTSJ VMs).

Text instances can be printed out directly (no intermediate String allocated). For example:

           FastTable myTable ...;
           myTable.toText().println(); // Prints to System.out
     

Implementation Note: To avoid expensive copy operations , Text instances are broken down into smaller immutable sequences, they form a minimal-depth binary tree. The tree is maintained balanced automatically through tree rotations. Insertion/deletions are performed in O[Log(n)] instead of O[n] for StringBuffer/StringBuilder.

Version:
5.3, January 10, 2007
Author:
Jean-Marie Dautelle, Wilfried Middleton
See Also:
Serialized Form

Field Summary
static Text EMPTY
          Holds an empty character sequence.
 
Constructor Summary
Text(java.lang.String str)
          Creates a text holding the characters from the specified String .
 
Method Summary
 char charAt(int index)
          Returns the character at the specified index.
 int compareTo(java.lang.Object csq)
          Compares this text to another character sequence or string lexicographically.
 Text concat(Text that)
          Concatenates the specified text to the end of this text.
 boolean contentEquals(java.lang.CharSequence csq)
          Indicates if this text has the same character content as the specified character sequence.
 boolean contentEqualsIgnoreCase(java.lang.CharSequence csq)
          Indicates if this text has the same character contend as the specified character sequence ignoring case considerations.
 Text copy()
          Returns a deep copy of this object allocated in the memory area (RTSJ) and/or context (Javolution) of the calling thread (the one making the copy).
 Text delete(int start, int end)
          Returns the text without the characters between the specified indexes.
 boolean endsWith(java.lang.CharSequence suffix)
          Indicates if this text ends with the specified suffix.
 boolean equals(java.lang.Object obj)
          Compares this text against the specified object for equality.
 void getChars(int start, int end, char[] dest, int destPos)
          Copies the characters from this text into the destination character array.
 int hashCode()
          Returns the hash code for this text.
 int indexOf(char c)
          Returns the index within this text of the first occurrence of the specified character, starting the search at the beginning.
 int indexOf(char c, int fromIndex)
          Returns the index within this text of the first occurrence of the specified character, starting the search at the specified index.
 int indexOf(java.lang.CharSequence csq)
          Returns the index within this text of the first occurrence of the specified character sequence searching forward.
 int indexOf(java.lang.CharSequence csq, int fromIndex)
          Returns the index within this text of the first occurrence of the specified characters sequence searching forward from the specified index.
 int indexOfAny(CharSet charSet)
          Returns the index within this text of the first occurrence of any character in the specified character set.
 int indexOfAny(CharSet charSet, int start)
          Returns the index within a region of this text of the first occurrence of any character in the specified character set.
 int indexOfAny(CharSet charSet, int start, int length)
          Returns the index within a region of this text of the first occurrence of any character in the specified character set.
 Text insert(int index, Text txt)
          Returns the text having the specified text inserted at the specified location.
static Text intern(java.lang.CharSequence csq)
          Returns a text equals to the specified character sequence from a pool of unique text instances in ImmortalMemory.
static Text intern(java.lang.String str)
          Returns a text equals to the specified string from a pool of unique text instances in ImmortalMemory.
 boolean isBlank()
          Indicates if all characters of this text are whitespaces (no characters greater than the space character).
 boolean isBlank(int start, int length)
          Indicates if the specified sub-range of characters of this text are whitespaces (no characters greater than the space character).
 int lastIndexOf(char c, int fromIndex)
          Returns the index within this text of the first occurrence of the specified character, searching backward and starting at the specified index.
 int lastIndexOf(java.lang.CharSequence csq)
          Returns the index within this text of the last occurrence of the specified characters sequence searching backward.
 int lastIndexOf(java.lang.CharSequence csq, int fromIndex)
          Returns the index within this text of the last occurrence of the specified character sequence searching backward from the specified index.
 int lastIndexOfAny(CharSet charSet)
          Returns the index within this text of the last occurrence of any character in the specified character set.
 int lastIndexOfAny(CharSet charSet, int start)
          Returns the index within a region of this text of the last occurrence of any character in the specified character set.
 int lastIndexOfAny(CharSet charSet, int start, int length)
          Returns the index within a region of this text of the last occurrence of any character in the specified character set.
 int length()
          Returns the length of this text.
 Text padLeft(int len)
          Pads this text on the left with spaces to make the minimum total length as specified.
 Text padLeft(int len, char c)
          Pads this text on the left to make the minimum total length as specified.
 Text padRight(int len)
          Pads this text on the right with spaces to make the minimum total length as specified.
 Text padRight(int len, char c)
          Pads this text on the right to make the minimum total length as specified.
 Text plus(java.lang.Object obj)
          Returns the concatenation of this text and the textual representation of the specified object.
 Text plus(java.lang.String str)
          Returns the concatenation of this text and the specified String (optimization).
 void print()
          Prints out this text to System.out (UTF-8 encoding).
 void print(java.io.Writer writer)
          Prints out this text to the specified writer.
 void println()
          Prints out this text to System.out and then terminates the line.
 void println(java.io.Writer writer)
          Prints out this text to the specified writer and then terminates the line.
 void printStatistics(java.io.PrintStream out)
          Prints the current statistics on this text tree structure.
 Text replace(java.lang.CharSequence target, java.lang.CharSequence replacement)
          Replaces each character sequence of this text that matches the specified target sequence with the specified replacement sequence.
 Text replace(CharSet charSet, java.lang.CharSequence replacement)
          Replaces the specified characters in this text with the specified replacement sequence.
 boolean startsWith(java.lang.CharSequence prefix)
          Indicates if this text starts with the specified prefix.
 boolean startsWith(java.lang.CharSequence prefix, int index)
          Indicates if this text starts with the specified prefix at the specified index.
 java.lang.CharSequence subSequence(int start, int end)
          Returns subtext(start, end).
 Text subtext(int start)
          Returns a portion of this text.
 Text subtext(int start, int end)
          Returns a portion of this text.
 Text toLowerCase()
          Converts the characters of this text to lower case.
 java.lang.String toString()
          Returns the String representation of this text.
 Text toText()
          Returns this (implements Realtime interface).
 Text toUpperCase()
          Converts the characters of this text to upper case.
 Text trim()
          Returns a copy of this text, with leading and trailing whitespace omitted.
 Text trimEnd()
          Returns a copy of this text, with trailing whitespace omitted.
 Text trimStart()
          Returns a copy of this text, with leading whitespace omitted.
static Text valueOf(boolean b)
          Returns the text representation of the boolean argument.
static Text valueOf(char c)
          Returns the text instance corresponding to the specified character.
static Text valueOf(char[] chars)
          Returns the text that contains the characters from the specified array.
static Text valueOf(char[] chars, int offset, int length)
          Returns the text that contains the characters from the specified subarray of characters.
static Text valueOf(char c, int length)
          Returns the text that contains a specific length sequence of the character specified.
static Text valueOf(double d)
          Returns the textual representation of the specified double argument.
static Text valueOf(double d, int digits, boolean scientific, boolean showZero)
          Returns the textual representation of the specified double argument formatted as specified.
static Text valueOf(float f)
          Returns the textual representation of the specified float instance.
static Text valueOf(int i)
          Returns the decimal representation of the specified int argument.
static Text valueOf(int i, int radix)
          Returns the radix representation of the specified int argument.
static Text valueOf(long l)
          Returns the decimal representation of the specified long argument.
static Text valueOf(long l, int radix)
          Returns the radix representation of the specified long argument.
static Text valueOf(java.lang.Object obj)
          Returns the text representing the specified object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final Text EMPTY
Holds an empty character sequence.

Constructor Detail

Text

public Text(java.lang.String str)
Creates a text holding the characters from the specified String .

Parameters:
str - the string holding the character content.
Method Detail

valueOf

public static Text valueOf(java.lang.Object obj)
Returns the text representing the specified object. If the object is an instance of Realtime then Realtime.toText() is returned.

Parameters:
obj - the object to represent as text.
Returns:
the textual representation of the specified object.

valueOf

public static Text valueOf(char[] chars)
Returns the text that contains the characters from the specified array.

Parameters:
chars - the array source of the characters.
Returns:
the corresponding instance.

valueOf

public static Text valueOf(char[] chars,
                           int offset,
                           int length)
Returns the text that contains the characters from the specified subarray of characters.

Parameters:
chars - the source of the characters.
offset - the index of the first character in the data soure.
length - the length of the text returned.
Returns:
the corresponding instance.
Throws:
java.lang.IndexOutOfBoundsException - if (offset < 0) || (length < 0) || ((offset + length) > chars.length)

valueOf

public static Text valueOf(boolean b)
Returns the text representation of the boolean argument.

Parameters:
b - a boolean.
Returns:
if the argument is true, the text "true" is returned; otherwise, the text "false" is returned.

valueOf

public static Text valueOf(char c)
Returns the text instance corresponding to the specified character.

Parameters:
c - a character.
Returns:
a text of length 1 containing 'c'.

valueOf

public static Text valueOf(int i)
Returns the decimal representation of the specified int argument.

Parameters:
i - the int to format.
Returns:
the corresponding text instance.

valueOf

public static Text valueOf(int i,
                           int radix)
Returns the radix representation of the specified int argument.

Parameters:
i - the int to format.
radix - the radix (e.g. 16 for hexadecimal).
Returns:
the corresponding text instance.

valueOf

public static Text valueOf(long l)
Returns the decimal representation of the specified long argument.

Parameters:
l - the long to format.
Returns:
the corresponding text instance.

valueOf

public static Text valueOf(long l,
                           int radix)
Returns the radix representation of the specified long argument.

Parameters:
l - the long to format.
radix - the radix (e.g. 16 for hexadecimal).
Returns:
the corresponding text instance.

valueOf

public static Text valueOf(float f)
Returns the textual representation of the specified float instance.

Parameters:
f - the float to format.
Returns:
the corresponding text instance.

valueOf

public static Text valueOf(double d)
Returns the textual representation of the specified double argument.

Parameters:
d - the double to format.
Returns:
the corresponding text instance.

valueOf

public static Text valueOf(double d,
                           int digits,
                           boolean scientific,
                           boolean showZero)
Returns the textual representation of the specified double argument formatted as specified.

Parameters:
d - the double to format.
digits - the number of significative digits (excludes exponent) or -1 to mimic the standard library (16 or 17 digits).
scientific - true to forces the use of the scientific notation (e.g. 1.23E3); false otherwise.
showZero - true if trailing fractional zeros are represented; false otherwise.
Returns:
the corresponding text instance.
Throws:
java.lang.IllegalArgumentException - if (digits > 19))

length

public int length()
Returns the length of this text.

Specified by:
length in interface java.lang.CharSequence
Returns:
the number of characters (16-bits Unicode) composing this text.

plus

public Text plus(java.lang.Object obj)
Returns the concatenation of this text and the textual representation of the specified object.

Parameters:
obj - the object whose textual representation is concatenated.
Returns:
this.concat(Text.valueOf(obj))

plus

public Text plus(java.lang.String str)
Returns the concatenation of this text and the specified String (optimization).

Parameters:
str - the string whose characters are concatenated.
Returns:
this.concat(Text.valueOf(obj))

concat

public Text concat(Text that)
Concatenates the specified text to the end of this text. This method is very fast (faster even than StringBuffer.append(String)) and still returns a text instance with an internal binary tree of minimal depth!

Parameters:
that - the text that is concatenated.
Returns:
this + that

subtext

public Text subtext(int start)
Returns a portion of this text.

Parameters:
start - the index of the first character inclusive.
Returns:
the sub-text starting at the specified position.
Throws:
java.lang.IndexOutOfBoundsException - if (start < 0) || (start > this.length())

insert

public Text insert(int index,
                   Text txt)
Returns the text having the specified text inserted at the specified location.

Parameters:
index - the insertion position.
txt - the text being inserted.
Returns:
subtext(0, index).concat(txt).concat(subtext(index))
Throws:
java.lang.IndexOutOfBoundsException - if (index < 0) || (index > this.length())

delete

public Text delete(int start,
                   int end)
Returns the text without the characters between the specified indexes.

Parameters:
start - the beginning index, inclusive.
end - the ending index, exclusive.
Returns:
subtext(0, start).concat(subtext(end))
Throws:
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length()

replace

public Text replace(java.lang.CharSequence target,
                    java.lang.CharSequence replacement)
Replaces each character sequence of this text that matches the specified target sequence with the specified replacement sequence.

Parameters:
target - the character sequence to be replaced.
replacement - the replacement sequence.
Returns:
the resulting text.

replace

public Text replace(CharSet charSet,
                    java.lang.CharSequence replacement)
Replaces the specified characters in this text with the specified replacement sequence.

Parameters:
charSet - the set of characters to be replaced.
replacement - the replacement sequence.
Returns:
the resulting text.

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Returns subtext(start, end).

Specified by:
subSequence in interface java.lang.CharSequence
Parameters:
start - the index of the first character inclusive.
end - the index of the last character exclusive.
Returns:
this.subtext(start, end)
Throws:
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())

indexOf

public int indexOf(java.lang.CharSequence csq)
Returns the index within this text of the first occurrence of the specified character sequence searching forward.

Parameters:
csq - a character sequence.
Returns:
the index of the first character of the character sequence found; or -1 if the character sequence is not found.

indexOf

public int indexOf(java.lang.CharSequence csq,
                   int fromIndex)
Returns the index within this text of the first occurrence of the specified characters sequence searching forward from the specified index.

Parameters:
csq - a character sequence.
fromIndex - the index to start the search from.
Returns:
the index in the range [fromIndex, length() - csq.length()] or -1 if the character sequence is not found.

lastIndexOf

public int lastIndexOf(java.lang.CharSequence csq)
Returns the index within this text of the last occurrence of the specified characters sequence searching backward.

Parameters:
csq - a character sequence.
Returns:
the index of the first character of the character sequence found; or -1 if the character sequence is not found.

lastIndexOf

public int lastIndexOf(java.lang.CharSequence csq,
                       int fromIndex)
Returns the index within this text of the last occurrence of the specified character sequence searching backward from the specified index.

Parameters:
csq - a character sequence.
fromIndex - the index to start the backward search from.
Returns:
the index in the range [0, fromIndex] or -1 if the character sequence is not found.

startsWith

public boolean startsWith(java.lang.CharSequence prefix)
Indicates if this text starts with the specified prefix.

Parameters:
prefix - the prefix.
Returns:
true if the character sequence represented by the argument is a prefix of the character sequence represented by this text; false otherwise.

endsWith

public boolean endsWith(java.lang.CharSequence suffix)
Indicates if this text ends with the specified suffix.

Parameters:
suffix - the suffix.
Returns:
true if the character sequence represented by the argument is a suffix of the character sequence represented by this text; false otherwise.

startsWith

public boolean startsWith(java.lang.CharSequence prefix,
                          int index)
Indicates if this text starts with the specified prefix at the specified index.

Parameters:
prefix - the prefix.
index - the index of the prefix location in this string.
Returns:
this.substring(index).startsWith(prefix)

trim

public Text trim()
Returns a copy of this text, with leading and trailing whitespace omitted.

Returns:
a copy of this text with leading and trailing white space removed, or this text if it has no leading or trailing white space.

intern

public static Text intern(java.lang.CharSequence csq)
Returns a text equals to the specified character sequence from a pool of unique text instances in ImmortalMemory.

Returns:
an unique text instance allocated in ImmortalMemory.

intern

public static Text intern(java.lang.String str)
Returns a text equals to the specified string from a pool of unique text instances in ImmortalMemory.

Returns:
an unique text instance allocated in ImmortalMemory.

contentEquals

public boolean contentEquals(java.lang.CharSequence csq)
Indicates if this text has the same character content as the specified character sequence.

Parameters:
csq - the character sequence to compare with.
Returns:
true if the specified character sequence has the same character content as this text; false otherwise.

contentEqualsIgnoreCase

public boolean contentEqualsIgnoreCase(java.lang.CharSequence csq)
Indicates if this text has the same character contend as the specified character sequence ignoring case considerations.

Parameters:
csq - the CharSequence to compare this text against.
Returns:
true if the argument and this text are equal, ignoring case; false otherwise.

equals

public boolean equals(java.lang.Object obj)
Compares this text against the specified object for equality. Returns true if the specified object is a text having the same character sequence as this text. For generic comparaison with any character sequence the contentEquals(CharSequence) should be used.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with or null.
Returns:
true if that is a text with the same character sequence as this text; false otherwise.

hashCode

public int hashCode()
Returns the hash code for this text.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value.

compareTo

public int compareTo(java.lang.Object csq)
Compares this text to another character sequence or string lexicographically.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
csq - the character sequence to be compared.
Returns:
TypeFormat.LEXICAL_COMPARATOR.compare(this, csq)
Throws:
java.lang.ClassCastException - if the specifed object is not a CharSequence or a String.

toText

public Text toText()
Returns this (implements Realtime interface).

Specified by:
toText in interface Realtime
Returns:
this

printStatistics

public void printStatistics(java.io.PrintStream out)
Prints the current statistics on this text tree structure.

Parameters:
out - the stream to use for output (e.g. System.out)

print

public void print()
Prints out this text to System.out (UTF-8 encoding). This method is equivalent to:
     synchronized(OUT) {
         print(OUT);
         OUT.flush();
     }
     ...
     static final OUT = new UTF8StreamWriter().setOutput(System.out);
 


println

public void println()
Prints out this text to System.out and then terminates the line. This method is equivalent to:
     synchronized(OUT) {
         println(OUT);
         OUT.flush();
     }
     ...
     static final OUT = new UTF8StreamWriter().setOutput(System.out);
 


print

public void print(java.io.Writer writer)
           throws java.io.IOException
Prints out this text to the specified writer.

Parameters:
writer - the destination writer.
Throws:
java.io.IOException

println

public void println(java.io.Writer writer)
             throws java.io.IOException
Prints out this text to the specified writer and then terminates the line.

Parameters:
writer - the destination writer.
Throws:
java.io.IOException

toLowerCase

public Text toLowerCase()
Converts the characters of this text to lower case.

Returns:
the text in lower case.
See Also:
Character.toLowerCase(char)

toUpperCase

public Text toUpperCase()
Converts the characters of this text to upper case.

Returns:
the text in lower case.
See Also:
Character.toUpperCase(char)

charAt

public char charAt(int index)
Returns the character at the specified index.

Specified by:
charAt in interface java.lang.CharSequence
Parameters:
index - the index of the character.
Returns:
the character at the specified index.
Throws:
java.lang.IndexOutOfBoundsException - if (index < 0) || (index >= this.length())

indexOf

public int indexOf(char c)
Returns the index within this text of the first occurrence of the specified character, starting the search at the beginning.

Parameters:
c - the character to search for.
Returns:
the index of the first occurrence of the character in this text that is greater than or equal to 0, or -1 if the character does not occur.

indexOf

public int indexOf(char c,
                   int fromIndex)
Returns the index within this text of the first occurrence of the specified character, starting the search at the specified index.

Parameters:
c - the character to search for.
fromIndex - the index to start the search from.
Returns:
the index of the first occurrence of the character in this text that is greater than or equal to fromIndex, or -1 if the character does not occur.

lastIndexOf

public int lastIndexOf(char c,
                       int fromIndex)
Returns the index within this text of the first occurrence of the specified character, searching backward and starting at the specified index.

Parameters:
c - the character to search for.
fromIndex - the index to start the search backward from.
Returns:
the index of the first occurrence of the character in this text that is less than or equal to fromIndex, or -1 if the character does not occur.

subtext

public Text subtext(int start,
                    int end)
Returns a portion of this text.

Parameters:
start - the index of the first character inclusive.
end - the index of the last character exclusive.
Returns:
the sub-text starting at the specified start position and ending just before the specified end position.
Throws:
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())

getChars

public void getChars(int start,
                     int end,
                     char[] dest,
                     int destPos)
Copies the characters from this text into the destination character array.

Parameters:
start - the index of the first character to copy.
end - the index after the last character to copy.
dest - the destination array.
destPos - the start offset in the destination array.
Throws:
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())

toString

public java.lang.String toString()
Returns the String representation of this text.

Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object
Returns:
the java.lang.String for this text.

copy

public Text copy()
Description copied from interface: ValueType
Returns a deep copy of this object allocated in the memory area (RTSJ) and/or context (Javolution) of the calling thread (the one making the copy).

Specified by:
copy in interface ValueType
Returns:
an object identical to this object but allocated by the calling thread (e.g. on the "stack" of the calling thread).

valueOf

public static Text valueOf(char c,
                           int length)
Returns the text that contains a specific length sequence of the character specified.

Parameters:
c - the character to fill this text with.
length - the length of the text returned.
Returns:
the corresponding instance.
Throws:
java.lang.IndexOutOfBoundsException - if (length < 0)

isBlank

public boolean isBlank()
Indicates if all characters of this text are whitespaces (no characters greater than the space character).

Returns:
true if this text contains only whitespace.

isBlank

public boolean isBlank(int start,
                       int length)
Indicates if the specified sub-range of characters of this text are whitespaces (no characters greater than the space character).

Parameters:
start - the start index.
length - the number of characters to inspect.

trimStart

public Text trimStart()
Returns a copy of this text, with leading whitespace omitted.

Returns:
a copy of this text with leading white space removed, or this text if it has no leading white space.

trimEnd

public Text trimEnd()
Returns a copy of this text, with trailing whitespace omitted.

Returns:
a copy of this text with trailing white space removed, or this text if it has no trailing white space.

padLeft

public Text padLeft(int len)
Pads this text on the left with spaces to make the minimum total length as specified. The new length of the new text is equal to the original length plus (length()-len) spaces.

Parameters:
len - the total number of characters to make this text equal to.
Returns:
a new text or the same text if no padding required.
Throws:
an - IllegalArgumentException if the (len<0).

padLeft

public Text padLeft(int len,
                    char c)
Pads this text on the left to make the minimum total length as specified. Spaces or the given Unicode character are used to pad with.
The new length of the new text is equal to the original length plus (length()-len) pad characters.

Parameters:
len - the total number of characters to make this text equal to.
c - the character to pad using.
Returns:
a new text or the same text if no padding required.
Throws:
an - IllegalArgumentException if the (len<0).

padRight

public Text padRight(int len)
Pads this text on the right with spaces to make the minimum total length as specified. The new length of the new text is equal to the original length plus (length()-len) spaces.

Parameters:
len - the total number of characters to make this text equal to.
Returns:
a new text or the same text if no padding required.
Throws:
an - IllegalArgumentException if the (len<0).

padRight

public Text padRight(int len,
                     char c)
Pads this text on the right to make the minimum total length as specified. Spaces or the given Unicode character are used to pad with.
The new length of the new text is equal to the original length plus (length()-len) pad characters.

Parameters:
len - the total number of characters to make this text equal to.
c - the character to pad using.
Returns:
a new text or the same text if no padding required.
Throws:
an - IllegalArgumentException if the (len<0).

indexOfAny

public int indexOfAny(CharSet charSet)
Returns the index within this text of the first occurrence of any character in the specified character set.

Parameters:
charSet - the character set.
Returns:
the index of the first character that matches one of the characters in the supplied set; or -1 if none.

indexOfAny

public int indexOfAny(CharSet charSet,
                      int start)
Returns the index within a region of this text of the first occurrence of any character in the specified character set.

Parameters:
charSet - the character set.
start - the index of the start of the search region in this text.
Returns:
the index of the first character that matches one of the characters in the supplied set; or -1 if none.

indexOfAny

public int indexOfAny(CharSet charSet,
                      int start,
                      int length)
Returns the index within a region of this text of the first occurrence of any character in the specified character set.

Parameters:
charSet - the character set.
start - the index of the start of the search region in this text.
length - the length of the region to search.
Returns:
the index of the first character that matches one of the characters in the supplied array; or -1 if none.

lastIndexOfAny

public int lastIndexOfAny(CharSet charSet)
Returns the index within this text of the last occurrence of any character in the specified character set.

Parameters:
charSet - the character set.
Returns:
the index of the last character that matches one of the characters in the supplied array; or -1 if none.

lastIndexOfAny

public int lastIndexOfAny(CharSet charSet,
                          int start)
Returns the index within a region of this text of the last occurrence of any character in the specified character set.

Parameters:
charSet - the character set.
start - the index of the start of the search region in this text.
Returns:
the index of the last character that matches one of the characters in the supplied array; or -1 if none.

lastIndexOfAny

public int lastIndexOfAny(CharSet charSet,
                          int start,
                          int length)
Returns the index within a region of this text of the last occurrence of any character in the specified character set.

Parameters:
charSet - the character set.
start - the index of the start of the search region in this text.
length - the length of the region to search.
Returns:
the index of the last character that matches one of the characters in the supplied array; or -1 if none.

J avolution v5.4 (J2SE 1.6+)

Copyright © 2005 - 2009 Javolution.