All Packages Class Hierarchy This Package Previous Next Index
Class jp.kyasu.graphics.Text
java.lang.Object
|
+----jp.kyasu.graphics.Text
- public class Text
- extends Object
- implements Cloneable, Serializable
The Text
class implements the growable string with style
(TextStyle
) and visual items (TextAttachment
).
In the Text
, following three characters has special meaning:
'\n'
- The line (paragraph) separator that breaks
the line and separates the paragraph.
'\r'
- The line break that breaks the line but not
separate the paragraph.
'\FFFE'
- The text attachment mark that indicates
the position of the text attachment.
For example:
This is a paragraph 1.\n
This is a paragraph 2\r
continued to the next line.\n
This is a paragraph 3 containing an image \FFFE.\n
- Version:
- 15 Jun 1998
- Author:
- Kazuki YASUMATSU
- See Also:
- TextStyle, TextAttachment
-
ATTACHMENT_CHAR
- The text attachment mark that indicates the position of
the text attachment.
-
LINE_BREAK_CHAR
- The line break that breaks the line but not separate the
paragraph.
-
LINE_SEPARATOR_CHAR
- The line (paragraph) separator that breaks the line and
separates the paragraph.
-
LIST_COL_SEPARATOR_CHAR
- The list column separator that separates the list column.
-
LIST_SEPARATOR_CHAR
- The list separator that separates the list item.
-
Text()
- Constructs an empty text.
-
Text(int)
- Constructs an empty text with the initial capacity.
-
Text(int, int)
- Constructs an empty text with the initial capacity and the
maximum capacity increment size.
-
Text(String)
- Constructs a text with the contents of the string, whose every
style equals to the default style.
-
Text(String, TextStyle)
- Constructs a text with the contents of the string, whose every
style equals to the specified style.
-
Text(String, TextStyle, int)
- Constructs a text with the contents of the string and the
maximum capacity increment size, whose every style equals to
the specified style.
-
Text(TextAttachment)
- Constructs a text with the text attachment, whose every style
equals to the default style.
-
Text(TextAttachment, TextStyle)
- Constructs a text with the text attachment, whose every style
equals to the specified style.
-
Text(TextAttachment, TextStyle, int)
- Constructs a text with the text attachment and the maximum
capacity increment size, whose every style equals to the
specified style.
-
Text(Visualizable)
- Constructs a text with the visual object, whose every style
equals to the default style.
-
append(char)
- Appends the character to this text.
-
append(String)
- Appends the characters of the
string
to this text.
-
append(String, int, int)
- Appends the characters of the
string
from the specified
begin
index to the specified endIndex-1
index.
-
append(Text)
- Appends the specified text to this text.
-
append(TextAttachment)
- Appends the text attachment to this text.
-
charAt(int)
- Returns the character at the specified index.
-
clone()
- Returns a clone of this text.
-
cloneStyle()
- Returns a clone of this text.
-
compareTo(String)
- Compares this text with the string argument lexicographically.
-
compareTo(Text)
- Compares two texts lexicographically.
-
copyJavaToSystemReadWriter(Reader, Writer)
- Copies the contents of the specified reader into the specified writer
with a conversion from CR or LF to the system line separator.
-
copyJavaToSystemReadWriter(Reader, Writer, String)
- Copies the contents of the specified reader into the specified writer
with a conversion from CR or LF to the specified separator.
-
copySystemToJavaReadWriter(Reader, Writer)
- Copies the contents of the specified reader into the specified writer
with a conversion from any one of line-ends (CR, LF, or CRLF) to LF.
-
copySystemToJavaReadWriter(Reader, Writer, int)
- Copies the contents of the specified reader into the specified writer
with a conversion from any one of line-ends (CR, LF, or CRLF) to LF.
-
equals(Object)
- Compares two objects for equality.
-
getAttachmentAt(int)
- Returns the text attachment at the specified index.
-
getAttachmentCount()
- Returns the number of the text attachments in this text.
-
getAttachments()
- Returns all text attachments in this text as a hashtable.
-
getChar(int)
- Returns the character at the specified index.
-
getCharacterIterator()
- Returns the character iterator for this text.
-
getCharacterIterator(int)
- Returns the character iterator for this text, with the specified
initial index.
-
getCharacterIterator(int, int, int)
- Returns the character iterator for this text, with the specified
range and initial index.
-
getChars(int, int, char[], int)
- Copies characters from this text into the destination character array.
-
getJavaString(String)
- Converts the platform string whose line-end is CR, LF, or CRLF to
the string whose internal representation is suitable for the text,
i.e., whose line-end is LF.
-
getJavaString(String, int)
- Converts the platform string whose line-end is CR, LF, or CRLF to
the string whose internal representation is suitable for the text,
i.e., whose line-end is the specified separator character.
-
getRunLengthAt(int)
- Returns the run length (the number of the constant occurrence)
of the style at the specified index.
-
getRunOffsetAt(int)
- Returns the run offset (the starting index of the constant
occurrence) of the style at the specified index.
-
getSystemString(String)
- Converts the string whose internal representation is suitable
for the text, i.e., whose line-end is LF and line-break is CR,
to the platform string whose line-end is CR, LF, or CRLF.
-
getSystemString(String, String)
- Converts the string whose internal representation is suitable
for the text, i.e., whose line-end is LF and line-break is CR,
to the platform string whose line-end is the specified line separator.
-
getTextStyleArray(int, int)
- Returns the run array representation of the text styles in this text.
-
getTextStyleAt(int)
- Returns the text style at the specified index.
-
getTextStyleCount()
- Returns the number of the text styles in this text.
-
getTextStyleRuns()
- Returns the text styles as a run array in this text.
-
getTextStyles()
- Returns all text styles in this text.
-
getTextStyles(int, int)
- Returns the text styles in this text.
-
hashCode()
- Returns a hashcode for this text.
-
indexOf(boolean, String, int)
- Returns the index within this text of the first occurrence of the
specified substring, starting at the specified index.
-
indexOf(boolean, Text, int)
- Returns the index within this text of the first occurrence of the
substring of the specified text, starting at the specified index.
-
indexOf(int)
- Returns the index within this text of the first occurrence of the
specified character.
-
indexOf(int, int)
- Returns the index within this text of the first occurrence of the
specified character, starting the search at the specified index.
-
indexOf(String)
- Returns the index within this text of the first occurrence of the
specified substring.
-
indexOf(String, int)
- Returns the index within this text of the first occurrence of the
specified substring, starting at the specified index.
-
indexOf(Text)
- Returns the index within this text of the first occurrence of the
substring in the specified text.
-
indexOf(Text, int)
- Returns the index within this text of the first occurrence of the
substring of the specified text, starting at the specified index.
-
indexOfIgnoreCase(String)
- Returns the index within this text of the first occurrence of the
specified substring, ignoring case.
-
indexOfIgnoreCase(String, int)
- Returns the index within this text of the first occurrence of the
specified substring, starting at the specified index, ignoring case.
-
indexOfIgnoreCase(Text)
- Returns the index within this text of the first occurrence of the
substring in the specified text, ignoring case.
-
indexOfIgnoreCase(Text, int)
- Returns the index within this text of the first occurrence of the
substring of the specified text, starting at the specified index,
ignoring case.
-
insert(int, String)
- Inserts the characters of the specified string to this text from
the specified
offset
.
-
insert(int, Text)
- Inserts the components of the specified text to this text from
the specified
offset
.
-
isEmpty()
- Tests if this text has no characters.
-
lastIndexOf(boolean, String, int)
- Returns the index within this text of the last occurrence of the
specified substring.
-
lastIndexOf(boolean, Text, int)
- Returns the index within this text of the last occurrence of the
substring in the specified text.
-
lastIndexOf(int)
- Returns the index within this text of the last occurrence of the
specified character.
-
lastIndexOf(int, int)
- Returns the index within this text of the last occurrence of the
specified character, searching backward starting at the specified index.
-
lastIndexOf(String)
- Returns the index within this text of the rightmost occurrence of the
specified substring.
-
lastIndexOf(String, int)
- Returns the index within this text of the last occurrence of the
specified substring.
-
lastIndexOf(Text)
- Returns the index within this text of the rightmost occurrence of the
substring in the specified text.
-
lastIndexOf(Text, int)
- Returns the index within this text of the last occurrence of the
substring in the specified text.
-
lastIndexOfIgnoreCase(String)
- Returns the index within this text of the rightmost occurrence of the
specified substring, ignoring case.
-
lastIndexOfIgnoreCase(String, int)
- Returns the index within this text of the last occurrence of the
specified substring, ignoring case.
-
lastIndexOfIgnoreCase(Text)
- Returns the index within this text of the rightmost occurrence of the
substring in the specified text, ignoring case.
-
lastIndexOfIgnoreCase(Text, int)
- Returns the index within this text of the last occurrence of the
substring in the specified text, ignoring case.
-
length()
- Returns the length of this text.
-
modifyStyle(int, int, TextStyleModifier)
- Modifies the style of this text with the specified text style modifier.
-
regionMatches(boolean, int, String, int, int)
- Tests if the text region and the string region are equal.
-
regionMatches(boolean, int, Text, int, int)
- Tests if two text regions are equal.
-
regionMatches(int, String, int, int)
- Tests if the text region and the string are equal.
-
regionMatches(int, Text, int, int)
- Tests if two text regions are equal.
-
remove(int, int)
- Removes the characters in this text from the specified
offset
.
-
removeAll()
- Removes all characters from this text and sets its length to zero.
-
replace(int, int, String)
- Replaces the components of this text with the components of the
specified string.
-
replace(int, int, Text)
- Replaces the components of this text with the components of the
specified text.
-
replaceStyle(int, int, TextStyle)
- Replaces the style of this text with the specified style.
-
setAttachmentAt(int, TextAttachment)
- Sets the component at the specified index of this text to be
the specified text attachment.
-
setChar(int, char)
- Sets the component at the specified index of this text to be
the specified character.
-
setCharAt(int, char)
- Sets the component at the specified index of this text to be
the specified character.
-
substring(int)
- Returns a new string that is a substring of this text.
-
substring(int, int)
- Returns a new string that is a substring of this text.
-
subtext(int)
- Returns a new text that is a subtext of this text.
-
subtext(int, int)
- Returns a new text that is a subtext of this text.
-
textStyles()
- Returns an enumeration of the text styles of this text.
-
textStyles(int, int)
- Returns an enumeration of the text styles of this text.
-
toString()
- Returns a string representation of this text.
LINE_SEPARATOR_CHAR
public static final char LINE_SEPARATOR_CHAR
- The line (paragraph) separator that breaks the line and
separates the paragraph.
- See Also:
- TextScanner, JAVA_STOPS
LINE_BREAK_CHAR
public static final char LINE_BREAK_CHAR
- The line break that breaks the line but not separate the
paragraph.
- See Also:
- TextScanner, JAVA_STOPS, JAVA_BREAK_STOPS
LIST_SEPARATOR_CHAR
public static final char LIST_SEPARATOR_CHAR
- The list separator that separates the list item.
- See Also:
- LIST_STOPS
LIST_COL_SEPARATOR_CHAR
public static final char LIST_COL_SEPARATOR_CHAR
- The list column separator that separates the list column.
- See Also:
- LIST_STOPS, LIST_COLUMN_STOPS
ATTACHMENT_CHAR
public static final char ATTACHMENT_CHAR
- The text attachment mark that indicates the position of
the text attachment.
- See Also:
- TextScanner
Text
public Text()
- Constructs an empty text.
Text
public Text(int initialCapacity)
- Constructs an empty text with the initial capacity.
- Parameters:
- initialCapacity - the initial capacity of the text.
Text
public Text(int initialCapacity,
int maxCapacityIncrement)
- Constructs an empty text with the initial capacity and the
maximum capacity increment size.
- Parameters:
- initialCapacity - the initial capacity of the text.
- maxCapacityIncrement - the maximum amount by which the capacity
is increased when the text overflows.
Text
public Text(String str)
- Constructs a text with the contents of the string, whose every
style equals to the default style.
- Parameters:
- str - a string.
Text
public Text(String str,
TextStyle style)
- Constructs a text with the contents of the string, whose every
style equals to the specified style.
- Parameters:
- str - a string.
- style - the style of the text.
Text
public Text(String str,
TextStyle style,
int maxCapacityIncrement)
- Constructs a text with the contents of the string and the
maximum capacity increment size, whose every style equals to
the specified style.
- Parameters:
- str - a string.
- style - the style of the text.
- maxCapacityIncrement - the maximum amount by which the capacity
is increased when the text overflows.
Text
public Text(Visualizable visualizable)
- Constructs a text with the visual object, whose every style
equals to the default style.
- Parameters:
- visualizable - a visual object.
Text
public Text(TextAttachment ta)
- Constructs a text with the text attachment, whose every style
equals to the default style.
- Parameters:
- ta - a text attachment.
Text
public Text(TextAttachment ta,
TextStyle style)
- Constructs a text with the text attachment, whose every style
equals to the specified style.
- Parameters:
- ta - a text attachment.
- style - the style of the text.
Text
public Text(TextAttachment ta,
TextStyle style,
int maxCapacityIncrement)
- Constructs a text with the text attachment and the maximum
capacity increment size, whose every style equals to the
specified style.
- Parameters:
- ta - a text attachment.
- style - the style of the text.
- maxCapacityIncrement - the maximum amount by which the capacity
is increased when the text overflows.
getJavaString
public static String getJavaString(String sysString)
- Converts the platform string whose line-end is CR, LF, or CRLF to
the string whose internal representation is suitable for the text,
i.e., whose line-end is LF.
- Parameters:
- sysString - the platform string.
- Returns:
- the string whose internal representation is suitable for
the text.
- See Also:
- getJavaString
getJavaString
public static String getJavaString(String sysString,
int separatorChar)
- Converts the platform string whose line-end is CR, LF, or CRLF to
the string whose internal representation is suitable for the text,
i.e., whose line-end is the specified separator character.
- Parameters:
- sysString - the platform string.
- separator - the specified separator character.
- Returns:
- the string whose internal representation is suitable for
the text.
- See Also:
- copySystemToJavaReadWriter
getSystemString
public static String getSystemString(String javaString)
- Converts the string whose internal representation is suitable
for the text, i.e., whose line-end is LF and line-break is CR,
to the platform string whose line-end is CR, LF, or CRLF.
- Parameters:
- javaString - the string whose internal representation is suitable
for the text.
- Returns:
- the platform string.
- See Also:
- getSystemString
getSystemString
public static String getSystemString(String javaString,
String separator)
- Converts the string whose internal representation is suitable
for the text, i.e., whose line-end is LF and line-break is CR,
to the platform string whose line-end is the specified line separator.
- Parameters:
- javaString - the string whose internal representation is suitable
for the text.
- separator - the specified separator string.
- Returns:
- the platform string.
- See Also:
- copyJavaToSystemReadWriter
copySystemToJavaReadWriter
public static void copySystemToJavaReadWriter(Reader sysReader,
Writer javaWriter) throws IOException
- Copies the contents of the specified reader into the specified writer
with a conversion from any one of line-ends (CR, LF, or CRLF) to LF.
As a result of the conversion, the contents of the writer become
suitable for the internal representation of the text.
- Parameters:
- sysReader - the specified reader.
- javaWriter - the specified writer.
- Throws: IOException
- If an I/O error occurs.
- See Also:
- copySystemToJavaReadWriter
copySystemToJavaReadWriter
public static void copySystemToJavaReadWriter(Reader sysReader,
Writer javaWriter,
int separatorChar) throws IOException
- Copies the contents of the specified reader into the specified writer
with a conversion from any one of line-ends (CR, LF, or CRLF) to LF.
As a result of the conversion, the contents of the writer become
suitable for the internal representation of the text whose line
separator equals to the specified separator character.
- Parameters:
- sysReader - the specified reader.
- javaWriter - the specified writer.
- separatorChar - the specified separator character.
- Throws: IOException
- If an I/O error occurs.
copyJavaToSystemReadWriter
public static void copyJavaToSystemReadWriter(Reader javaReader,
Writer sysWriter) throws IOException
- Copies the contents of the specified reader into the specified writer
with a conversion from CR or LF to the system line separator.
As a result of the conversion, the contents of the writer become
suitable for the platform.
- Parameters:
- javaReader - the specified reader.
- sysWriter - the specified writer.
- Throws: IOException
- If an I/O error occurs.
- See Also:
- copyJavaToSystemReadWriter
copyJavaToSystemReadWriter
public static void copyJavaToSystemReadWriter(Reader javaReader,
Writer sysWriter,
String separator) throws IOException
- Copies the contents of the specified reader into the specified writer
with a conversion from CR or LF to the specified separator.
As a result of the conversion, the contents of the writer become
suitable for the platform whose line separator equals to the
specified separator string.
- Parameters:
- javaReader - the specified reader.
- sysWriter - the specified writer.
- separator - the specified separator string.
- Throws: IOException
- If an I/O error occurs.
getCharacterIterator
public final CharacterIterator getCharacterIterator()
- Returns the character iterator for this text.
- Returns:
- the character iterator for this text.
getCharacterIterator
public final CharacterIterator getCharacterIterator(int pos)
- Returns the character iterator for this text, with the specified
initial index.
- Parameters:
- pos - initial iterator position.
- Returns:
- the character iterator for this text.
getCharacterIterator
public final CharacterIterator getCharacterIterator(int begin,
int end,
int pos)
- Returns the character iterator for this text, with the specified
range and initial index.
- Parameters:
- begin - index of the first character.
- end - index of the character following the last character.
- pos - initial iterator position.
- Returns:
- the character iterator for this text.
textStyles
public final Enumeration textStyles()
- Returns an enumeration of the text styles of this text.
- Returns:
- an enumeration of the text styles of this text.
textStyles
public final Enumeration textStyles(int begin,
int end)
- Returns an enumeration of the text styles of this text.
- Parameters:
- begin - the beginning index to get styles, inclusive.
- end - the ending index to get styles, exclusive.
- Returns:
- an enumeration of the text styles of this text.
getTextStyleRuns
public final RunArray getTextStyleRuns()
- Returns the text styles as a run array in this text.
An application should not modify the returned run array.
- Returns:
- all text styles as a run array in this text.
getTextStyleAt
public final TextStyle getTextStyleAt(int index)
- Returns the text style at the specified index.
- Parameters:
- index - an index into this text.
- Returns:
- the text style at the specified index.
getTextStyleCount
public final int getTextStyleCount()
- Returns the number of the text styles in this text.
- Returns:
- the number of the text styles in this text.
getTextStyles
public final TextStyle[] getTextStyles()
- Returns all text styles in this text.
- Returns:
- all text styles in this text.
getTextStyles
public final TextStyle[] getTextStyles(int begin,
int end)
- Returns the text styles in this text.
- Parameters:
- begin - the beginning index to get text styles, inclusive.
- end - the ending index to get text styles, exclusive.
- Returns:
- the text styles in this text.
getTextStyleArray
public final RunArray getTextStyleArray(int begin,
int end)
- Returns the run array representation of the text styles in this text.
- Parameters:
- begin - the beginning index to get text styles, inclusive.
- end - the ending index to get text styles, exclusive.
- Returns:
- the run array representation of the text styles in this text.
getAttachmentCount
public final int getAttachmentCount()
- Returns the number of the text attachments in this text.
- Returns:
- the number of the text attachments in this text.
getAttachments
public final Hashtable getAttachments()
- Returns all text attachments in this text as a hashtable.
An application should not modify the returned array.
- Returns:
- the text attachments in this text, as a hashtable.
getAttachmentAt
public final TextAttachment getAttachmentAt(int index)
- Returns the text attachment at the specified index.
- Parameters:
- index - an index into this text.
- Returns:
- the text attachment if this text contains the text attachment
at the specified index;
null
otherwise.
setAttachmentAt
public final void setAttachmentAt(int index,
TextAttachment ta)
- Sets the component at the specified index of this text to be
the specified text attachment.
- Parameters:
- index - the specified index.
- ta - the specified text attachment.
charAt
public final char charAt(int index)
- Returns the character at the specified index.
- Parameters:
- index - an index into this text.
- Returns:
- the character at the specified index.
setCharAt
public final void setCharAt(int index,
char c)
- Sets the component at the specified index of this text to be
the specified character.
- Parameters:
- index - the specified index.
- c - the specified character.
getChar
public final char getChar(int index)
- Returns the character at the specified index.
- Parameters:
- index - an index into this text.
- Returns:
- the character at the specified index.
setChar
public final void setChar(int index,
char c)
- Sets the component at the specified index of this text to be
the specified character.
- Parameters:
- index - the specified index.
- c - the specified character.
getChars
public void getChars(int srcBegin,
int srcEnd,
char dst[],
int dstBegin)
- Copies characters from this text into the destination character array.
- Parameters:
- srcBegin - index of the first character in this text
to copy (inclusive).
- srcEnd - index after the last character in this text
to copy (exclusive).
- dst - the destination array.
- dstBegin - the start offset in the destination array.
- Throws: ArrayIndexOutOfBoundsException
- If srcBegin or srcEnd is out
of range, or if srcBegin is greater than the srcEnd.
isEmpty
public final boolean isEmpty()
- Tests if this text has no characters.
- Returns:
-
true
if this text has no characters;
false
otherwise.
length
public final int length()
- Returns the length of this text.
- Returns:
- the length of this text.
hashCode
public int hashCode()
- Returns a hashcode for this text.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object anObject)
- Compares two objects for equality.
- Overrides:
- equals in class Object
compareTo
public int compareTo(Text anotherText)
- Compares two texts lexicographically. This operation does not
compare the styles or the text attachments (visual items).
The comparison is based on the Unicode value of each character in
the texts.
- Parameters:
- anotherText - the
Text
to be compared.
- Returns:
- the value
0
if the text argument is equal to
this text; a value less than 0
if this text
is lexicographically less than the text argument; and a
value greater than 0
if this text is
lexicographically greater than the text argument.
compareTo
public int compareTo(String anotherString)
- Compares this text with the string argument lexicographically.
The comparison is based on the Unicode value of each character in
the text and the string.
- Parameters:
- anotherString - the
String
to be compared.
- Returns:
- the value
0
if the string argument is equal to
this text; a value less than 0
if this text
is lexicographically less than the string argument; and a
value greater than 0
if this text is
lexicographically greater than the string argument.
regionMatches
public boolean regionMatches(int toffset,
Text other,
int ooffset,
int len)
- Tests if two text regions are equal. The comparison is based on
the Unicode value of each character in the texts.
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this text, or if ooffset
+length
is greater than the length of the text argument, then this method
returns false
.
- Parameters:
- toffset - the starting offset of the subregion in this text.
- other - the text argument.
- ooffset - the starting offset of the subregion in the text
argument.
- len - the number of characters to compare.
- Returns:
-
true
if the specified subregion of this text
exactly matches the specified subregion of the text argument;
false
otherwise.
regionMatches
public boolean regionMatches(int toffset,
String other,
int ooffset,
int len)
- Tests if the text region and the string are equal. The comparison
is based on the Unicode value of each character in the text and the
string.
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this text, or if ooffset
+length
is greater than the length of the string argument, then this method
returns false
.
- Parameters:
- toffset - the starting offset of the subregion in this text.
- other - the string argument.
- ooffset - the starting offset of the subregion in the string
argument.
- len - the number of characters to compare.
- Returns:
-
true
if the specified subregion of this text
exactly matches the specified subregion of the string argument;
false
otherwise.
regionMatches
public boolean regionMatches(boolean ignoreCase,
int toffset,
Text other,
int ooffset,
int len)
- Tests if two text regions are equal. The comparison is based on
the Unicode value of each character in the texts.
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this text, or if ooffset
+length
is greater than the length of the text argument, then this method
returns false
.
- Parameters:
- ignoreCase - if
true
, ignore case when comparing
characters.
- toffset - the starting offset of the subregion in this text.
- other - the text argument.
- ooffset - the starting offset of the subregion in the text
argument.
- len - the number of characters to compare.
- Returns:
-
true
if the specified subregion of this text
matches the specified subregion of the text argument;
false
otherwise. Whether the matching is exact
or case insensitive depends on the ignoreCase
argument.
regionMatches
public boolean regionMatches(boolean ignoreCase,
int toffset,
String other,
int ooffset,
int len)
- Tests if the text region and the string region are equal. The
comparison is based on the Unicode value of each character in the
texts.
If toffset
or ooffset
is negative, or
if toffset
+length
is greater than the
length of this text, or if ooffset
+length
is greater than the length of the string argument, then this method
returns false
.
- Parameters:
- ignoreCase - if
true
, ignore case when comparing
characters.
- toffset - the starting offset of the subregion in this text.
- other - the string argument.
- ooffset - the starting offset of the subregion in the string
argument.
- len - the number of characters to compare.
- Returns:
-
true
if the specified subregion of this text
matches the specified subregion of the string argument;
false
otherwise. Whether the matching is exact
or case insensitive depends on the ignoreCase
argument.
indexOf
public int indexOf(int ch)
- Returns the index within this text of the first occurrence of the
specified character.
- Parameters:
- ch - a character.
- Returns:
- the index of the first occurrence of the character in the
character sequence represented by this object, or
-1
if the character does not occur.
indexOf
public int indexOf(int ch,
int fromIndex)
- Returns the index within this text of the first occurrence of the
specified character, starting the search at the specified index.
- Parameters:
- ch - a character.
- fromIndex - the index to start the search from.
- Returns:
- the index of the first occurrence of the character in the
character sequence represented by this object that is greater
than or equal to
fromIndex
, or -1
if the character does not occur.
lastIndexOf
public int lastIndexOf(int ch)
- Returns the index within this text of the last occurrence of the
specified character.
The Text is searched backwards starting at the last character.
- Parameters:
- ch - a character.
- Returns:
- the index of the last occurrence of the character in the
character sequence represented by this object, or
-1
if the character does not occur.
lastIndexOf
public int lastIndexOf(int ch,
int fromIndex)
- Returns the index within this text of the last occurrence of the
specified character, searching backward starting at the specified index.
- Parameters:
- ch - a character.
- fromIndex - the index to start the search from.
- Returns:
- the index of the last occurrence of the character in the
character sequence represented by this object that is less
than or equal to
fromIndex
, or -1
if the character does not occur before that point.
indexOf
public int indexOf(Text text)
- Returns the index within this text of the first occurrence of the
substring in the specified text.
- Parameters:
- text - the subtext to search for.
- Returns:
- if the text argument occurs as a substring within this
object, then the index of the first character of the first
such substring is returned; if it does not occur as a
substring,
-1
is returned.
indexOf
public int indexOf(Text text,
int fromIndex)
- Returns the index within this text of the first occurrence of the
substring of the specified text, starting at the specified index.
- Parameters:
- text - the subtext to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the text argument occurs as a substring within this
object at a starting index no smaller than
fromIndex
, then the index of the first character
of the first such substring is returned. If it does not occur
as a substring starting at fromIndex
or beyond,
-1
is returned.
indexOfIgnoreCase
public int indexOfIgnoreCase(Text text)
- Returns the index within this text of the first occurrence of the
substring in the specified text, ignoring case.
- Parameters:
- text - the subtext to search for.
- Returns:
- if the text argument occurs as a substring within this
object, then the index of the first character of the first
such substring is returned; if it does not occur as a
substring,
-1
is returned.
indexOfIgnoreCase
public int indexOfIgnoreCase(Text text,
int fromIndex)
- Returns the index within this text of the first occurrence of the
substring of the specified text, starting at the specified index,
ignoring case.
- Parameters:
- text - the subtext to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the text argument occurs as a substring within this
object at a starting index no smaller than
fromIndex
, then the index of the first character
of the first such substring is returned. If it does not occur
as a substring starting at fromIndex
or beyond,
-1
is returned.
indexOf
public int indexOf(boolean ignoreCase,
Text text,
int fromIndex)
- Returns the index within this text of the first occurrence of the
substring of the specified text, starting at the specified index.
If the
ignoreCase
is true, then ignore case when
comparing characters.
- Parameters:
- ignoreCase - if
true
, ignore case when comparing
characters.
- text - the subtext to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the text argument occurs as a substring within this
object at a starting index no smaller than
fromIndex
, then the index of the first character
of the first such substring is returned. If it does not occur
as a substring starting at fromIndex
or beyond,
-1
is returned.
indexOf
public int indexOf(String str)
- Returns the index within this text of the first occurrence of the
specified substring.
- Parameters:
- str - the substring to search for.
- Returns:
- if the string argument occurs as a substring within this
object, then the index of the first character of the first
such substring is returned; if it does not occur as a
substring,
-1
is returned.
indexOf
public int indexOf(String str,
int fromIndex)
- Returns the index within this text of the first occurrence of the
specified substring, starting at the specified index.
- Parameters:
- str - the substring to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the string argument occurs as a substring within this
object at a starting index no smaller than
fromIndex
, then the index of the first character
of the first such substring is returned. If it does not occur
as a substring starting at fromIndex
or beyond,
-1
is returned.
indexOfIgnoreCase
public int indexOfIgnoreCase(String str)
- Returns the index within this text of the first occurrence of the
specified substring, ignoring case.
- Parameters:
- str - the substring to search for.
- Returns:
- if the string argument occurs as a substring within this
object, then the index of the first character of the first
such substring is returned; if it does not occur as a
substring,
-1
is returned.
indexOfIgnoreCase
public int indexOfIgnoreCase(String str,
int fromIndex)
- Returns the index within this text of the first occurrence of the
specified substring, starting at the specified index, ignoring case.
- Parameters:
- str - the substring to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the string argument occurs as a substring within this
object at a starting index no smaller than
fromIndex
, then the index of the first character
of the first such substring is returned. If it does not occur
as a substring starting at fromIndex
or beyond,
-1
is returned.
indexOf
public int indexOf(boolean ignoreCase,
String str,
int fromIndex)
- Returns the index within this text of the first occurrence of the
specified substring, starting at the specified index.
If the
ignoreCase
is true, then ignore case when
comparing characters.
- Parameters:
- ignoreCase - if
true
, ignore case when comparing
characters.
- str - the substring to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the string argument occurs as a substring within this
object at a starting index no smaller than
fromIndex
, then the index of the first character
of the first such substring is returned. If it does not occur
as a substring starting at fromIndex
or beyond,
-1
is returned.
lastIndexOf
public int lastIndexOf(Text text)
- Returns the index within this text of the rightmost occurrence of the
substring in the specified text. The rightmost empty string "" is
considered to occur at the index value
this.length()
.
- Parameters:
- text - the subtext to search for.
- Returns:
- if the text argument occurs one or more times as a substring
within this object, then the index of the first character of
the last such substring is returned. If it does not occur as
a substring,
-1
is returned.
lastIndexOf
public int lastIndexOf(Text text,
int fromIndex)
- Returns the index within this text of the last occurrence of the
substring in the specified text.
The returned index indicates the start of the subtext, and it
must be equal to or less than
fromIndex
.
- Parameters:
- text - the subtext to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the text argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex
, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex
or earlier,
-1
is returned.
lastIndexOfIgnoreCase
public int lastIndexOfIgnoreCase(Text text)
- Returns the index within this text of the rightmost occurrence of the
substring in the specified text, ignoring case. The rightmost empty
string "" is considered to occur at the index value
this.length()
.
- Parameters:
- text - the subtext to search for.
- Returns:
- if the text argument occurs one or more times as a substring
within this object, then the index of the first character of
the last such substring is returned. If it does not occur as
a substring,
-1
is returned.
lastIndexOfIgnoreCase
public int lastIndexOfIgnoreCase(Text text,
int fromIndex)
- Returns the index within this text of the last occurrence of the
substring in the specified text, ignoring case.
The returned index indicates the start of the subtext, and it
must be equal to or less than
fromIndex
.
- Parameters:
- text - the subtext to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the text argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex
, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex
or earlier,
-1
is returned.
lastIndexOf
public int lastIndexOf(boolean ignoreCase,
Text text,
int fromIndex)
- Returns the index within this text of the last occurrence of the
substring in the specified text.
The returned index indicates the start of the subtext, and it
must be equal to or less than
fromIndex
.
If the ignoreCase
is true, then ignore case when
comparing characters.
- Parameters:
- ignoreCase - if
true
, ignore case when comparing
characters.
- text - the subtext to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the text argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex
, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex
or earlier,
-1
is returned.
lastIndexOf
public int lastIndexOf(String str)
- Returns the index within this text of the rightmost occurrence of the
specified substring. The rightmost empty string "" is considered to
occur at the index value
this.length()
.
- Parameters:
- str - the substring to search for.
- Returns:
- if the string argument occurs one or more times as a substring
within this object, then the index of the first character of
the last such substring is returned. If it does not occur as
a substring,
-1
is returned.
lastIndexOf
public int lastIndexOf(String str,
int fromIndex)
- Returns the index within this text of the last occurrence of the
specified substring.
The returned index indicates the start of the substring, and it
must be equal to or less than
fromIndex
.
- Parameters:
- str - the substring to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the string argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex
, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex
or earlier,
-1
is returned.
lastIndexOfIgnoreCase
public int lastIndexOfIgnoreCase(String str)
- Returns the index within this text of the rightmost occurrence of the
specified substring, ignoring case. The rightmost empty string "" is
considered to occur at the index value
this.length()
.
- Parameters:
- str - the substring to search for.
- Returns:
- if the string argument occurs one or more times as a substring
within this object, then the index of the first character of
the last such substring is returned. If it does not occur as
a substring,
-1
is returned.
lastIndexOfIgnoreCase
public int lastIndexOfIgnoreCase(String str,
int fromIndex)
- Returns the index within this text of the last occurrence of the
specified substring, ignoring case.
The returned index indicates the start of the substring, and it
must be equal to or less than
fromIndex
.
- Parameters:
- str - the substring to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the string argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex
, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex
or earlier,
-1
is returned.
lastIndexOf
public int lastIndexOf(boolean ignoreCase,
String str,
int fromIndex)
- Returns the index within this text of the last occurrence of the
specified substring.
The returned index indicates the start of the substring, and it
must be equal to or less than
fromIndex
.
If the ignoreCase
is true, then ignore case when
comparing characters.
- Parameters:
- ignoreCase - if
true
, ignore case when comparing
characters.
- str - the substring to search for.
- fromIndex - the index to start the search from.
- Returns:
- If the string argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex
, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex
or earlier,
-1
is returned.
removeAll
public void removeAll()
- Removes all characters from this text and sets its length to zero.
remove
public void remove(int offset,
int size)
- Removes the characters in this text from the specified
offset
. The number of the characters to be removed is
specified by the size
. Each character in this text
with an index greater or equal to offset+size
is
shifted downward.
- Parameters:
- offset - the start index of the characters to be removed.
- size - the number of the characters to be removed.
substring
public String substring(int beginIndex)
- Returns a new string that is a substring of this text. The substring
begins at the specified index and extends to the end of this text.
- Parameters:
- beginIndex - the beginning index, inclusive.
- Returns:
- the substring.
substring
public String substring(int beginIndex,
int endIndex)
- Returns a new string that is a substring of this text. The substring
begins at the specified
beginIndex
and extends to the
character at index endIndex-1
.
- Parameters:
- beginIndex - the beginning index, inclusive.
- endIndex - the ending index, exclusive.
- Returns:
- the substring.
subtext
public Text subtext(int beginIndex)
- Returns a new text that is a subtext of this text. The subtext
begins at the specified index and extends to the end of this text.
- Parameters:
- beginIndex - the beginning index, inclusive.
- Returns:
- the subtext.
subtext
public Text subtext(int beginIndex,
int endIndex)
- Returns a new text that is a subtext of this text. The subtext
begins at the specified
beginIndex
and extends to the
character at index endIndex-1
.
- Parameters:
- beginIndex - the beginning index, inclusive.
- endIndex - the ending index, exclusive.
- Returns:
- the subtext.
append
public Text append(char c)
- Appends the character to this text.
- Parameters:
- c - a character.
- Returns:
- this text.
append
public Text append(String str)
- Appends the characters of the
string
to this text.
- Parameters:
- str - a string.
- Returns:
- this text.
append
public Text append(String str,
int begin,
int end)
- Appends the characters of the
string
from the specified
begin
index to the specified endIndex-1
index.
- Parameters:
- str - a string.
- begin - the beginning index of the string, inclusive.
- end - the ending index of the string, exclusive.
- Returns:
- this text.
append
public Text append(Text text)
- Appends the specified text to this text.
- Parameters:
- text - a text.
- Returns:
- this text.
append
public Text append(TextAttachment ta)
- Appends the text attachment to this text.
- Parameters:
- ta - a text attachment.
- Returns:
- this text.
insert
public Text insert(int offset,
String str)
- Inserts the characters of the specified string to this text from
the specified
offset
.
- Parameters:
- offset - the start index of the characters to be inserted.
- str - a string.
- Returns:
- this text.
insert
public Text insert(int offset,
Text text)
- Inserts the components of the specified text to this text from
the specified
offset
.
- Parameters:
- offset - the start index of the components to be inserted.
- text - a text.
- Returns:
- this array.
replace
public Text replace(int begin,
int end,
String str)
- Replaces the components of this text with the components of the
specified string.
- Parameters:
- begin - the beginning index to replace, inclusive.
- end - the ending index to replace, exclusive.
- str - a replacement string.
- Returns:
- this text.
replace
public Text replace(int begin,
int end,
Text text)
- Replaces the components of this text with the components of the
specified text.
- Parameters:
- begin - the beginning index to replace, inclusive.
- end - the ending index to replace, exclusive.
- varray - a replacement text.
- Returns:
- this text.
replaceStyle
public Text replaceStyle(int begin,
int end,
TextStyle style)
- Replaces the style of this text with the specified style.
- Parameters:
- begin - the beginning index to replace, inclusive.
- end - the ending index to replace, exclusive.
- style - a replacement style.
- Returns:
- this text.
- Throws: ArrayIndexOutOfBoundsException
- if the
begin
, or
the end
is out of range.
modifyStyle
public Text modifyStyle(int begin,
int end,
TextStyleModifier modifier)
- Modifies the style of this text with the specified text style modifier.
- Parameters:
- begin - the beginning index to modify, inclusive.
- end - the ending index to modify, exclusive.
- modifier - the text style modifier.
- Returns:
- this text.
- Throws: ArrayIndexOutOfBoundsException
- if the
begin
, or
the end
is out of range.
getRunLengthAt
public int getRunLengthAt(int index)
- Returns the run length (the number of the constant occurrence)
of the style at the specified index.
- Parameters:
- index - an index into this text.
- Returns:
- the run length of the style from the specified index.
getRunOffsetAt
public int getRunOffsetAt(int index)
- Returns the run offset (the starting index of the constant
occurrence) of the style at the specified index.
- Parameters:
- index - an index into this text.
- Returns:
- the run offset of the style from the specified index.
cloneStyle
public Text cloneStyle()
- Returns a clone of this text. Contents of string and attachments are
shared.
- Returns:
- a clone of this text. Contents of string and attachments are
shared.
clone
public Object clone()
- Returns a clone of this text.
- Returns:
- a clone of this text.
- Overrides:
- clone in class Object
toString
public String toString()
- Returns a string representation of this text.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index