java text类型_java.text 类 AttributedString - Java 中文参考手册

java.lang.Object

c8e9f4e075d37a0af332e4af80182959.gifjava.text.AttributedString

public class AttributedStringextends Object

AttributedString 保存文本及相关属性信息。在文本阅读器希望通过 AttributedCharacterIterator 接口访问属性文本的情况下,它可用于存储实际数据。

从以下版本开始:

1.2

另请参见:AttributedCharacterIterator,

Annotation

构造方法摘要

AttributedString(AttributedCharacterIteratortext)

用给定的 AttributedCharacterIterator 表示的属性文本构造一个 AttributedString。

AttributedString(AttributedCharacterIteratortext,

intbeginIndex,

intendIndex)

用给定的 AttributedCharacterIterator 表示的属性文本的子范围构造一个 AttributedString。

AttributedString(AttributedCharacterIteratortext,

intbeginIndex,

intendIndex,

AttributedCharacterIterator.Attribute[]attributes)

用给定的 AttributedCharacterIterator 表示的属性文本的子范围构造一个 AttributedString。

AttributedString(Stringtext)

构造带给定文本的 AttributedString 实例。

AttributedString(Stringtext,

Map extends AttributedCharacterIterator.Attribute,?>attributes)

构造带给定文本和属性的 AttributedString。

方法摘要

void

addAttribute(AttributedCharacterIterator.Attributeattribute,

Objectvalue)

将一个属性添加到整个字符串中。

void

addAttribute(AttributedCharacterIterator.Attributeattribute,

Objectvalue,

intbeginIndex,

intendIndex)

将一个属性添加到字符串的子范围。

void

addAttributes(Map extends AttributedCharacterIterator.Attribute,?>attributes,

intbeginIndex,

intendIndex)

将属性集添加到字符串的子范围。

AttributedCharacterIterator

getIterator()

构造一个 AttributedCharacterIterator 实例,提供对整个字符串内容的访问。

AttributedCharacterIterator

getIterator(AttributedCharacterIterator.Attribute[]attributes)

构造一个 AttributedCharacterIterator 实例,提供对字符串选定内容的访问。

AttributedCharacterIterator

getIterator(AttributedCharacterIterator.Attribute[]attributes,

intbeginIndex,

intendIndex)

构造一个 AttributedCharacterIterator 实例,提供对字符串选定内容的访问。

从类 java.lang.Object 继承的方法

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

构造方法详细信息

AttributedString

public AttributedString(Stringtext)

构造带给定文本的 AttributedString 实例。

参数:text – 此属性字符串的文本。

AttributedString

public AttributedString(Stringtext,

Map extends AttributedCharacterIterator.Attribute,?>attributes)

构造带给定文本和属性的 AttributedString。

参数:text – 此属性字符串的文本。attributes – 应用于整个字符串的属性。抛出:IllegalArgumentException – 如果文本长度为 0 且属性参数不是一个空 Map(属性不能应用于 0 长度范围文本)。

AttributedString

public AttributedString(AttributedCharacterIteratortext)

用给定的 AttributedCharacterIterator 表示的属性文本构造一个 AttributedString。

参数:text – 此属性字符串的文本。

AttributedString

public AttributedString(AttributedCharacterIteratortext,

intbeginIndex,

intendIndex)

用给定的 AttributedCharacterIterator 表示的属性文本的子范围构造一个 AttributedString。如果给定的范围产生一个空文本,所有的属性将被丢弃。注意,对于初始属性范围的子范围,Annotation 对象包装的任何属性都被丢弃。

参数:text – 此属性字符串的文本。beginIndex – 该范围的第一个字符的索引。endIndex – 范围最后一个字符之后紧邻字符的索引。抛出:IllegalArgumentException – 如果 beginIndex 和 endIndex 指定的子范围超出文本范围。另请参见:Annotation

AttributedString

public AttributedString(AttributedCharacterIteratortext,

intbeginIndex,

intendIndex,

AttributedCharacterIterator.Attribute[]attributes)

用给定的 AttributedCharacterIterator 表示的属性文本的子范围构造一个 AttributedString。只有属性与给定的属性匹配时才被合并进该实例。如果指定的范围产生一个空文本,所有的属性将被丢弃。注意,对于初始属性范围的子范围,Annotation 对象包装的任何属性都被丢弃。

参数:text – 此属性字符串的文本。beginIndex – 该范围的第一个字符的索引。endIndex – 范围最后一个字符之后紧邻字符的索引。attributes – 指定要从文本中提取出来的属性。如果指定为 null,则用到所有可用属性。抛出:IllegalArgumentException – 如果 beginIndex 和 endIndex 指定的子范围超出文本范围。另请参见:Annotation

方法详细信息

addAttribute

public void addAttribute(AttributedCharacterIterator.Attributeattribute,

Objectvalue)

将一个属性添加到整个字符串中。

参数:attribute – 属性键value – 属性值;可以为 null抛出:IllegalArgumentException – 如果 AttributedString 长度为 0(属性不能应用于 0 长度范围文本)。

addAttribute

public void addAttribute(AttributedCharacterIterator.Attributeattribute,

Objectvalue,

intbeginIndex,

intendIndex)

将一个属性添加到字符串的子范围。

参数:attribute – 属性键value – 属性值。可以为 null。beginIndex – 该范围的第一个字符的索引。endIndex – 范围最后一个字符之后紧邻字符的索引。抛出:IllegalArgumentException – 如果 beginIndex 小于 0,endIndex 大于字符串的长度,或者 beginIndex 和 endIndex 一起未定义字符串的非空子范围。

addAttributes

public void addAttributes(Map extends AttributedCharacterIterator.Attribute,?>attributes,

intbeginIndex,

intendIndex)

将属性集添加到字符串的子范围。

参数:attributes – 要添加到字符串的属性。beginIndex – 该范围的第一个字符的索引。endIndex – 范围最后一个字符之后紧邻字符的索引。抛出:IllegalArgumentException – 如果 beginIndex 小于 0,endIndex 大于字符串的长度,或者 beginIndex 和 endIndex 一起未定义字符串的非空子范围,且属性参数不是一个空 Map。

getIterator

public AttributedCharacterIterator getIterator()

构造一个 AttributedCharacterIterator 实例,提供对整个字符串内容的访问。

返回:提供访问文本及其属性的迭代器。

getIterator

public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[]attributes)

构造一个 AttributedCharacterIterator 实例,提供对字符串选定内容的访问。实现者不必让没有列于属性中的属性信息通过迭代器可访问。如果列表为 null,则应该让所有可用的属性信息都可访问。

参数:attributes – 客户感兴趣的属性列表返回:提供访问文本及其属性的迭代器

getIterator

public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[]attributes,

intbeginIndex,

intendIndex)

构造一个 AttributedCharacterIterator 实例,提供对字符串选定内容的访问。实现者不必让没有列于属性中的属性信息通过迭代器可访问。如果列表为 null,则应该让所有可用的属性信息都可访问。

参数:attributes – 客户感兴趣的属性列表beginIndex – 第一个字符的索引endIndex – 最后一个字符之后紧邻字符的索引返回:提供访问文本及其属性的迭代器抛出:IllegalArgumentException – 如果 beginIndex 小于 0,endIndex 大于字符串的长度,或者 beginIndex 大于 endIndex。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值