JavaTM Platform
Standard Ed. 6

javax.swing.text
类 AbstractDocument.AbstractElement

java.lang.Object
  继承者 javax.swing.text.AbstractDocument.AbstractElement
所有已实现的接口:
Serializable, AttributeSet, Element, MutableAttributeSet, TreeNode
直接已知子类:
AbstractDocument.BranchElement, AbstractDocument.LeafElement
正在封闭类:
AbstractDocument

public abstract class AbstractDocument.AbstractElement
extends Object
implements Element, MutableAttributeSet, Serializable, TreeNode

实现元素的抽象部分。默认情况下,通过提供表示该元素当前属性集合的不可变部分的字段,元素支持这些属性。该元素本身可以实现 MutableAttributeSet,后者可以通过获取新的不可变集合来修改该集合。这些不可变集合是由与此文档相关的 AttributeContext 提供的。

警告:此类的序列化对象将与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder


嵌套类摘要
 
从接口 javax.swing.text.AttributeSet 继承的嵌套类/接口
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
 
字段摘要
 
从接口 javax.swing.text.AttributeSet 继承的字段
NameAttribute, ResolveAttribute
 
构造方法摘要
AbstractDocument.AbstractElement(Element parent, AttributeSet a)
          创建新的 AbstractElement。
 
方法摘要
 void addAttribute(Object name, Object value)
          向该元素添加一个属性。
 void addAttributes(AttributeSet attr)
          向该元素添加一个属性集合。
abstract  Enumeration children()
          以 Enumeration 形式返回接收方的子级。
 boolean containsAttribute(Object name, Object value)
          检查是否定义了给定的属性名称/值。
 boolean containsAttributes(AttributeSet attrs)
          检查该元素是否包含所有的属性。
 AttributeSet copyAttributes()
          复制属性集合。
 void dump(PrintStream psOut, int indentAmount)
          转储该元素层次结构的调试表示形式。
abstract  boolean getAllowsChildren()
          如果接收方允许有子级,则返回 true。
 Object getAttribute(Object attrName)
          获取属性值。
 int getAttributeCount()
          获取所定义的属性数量。
 Enumeration<?> getAttributeNames()
          获取所有属性的名称。
 AttributeSet getAttributes()
          获取该元素的属性。
 TreeNode getChildAt(int childIndex)
          在索引 childIndex 处返回子级 TreeNode
 int getChildCount()
          返回接受方所包含的子级 TreeNode 的数量。
 Document getDocument()
          获得基础模型。
abstract  Element getElement(int index)
          获取子元素。
abstract  int getElementCount()
          获取该元素子级的数量。
abstract  int getElementIndex(int offset)
          获取最接近给定模型偏移量的子元素索引。
abstract  int getEndOffset()
          获取该元素在此模型中的终止偏移量。
 int getIndex(TreeNode node)
          返回接收方子级中 node 的索引。
 String getName()
          获取该元素的名称。
 TreeNode getParent()
          返回接收方的父级 TreeNode
 Element getParentElement()
          获取该元素的父级。
 AttributeSet getResolveParent()
          获取要解析的父级。
abstract  int getStartOffset()
          获取该元素在此模型中的起始偏移量。
 boolean isDefined(Object attrName)
          检查是否定义了给定的属性。
 boolean isEqual(AttributeSet attr)
          检查两个属性集合是否相等。
abstract  boolean isLeaf()
          检查该元素是否为叶元素。
 void removeAttribute(Object name)
          从该集合中移除一个属性。
 void removeAttributes(AttributeSet attrs)
          移除该元素的属性集合。
 void removeAttributes(Enumeration<?> names)
          移除该元素的属性集合。
 void setResolveParent(AttributeSet parent)
          设置要解析的父级。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

AbstractDocument.AbstractElement

public AbstractDocument.AbstractElement(Element parent,
                                        AttributeSet a)
创建新的 AbstractElement。

