java.lang.Object
javax.swing.text.AbstractDocument.AbstractElement
- 所有已实现的接口:
-
Serializable,AttributeSet,Element,MutableAttributeSet,TreeNode
- 封装类:
-
AbstractDocument
public abstract class AbstractDocument.AbstractElement extends Object implements Element, MutableAttributeSet, Serializable, TreeNode
实现元素的抽象部分。默认情况下,元素通过具有表示元素当前属性集的不可变部分的字段来支持属性。元素本身实现了MutableAttributeSet,可以通过获取新的不可变集合来修改集合。不可变集合由与文档关联的AttributeContext提供。
警告: 该类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4开始,已将所有JavaBeans的长期存储支持添加到java.beans包中。请参见XMLEncoder。
-
Nested Class Summary
Nested classes/interfaces declared in interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute -
Field Summary
Fields declared in interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(Object name, Object value) 向元素添加属性。voidaddAttributes(AttributeSet attr) 向元素添加一组属性。abstract Enumeration<TreeNode> children()将接收器的子项作为Enumeration返回。booleancontainsAttribute(Object name, Object value) 检查给定的属性名称/值是否已定义。booleancontainsAttributes(AttributeSet attrs) 检查元素是否包含所有属性。复制一组属性。voiddump(PrintStream psOut, int indentAmount) 转储元素层次结构的调试表示。abstract boolean如果接收器允许子项,则返回true。getAttribute(Object attrName) 获取属性的值。int获取已定义的属性数量。Enumeration<?> 获取所有属性的名称。获取元素的属性。getChildAt(int childIndex) 返回索引childIndex处的子TreeNode。int返回接收器包含的子TreeNode的数量。检索基础模型。abstract ElementgetElement(int index) 获取子元素。abstract int获取元素的子项数。abstract intgetElementIndex(int offset) 获取最接近给定模型偏移量的子元素索引。abstract int获取元素在模型中的结束偏移量。int返回接收器子项中node的索引。getName()获取元素的名称。返回接收器的父TreeNode。获取元素的父元素。获取解析父级。abstract int获取元素在模型中的起始偏移量。boolean检查给定的属性是否已定义。booleanisEqual(AttributeSet attr) 检查两个属性集是否相等。abstract booleanisLeaf()检查元素是否为叶子。voidremoveAttribute(Object name) 从集合中删除一个属性。voidremoveAttributes(Enumeration<?> names) 删除元素的一组属性。voidremoveAttributes(AttributeSet attrs) 删除元素的一组属性。voidsetResolveParent(AttributeSet parent) 设置解析父级。
-
Constructor Details
-
AbstractElement
创建一个新的AbstractElement。- 参数:
-
parent- 父元素 -
a- 元素的属性 - 自1.4版本起:
- 1.4
-
-
Method Details
-
dump
转储元素层次结构的调试表示。- 参数:
-
psOut- 输出流 -
indentAmount- 缩进级别 >= 0
-
getAttributeCount
public int getAttributeCount()获取已定义的属性数量。- 指定者:
-
getAttributeCount在接口AttributeSet中 - 返回:
- 属性数量 >= 0
- 参见:
-
isDefined
检查给定的属性是否已定义。- 指定者:
-
isDefined在接口AttributeSet中 - 参数:
-
attrName- 非空属性名称 - 返回:
- 如果属性已定义,则为true
- 参见:
-
isEqual
检查两个属性集是否相等。- 指定者:
-
isEqual在接口AttributeSet中 - 参数:
-
attr- 要检查的属性集 - 返回:
- 如果相同,则为true
- 参见:
-
copyAttributes
复制一组属性。- 指定者:
-
copyAttributes在接口AttributeSet中 - 返回:
- 复制品
- 参见:
-
getAttribute
获取属性的值。- 指定者:
-
getAttribute在接口AttributeSet中 - 参数:
-
attrName- 非空属性名称 - 返回:
- 属性值
- 参见:
-
getAttributeNames
获取所有属性的名称。- 指定者:
-
getAttributeNames在接口AttributeSet中 - 返回:
- 属性名称的枚举
- 参见:
-
containsAttribute
检查给定的属性名称/值是否已定义。- 指定者:
-
containsAttribute在接口AttributeSet中 - 参数:
-
name- 非空属性名称 -
value- 属性值 - 返回:
- 如果名称/值已定义,则为true
- 参见:
-
containsAttributes
检查元素是否包含所有属性。- 指定者:
-
containsAttributes在接口AttributeSet中 - 参数:
-
attrs- 要检查的属性 - 返回:
- 如果元素包含所有属性,则为true
- 参见:
-
getResolveParent
获取解析父级。如果未重写,则解析父级默认为父元素。- 指定者:
-
getResolveParent在接口AttributeSet中 - 返回:
-
父级的属性,如果没有则为
null - 参见:
-
addAttribute
向元素添加属性。- 指定者:
-
addAttribute在接口MutableAttributeSet中 - 参数:
-
name- 非空属性名称 -
value- 属性值 - 参见:
-
addAttributes
向元素添加一组属性。- 指定者:
-
addAttributes在接口MutableAttributeSet中 - 参数:
-
attr- 要添加的属性 - 参见:
-
removeAttribute
从集合中移除一个属性。- 指定者:
-
removeAttribute在接口MutableAttributeSet中 - 参数:
-
name- 非空属性名称 - 参见:
-
removeAttributes
为元素移除一组属性。- 指定者:
-
removeAttributes在接口MutableAttributeSet中 - 参数:
-
names- 属性名称 - 参见:
-
removeAttributes
为元素移除一组属性。- 指定者:
-
removeAttributes在接口MutableAttributeSet中 - 参数:
-
attrs- 属性 - 参见:
-
setResolveParent
设置解析父级。- 指定者:
-
setResolveParent在接口MutableAttributeSet中 - 参数:
-
parent- 父级,如果没有则为null - 参见:
-
getDocument
检索基础模型。- 指定者:
-
getDocument在接口Element中 - 返回:
- 模型
-
getParentElement
获取元素的父级。- 指定者:
-
getParentElement在接口Element中 - 返回:
- 父级
-
getAttributes
获取元素的属性。- 指定者:
-
getAttributes在接口Element中 - 返回:
- 属性集
-
getName
获取元素的名称。 -
getStartOffset
public abstract int getStartOffset()获取元素在模型中的起始偏移量。- 指定者:
-
getStartOffset在接口Element中 - 返回:
- 偏移量 >= 0
- 参见:
-
getEndOffset
public abstract int getEndOffset()获取元素在模型中的结束偏移量。- 指定者:
-
getEndOffset在接口Element中 - 返回:
- 偏移量 >= 0
- 参见:
-
getElement
获取子元素。- 指定者:
-
getElement在接口Element中 - 参数:
-
index- 子索引,>= 0 && < getElementCount() - 返回:
- 子元素
-
getElementCount
public abstract int getElementCount()获取元素的子元素数量。- 指定者:
-
getElementCount在接口Element中 - 返回:
- 子元素数量 >= 0
-
getElementIndex
public abstract int getElementIndex(int offset) 获取最接近给定模型偏移量的子元素索引。- 指定者:
-
getElementIndex在接口Element中 - 参数:
-
offset- 偏移量 >= 0 - 返回:
- 元素索引 >= 0
-
isLeaf
public abstract boolean isLeaf()检查元素是否为叶子节点。 -
getChildAt
返回索引为childIndex的子TreeNode。- 指定者:
-
getChildAt在接口TreeNode中 - 参数:
-
childIndex- 子索引 - 返回:
- 给定索引处的子节点
-
getChildCount
public int getChildCount()返回接收者包含的TreeNode的数量。- 指定者:
-
getChildCount在接口TreeNode中 - 返回:
-
接收者包含的
TreeNode的数量
-
getParent
返回接收者的父级TreeNode。 -
getIndex
返回接收者子节点中node的索引。如果接收者不包含node,则返回-1。 -
getAllowsChildren
public abstract boolean getAllowsChildren()如果接收者允许子节点,则返回true。- 指定者:
-
getAllowsChildren在接口TreeNode中 - 返回:
- 如果接收者允许子节点,则为true,否则为false
-
children
返回接收者的子节点作为一个Enumeration。
-