JavaTM 2 Platform
Standard Ed. 6

javax.swing.text
接口 AbstractDocument.AttributeContext

所有已知实现类:
StyleContext, StyleSheet
正在封闭类:
AbstractDocument

public static interface AbstractDocument.AttributeContext

一个接口,它用于允许 MutableAttributeSet 的实现使用可插入属性压缩技术。可以使用属性集的每个变化将以前的 AttributeSet 实例与另一个实例交换,保留 AttributeSet 保持不可变的可能性。StyleContext 类提供了一个实现。 此类提供的 Element 实现使用此接口来提供其 MutableAttributeSet 实现,所以可采用不同的 AttributeSet 压缩技术。要返回负责实现所需压缩技术的对象,则应该实现 getAttributeContext 方法。

另请参见:
StyleContext

方法摘要
 AttributeSet addAttribute(AttributeSet old, Object name, Object value)
          向给定属性集中添加一个属性,并返回新的有代表性的属性集。
 AttributeSet addAttributes(AttributeSet old, AttributeSet attr)
          向元素添加一组属性。
 AttributeSet getEmptySet()
          获取一个空的 AttributeSet。
 void reclaim(AttributeSet a)
          回收某个属性集。
 AttributeSet removeAttribute(AttributeSet old, Object name)
          从属性集中移除某个属性。
 AttributeSet removeAttributes(AttributeSet old, AttributeSet attrs)
          移除元素的一组属性。
 AttributeSet removeAttributes(AttributeSet old, Enumeration<?> names)
          移除元素的一组属性。
 

方法详细信息

addAttribute

AttributeSet addAttribute(AttributeSet old,
                          Object name,
                          Object value)
向给定属性集中添加一个属性,并返回新的有代表性的属性集。

参数:
old - 旧的属性集
name - 非 null 的属性名
value - 属性值
返回:
已更新的属性集
另请参见:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)

addAttributes

AttributeSet addAttributes(AttributeSet old,
                           AttributeSet attr)
向元素添加一组属性。

参数:
old - 旧的属性集
attr - 要添加的属性
返回:
已更新的属性集
另请参见:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)

removeAttribute

AttributeSet removeAttribute(AttributeSet old,
                             Object name)
从属性集中移除某个属性。

参数:
old - 旧的属性集
name - 非 null 的属性名
返回:
已更新的属性集
另请参见:
MutableAttributeSet.removeAttribute(java.lang.Object)

removeAttributes

AttributeSet removeAttributes(AttributeSet old,
                              Enumeration<?> names)
移除元素的一组属性。

参数:
old - 旧的属性集
names - 属性名
返回:
已更新的属性集
另请参见:
MutableAttributeSet.removeAttributes(java.util.Enumeration)

removeAttributes

AttributeSet removeAttributes(AttributeSet old,
                              AttributeSet attrs)
移除元素的一组属性。

参数:
old - 旧的属性集
attrs - 属性
返回:
已更新的属性集
另请参见:
MutableAttributeSet.removeAttributes(java.util.Enumeration)

getEmptySet

AttributeSet getEmptySet()
获取一个空的 AttributeSet。

返回:
属性集

reclaim

void reclaim(AttributeSet a)
回收某个属性集。这是 MutableAttributeSet 标记其不再需要特定的、不可变的属性集的一种方式。仅在 1.1 版本中才必需使用此方法,因为该版本中没有弱引用。1.1 版本的实现将在其 finalize 方法中调用此方法。

参数:
a - 要回收的属性集

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策