参数:
parent - 父元素
a - 该元素的属性
从以下版本开始:
1.4
方法详细信息

dump

public void dump(PrintStream psOut,
                 int indentAmount)
转储该元素层次结构的调试表示形式。

参数:
psOut - 输出流
indentAmount - 缩进级别 >= 0

getAttributeCount

public int getAttributeCount()
获取所定义的属性数量。

指定者:
接口 AttributeSet 中的 getAttributeCount
返回:
属性数量 >= 0
另请参见:
AttributeSet.getAttributeCount()

isDefined

public boolean isDefined(Object attrName)
检查是否定义了给定的属性。

指定者:
接口 AttributeSet 中的 isDefined
参数:
attrName - 非 null 属性的名称
返回:
如果定义了属性,则返回 true
另请参见:
AttributeSet.isDefined(java.lang.Object)

isEqual

public boolean isEqual(AttributeSet attr)
检查两个属性集合是否相等。

指定者:
接口 AttributeSet 中的 isEqual
参数:
attr - 要检查的属性集合
返回:
如果相同,则返回 true
另请参见:
AttributeSet.isEqual(javax.swing.text.AttributeSet)

copyAttributes

public AttributeSet copyAttributes()
复制属性集合。

指定者:
接口 AttributeSet 中的 copyAttributes
返回:
副本
另请参见:
AttributeSet.copyAttributes()

getAttribute

public Object getAttribute(Object attrName)
获取属性值。

指定者:
接口 AttributeSet 中的 getAttribute
参数:
attrName - 非 null 属性名称
返回:
属性值
另请参见:
AttributeSet.getAttribute(java.lang.Object)

getAttributeNames

public Enumeration<?> getAttributeNames()
获取所有属性的名称。

指定者:
接口 AttributeSet 中的 getAttributeNames
返回:
枚举形式的属性名称
另请参见:
AttributeSet.getAttributeNames()

containsAttribute

public boolean containsAttribute(Object name,
                                 Object value)
检查是否定义了给定的属性名称/值。

指定者:
接口 AttributeSet 中的 containsAttribute
参数:
name - 非 null 属性名称
value - 属性值
返回:
如果定义了名称/值,则返回 true
另请参见:
AttributeSet.containsAttribute(java.lang.Object, java.lang.Object)

containsAttributes

public boolean containsAttributes(AttributeSet attrs)
检查该元素是否包含所有的属性。

指定者:
接口 AttributeSet 中的 containsAttributes
参数:
attr - 要检查的属性
返回:
如果该元素包含所有的属性,则返回 true
另请参见:
AttributeSet.containsAttributes(javax.swing.text.AttributeSet)

getResolveParent

public AttributeSet getResolveParent()
获取要解析的父级。如果未重写,则要解析的父级默认为父元素。

指定者:
接口 AttributeSet 中的 getResolveParent
返回:
父级中的属性,如果不存在,则返回 null
另请参见:
AttributeSet.getResolveParent()

addAttribute

public void addAttribute(Object name,
                         Object value)
向该元素添加一个属性。

指定者:
接口 MutableAttributeSet 中的 addAttribute
参数:
name - 非 null 属性名称
value - 属性值
另请参见:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)

addAttributes

public void addAttributes(AttributeSet attr)
向该元素添加一个属性集合。

指定者:
接口 MutableAttributeSet 中的 addAttributes
参数:
attr - 要添加的属性
另请参见:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)

removeAttribute

public void removeAttribute(Object name)
从该集合中移除一个属性。

指定者:
接口 MutableAttributeSet 中的 removeAttribute
参数:
name - 非 null 属性名称
另请参见:
MutableAttributeSet.removeAttribute(java.lang.Object)

removeAttributes

public void removeAttributes(Enumeration<?> names)
移除该元素的属性集合。

指定者:
接口 MutableAttributeSet 中的 removeAttributes
参数:
names - 属性名称
另请参见:
MutableAttributeSet.removeAttributes(java.util.Enumeration)

