public class AttributedString extends Object
属性是一个键/值对,由键确定。在一个给定的字符上没有两个属性可以有相同的键。
属性的值是不可变的,也不能由客户端或存储发生突变。他们总是通过参考,而不是克隆。
AttributedCharacterIterator
,
Annotation
Constructor and Description |
---|
AttributedString(AttributedCharacterIterator text)
构建了一个attributedstring实例与给定的属性的文本表示的attributedcharacteriterator。
|
AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex)
构建了一个attributedstring实例与给定的属性的文本表示的attributedcharacteriterator终端。
|
AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes)
构建了一个attributedstring实例与给定的属性的文本表示的attributedcharacteriterator终端。
|
AttributedString(String text)
构建了一个attributedstring实例与给定的文本。
|
AttributedString(String text, Map<? extends AttributedCharacterIterator.Attribute,?> attributes)
构建了一个attributedstring实例与给定的文本和属性。
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(AttributedCharacterIterator.Attribute attribute, Object value)
向整个字符串添加一个属性。
|
void |
addAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int beginIndex, int endIndex)
将属性添加到的子字符串。
|
void |
addAttributes(Map<? extends AttributedCharacterIterator.Attribute,?> attributes, int beginIndex, int endIndex)
将一组属性的一部分的字符串。
|
AttributedCharacterIterator |
getIterator()
创建一个attributedcharacteriterator实例提供了访问此字符串的全部内容。
|
AttributedCharacterIterator |
getIterator(AttributedCharacterIterator.Attribute[] attributes)
创建一个attributedcharacteriterator实例提供了访问该字符串所选择的内容。
|
AttributedCharacterIterator |
getIterator(AttributedCharacterIterator.Attribute[] attributes, int beginIndex, int endIndex)
创建一个attributedcharacteriterator实例提供了访问该字符串所选择的内容。
|
public AttributedString(String text)
text
-这个属性字符串文本。
NullPointerException
-如果
text
是空的。
public AttributedString(String text, Map<? extends AttributedCharacterIterator.Attribute,?> attributes)
text
-这个属性字符串文本。
attributes
-应用于整个字符串的属性。
NullPointerException
-如果
text
或
attributes
是空的。
IllegalArgumentException
-如果文本长度为0和属性参数不是一个空洞的Map(属性不能应用于一个长度为0的范围)。
public AttributedString(AttributedCharacterIterator text)
text
-这个属性字符串文本。
NullPointerException
-如果
text
是空的。
public AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex)
text
-这个属性字符串文本。
beginIndex
-范围的第一个字符索引。
endIndex
的字符索引以下范围的最后一个字符。
NullPointerException
-如果
text
是空的。
IllegalArgumentException
beginIndex和endIndex如果给定的子范围的文本范围。
Annotation
public AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes)
text
-这个属性字符串文本。
beginIndex
-范围的第一个字符索引。
endIndex
的字符索引以下范围的最后一个字符。
attributes
-指定属性是从文本中提取。如果指定了空,所有可用的属性将被使用。
NullPointerException
-如果
text
是空的。
IllegalArgumentException
beginIndex和endIndex如果给定的子范围的文本范围。
Annotation
public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value)
attribute
-属性的关键
value
-该属性的值可以为空;
NullPointerException
-如果
attribute
是空的。
IllegalArgumentException
-如果attributedstring长度为0(属性不能应用于一个长度为0的范围)。
public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int beginIndex, int endIndex)
attribute
-属性的关键
value
-该属性的值。可能是空的。
beginIndex
-范围的第一个字符索引。
endIndex
的字符索引以下范围的最后一个字符。
NullPointerException
-如果
attribute
是空的。
IllegalArgumentException
如果beginIndex小于0,指定大于字符串的长度,或beginIndex和endIndex一起不定义一个非空的子字符串。
public void addAttributes(Map<? extends AttributedCharacterIterator.Attribute,?> attributes, int beginIndex, int endIndex)
attributes
-被添加到字符串的属性。
beginIndex
-范围的第一个字符索引。
endIndex
的字符索引以下范围的最后一个字符。
NullPointerException
-如果
attributes
是空的。
IllegalArgumentException
如果beginIndex小于0,指定大于字符串的长度,或beginIndex和endIndex一起不定义一个非空的子字符串和属性参数不是一个空洞的Map。
public AttributedCharacterIterator getIterator()
public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes)
attributes
-目录,用户感兴趣的属性
public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes, int beginIndex, int endIndex)
attributes
-目录,用户感兴趣的属性
beginIndex
-第一个字符的索引
endIndex
-最后一个字符后的字符的索引
IllegalArgumentException
如果beginIndex小于0,指定大于字符串的长度,或beginIndex大于endIndex。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.