public class IlvAttributedStringUtil extends Object
IlvAttributedStringUtil
class consists of static methods
that are of general use when working with
java.text.AttributedString
.
This class is a singleton and instances of this class cannot be created.Modifier and Type | Field and Description |
---|---|
static DataFlavor |
ATTRIBUTED_STRING_FLAVOR
Data flavor for attributed string selections.
|
Modifier and Type | Method and Description |
---|---|
static AttributedString |
concat(AttributedString astring1,
AttributedString astring2)
Concatenates two attributed strings.
|
static AttributedString |
concat(AttributedString astring1,
AttributedString astring2,
AttributedString astring3)
Concatenates three attributed strings.
|
static AttributedString |
concat(AttributedString astring,
String suffix)
Concatenates an attributed string with string suffix.
|
static AttributedString |
concat(AttributedString astring1,
String string2,
AttributedString astring3)
Inserts a normal string between two attributed strings.
|
static AttributedString |
concat(String prefix,
AttributedString astring)
Concatenates an attributed string with string prefix.
|
static void |
copyAttributes(AttributedString src,
int src_position,
AttributedString dst,
int dst_position,
int length)
Copies the attributes from the source attributed string to the destination
attributed string.
|
static void |
debugPrint(PrintStream out,
AttributedString astring)
Prints debug information about the attributed string.
|
static String |
getString(AttributedString astring)
Returns the string contained in an attributed string.
|
static TextAttribute |
getTextAttribute(String name)
Returns the text attribute of its name string.
|
static String |
getTextAttributeName(TextAttribute t)
Converts a text attribute to its name string.
|
static Transferable |
getTransferable(AttributedString src)
Returns a transferable for the attributed string.
|
static int |
length(AttributedString astring)
Returns the length of the attributed string.
|
static AttributedString |
substring(AttributedString astring,
int beginIndex,
int endIndex)
Returns the attributed string that is a substring of the input string.
|
public static final DataFlavor ATTRIBUTED_STRING_FLAVOR
public static String getString(AttributedString astring)
astring
- The attributed stringpublic static int length(AttributedString astring)
public static AttributedString substring(AttributedString astring, int beginIndex, int endIndex)
beginIndex
and
extends to the character at index endIndex - 1
.
Thus the length of the substring is endIndex-beginIndex
.
astring
- The original attributed string.beginIndex
- The beginning index, inclusive.endIndex
- The ending index, exclusive.IndexOutOfBoundsException
- if the
beginIndex
is negative, or
endIndex
is larger than the length of
this AttributedString
object, or
beginIndex
is larger than
endIndex
.public static AttributedString concat(AttributedString astring1, AttributedString astring2)
public static AttributedString concat(AttributedString astring1, AttributedString astring2, AttributedString astring3)
public static AttributedString concat(String prefix, AttributedString astring)
public static AttributedString concat(AttributedString astring, String suffix)
public static AttributedString concat(AttributedString astring1, String string2, AttributedString astring3)
public static void copyAttributes(AttributedString src, int src_position, AttributedString dst, int dst_position, int length)
src_position + length
characters.
The destination string must have at least
dst_position + length
characters.src
- the source string.src_position
- start position in the source string.dst
- the destination string.dst_position
- start position in the destination string.length
- the number of characters whose attributes
are copied.IllegalArgumentException
- one of the strings has not enough
characters.public static void debugPrint(PrintStream out, AttributedString astring)
out
- The output streamastring
- The attributed stringpublic static String getTextAttributeName(TextAttribute t)
TextAttribute.getName()
.getTextAttribute(java.lang.String)
public static TextAttribute getTextAttribute(String name)
public static Transferable getTransferable(AttributedString src)
ATTRIBUTED_STRING_FLAVOR
.
The transfer data of the data flavor ATTRIBUTED_STRING_FLAVOR
is the attributed string itself.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.