removeAttributes

public void removeAttributes(AttributeSet attrs)
移除该元素的属性集合。

指定者:
接口 MutableAttributeSet 中的 removeAttributes
参数:
attr - 属性
另请参见:
MutableAttributeSet.removeAttributes(java.util.Enumeration)

setResolveParent

public void setResolveParent(AttributeSet parent)
设置要解析的父级。

指定者:
接口 MutableAttributeSet 中的 setResolveParent
参数:
parent - 父级,如果不存在,则返回 null
另请参见:
MutableAttributeSet.setResolveParent(javax.swing.text.AttributeSet)

getDocument

public Document getDocument()
获得基础模型。

指定者:
接口 Element 中的 getDocument
返回:
模型

getParentElement

public Element getParentElement()
获取该元素的父级。

指定者:
接口 Element 中的 getParentElement
返回:
父级

getAttributes

public AttributeSet getAttributes()
获取该元素的属性。

指定者:
接口 Element 中的 getAttributes
返回:
属性集合

getName

public String getName()
获取该元素的名称。

指定者:
接口 Element 中的 getName
返回:
名称,如果不存在,则返回 null

getStartOffset

public abstract int getStartOffset()
获取该元素在此模型中的起始偏移量。

指定者:
接口 Element 中的 getStartOffset
返回:
偏移量 >= 0
另请参见:
Document, AbstractDocument

getEndOffset

public abstract int getEndOffset()
获取该元素在此模型中的终止偏移量。

指定者:
接口 Element 中的 getEndOffset
返回:
偏移量 >= 0
另请参见:
Document, AbstractDocument

getElement

public abstract Element getElement(int index)
获取子元素。

指定者:
接口 Element 中的 getElement
参数:
index - 子索引,其值 >= 0 && < getElementCount()
返回:
子元素

getElementCount

public abstract int getElementCount()
获取该元素子级的数量。

指定者:
接口 Element 中的 getElementCount
返回:
子级的数量 >= 0

getElementIndex

public abstract int getElementIndex(int offset)
获取最接近给定模型偏移量的子元素索引。

指定者:
接口 Element 中的 getElementIndex
参数:
offset - 偏移量 >= 0
返回:
元素索引 >= 0

isLeaf

public abstract boolean isLeaf()
检查该元素是否为叶元素。

指定者:
接口 Element 中的 isLeaf
指定者:
接口 TreeNode 中的 isLeaf
返回:
如果是叶元素,则返回 true

getChildAt

public TreeNode getChildAt(int childIndex)
在索引 childIndex 处返回子级 TreeNode

指定者:
接口 TreeNode 中的 getChildAt

getChildCount

public int getChildCount()
返回接受方所包含的子级 TreeNode 的数量。

指定者:
接口 TreeNode 中的 getChildCount
返回:
接受方所包含的子级 TreeNodews 的数量

getParent

public TreeNode getParent()
返回接收方的父级 TreeNode

指定者:
接口 TreeNode 中的 getParent
返回:
接收方的父级 TreeNode

getIndex

public int getIndex(TreeNode node)
返回接收方子级中 node 的索引。如果接收方中不包含 node,将返回 -1。

指定者:
接口 TreeNode 中的 getIndex
参数:
node - 感兴趣的位置
返回:
接收方的子级中 node 的索引,如果不存在,则返回 -1

getAllowsChildren

public abstract boolean getAllowsChildren()
如果接收方允许有子级,则返回 true。

指定者:
接口 TreeNode 中的 getAllowsChildren
返回:
如果接收方允许有子级,则返回 true,否则返回 false

children

public abstract Enumeration children()
Enumeration 形式返回接收方的子级。

指定者:
接口 TreeNode 中的 children
返回:
接收方的 Enumeration 形式的子级

JavaTM Platform
Standard Ed. 6

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

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