public final class StyledString extends java.lang.Object implements java.lang.Iterable<StyledString.Fragment>
fragments
mark substrings of the string and do not overlap.
Styles are applied using instances of StyledString.Style
. It can be iterated to
get all composing fragments.Modifier and Type | Class and Description |
---|---|
static class |
StyledString.Fragment
An immutable string styled with a given
StyledString.Style . |
static class |
StyledString.Style
An immutable object describing how a
StyledString should be style. |
Constructor and Description |
---|
StyledString()
Constructs an empty styled string.
|
StyledString(java.lang.String text)
Constructs a new styled string with the given text with no associated style.
|
StyledString(java.lang.String text,
StyledString.Style style)
Constructs a new styled string with the given text associated with the given style.
|
Modifier and Type | Method and Description |
---|---|
StyledString |
append(java.lang.String string)
Appends a string with a style to the
StyledString . |
StyledString |
append(java.lang.String string,
StyledString.Style style)
Appends a string with a style to the
StyledString . |
StyledString |
append(StyledString styledString)
Appends a string with styles to the
StyledString . |
java.lang.String |
getString()
Returns the string of this
StyledString . |
java.util.Iterator<StyledString.Fragment> |
iterator() |
public StyledString()
public StyledString(java.lang.String text)
public StyledString(java.lang.String text, StyledString.Style style)
public java.lang.String getString()
StyledString
.StyledString
.public StyledString append(java.lang.String string)
StyledString
. The appended
string will be not be styled.string
- the string to appendpublic StyledString append(java.lang.String string, StyledString.Style style)
StyledString
. The appended
string will be styled with the given style
.string
- the string to appendstyle
- the style to use for styling the string to append or
null
if no style should be associated with the
appended string.public StyledString append(StyledString styledString)
StyledString
.styledString
- the string to appendpublic java.util.Iterator<StyledString.Fragment> iterator()
iterator
in interface java.lang.Iterable<StyledString.Fragment>