JavaTM Platform
Standard Ed. 6

javax.swing.text
类 AbstractDocument.BranchElement

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

public class AbstractDocument.BranchElement
     
extends AbstractDocument.AbstractElement

实现一个包含其他元素的复合元素。

警告:此类的已序列化对象与以后的 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.BranchElement(Element parent, AttributeSet a)
          构造最初不包含任何子元素的复合元素。
 
方法摘要
 Enumeration children()
          以 Enumeration 的形式返回接收者的子级。
 boolean getAllowsChildren()
          如果接收者允许接收子元素,则返回 true。
 Element getElement(int index)
          获得一个子元素。
 int getElementCount()
          获得该元素的子元素数。
 int getElementIndex(int offset)
          获得与给定模型偏移量最接近的子元素索引。
 int getEndOffset()
          获得模型中该元素的结束偏移量。
 String getName()
          获得元素名。
 int getStartOffset()
          获得模型中该元素的起始偏移量。
 boolean isLeaf()
          检查该元素是否为叶元素。
 Element positionToElement(int pos)
          获得包含给定模型位置的子元素。
 void replace(int offset, int length, Element[] elems)
          使用新的元素集替换该内容。
 String toString()
          将该元素转换为字符串。
 
从类 javax.swing.text.AbstractDocument.AbstractElement 继承的方法
addAttribute, addAttributes, containsAttribute, containsAttributes, copyAttributes, dump, getAttribute, getAttributeCount, getAttributeNames, getAttributes, getChildAt, getChildCount, getDocument, getIndex, getParent, getParentElement, getResolveParent, isDefined, isEqual, removeAttribute, removeAttributes, removeAttributes, setResolveParent
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

AbstractDocument.BranchElement

public AbstractDocument.BranchElement(Element parent,
                                      AttributeSet a)
构造最初不包含任何子元素的复合元素。

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

positionToElement

public Element positionToElement(int pos)
获得包含给定模型位置的子元素。

参数:
pos - 位置,该位置 >= 0
返回:
元素,如果没有,则返回 null

replace

public void replace(int offset,
                    int length,
                    Element[] elems)
使用新的元素集替换该内容。

参数:
offset - 起始偏移量,该偏移量 >= 0
length - 要替换的长度,该长度 >= 0
elems - 新元素

toString

public String toString()
将该元素转换为字符串。

覆盖:
Object 中的 toString
返回:
字符串

getName

public String getName()
获得元素名。

指定者:
接口 Element 中的 getName
覆盖:
AbstractDocument.AbstractElement 中的 getName
返回:
元素名

getStartOffset

public int getStartOffset()
获得模型中该元素的起始偏移量。

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

getEndOffset

public int getEndOffset()
获得模型中该元素的结束偏移量。

指定者:
接口 Element 中的 getEndOffset
指定者:
AbstractDocument.AbstractElement 中的 getEndOffset
返回:
偏移量,该偏移量 >= 0
抛出:
NullPointerException - 如果此元素没有子元素
另请参见:
Document, AbstractDocument

getElement

public Element getElement(int index)
获得一个子元素。

指定者:
接口 Element 中的 getElement
指定者:
AbstractDocument.AbstractElement 中的 getElement
参数:
index - 子元素的索引,该索引 >= 0 && < getElementCount()
返回:
子元素,如果没有,则返回 null

getElementCount

public int getElementCount()
获得该元素的子元素数。

指定者:
接口 Element 中的 getElementCount
指定者:
AbstractDocument.AbstractElement 中的 getElementCount
返回:
子元素数,该数 >= 0

getElementIndex

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

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

isLeaf

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

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

getAllowsChildren

public boolean getAllowsChildren()
如果接收者允许接收子元素,则返回 true。

指定者:
接口 TreeNode 中的 getAllowsChildren
指定者:
AbstractDocument.AbstractElement 中的 getAllowsChildren
返回:
如果接收者允许接收子元素,则返回 true;否则返回 false

children

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

指定者:
接口 TreeNode 中的 children
指定者:
AbstractDocument.AbstractElement 中的 children
返回:
接收者的子级

JavaTM Platform
Standard Ed. 6

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

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