java.lang.Object
javax.swing.text.AbstractDocument.AbstractElement
- All Implemented Interfaces:
- Serializable,- AttributeSet,- Element,- MutableAttributeSet,- TreeNode
- Direct Known Subclasses:
- AbstractDocument.BranchElement,- AbstractDocument.LeafElement
- Enclosing class:
- AbstractDocument
public abstract class AbstractDocument.AbstractElement
extends Object
implements Element, MutableAttributeSet, Serializable, TreeNode
Implements the abstract part of an element.  By default elements
 support attributes by having a field that represents the immutable
 part of the current attribute set for the element.  The element itself
 implements MutableAttributeSet which can be used to modify the set
 by fetching a new immutable set.  The immutable sets are provided
 by the AttributeContext associated with the document.
 
 Warning:
 Serialized objects of this class will not be compatible with
 future Swing releases. The current serialization support is
 appropriate for short term storage or RMI between applications running
 the same version of Swing.  As of 1.4, support for long term storage
 of all JavaBeans
 has been added to the java.beans package.
 Please see XMLEncoder.
- 
Nested Class SummaryNested classes/interfaces declared in interface javax.swing.text.AttributeSetAttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
- 
Field SummaryFields declared in interface javax.swing.text.AttributeSetNameAttribute, ResolveAttribute
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractElement(Element parent, AttributeSet a) Creates a new AbstractElement.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAttribute(Object name, Object value) Adds an attribute to the element.voidaddAttributes(AttributeSet attr) Adds a set of attributes to the element.abstract Enumeration<TreeNode> children()Returns the children of the receiver as anEnumeration.booleancontainsAttribute(Object name, Object value) Checks whether a given attribute name/value is defined.booleancontainsAttributes(AttributeSet attrs) Checks whether the element contains all the attributes.Copies a set of attributes.voiddump(PrintStream psOut, int indentAmount) Dumps a debugging representation of the element hierarchy.abstract booleanReturns true if the receiver allows children.getAttribute(Object attrName) Gets the value of an attribute.intGets the number of attributes that are defined.Enumeration<?> Gets the names of all attributes.Gets the attributes for the element.getChildAt(int childIndex) Returns the childTreeNodeat indexchildIndex.intReturns the number of childrenTreeNode's receiver contains.Retrieves the underlying model.abstract ElementgetElement(int index) Gets a child element.abstract intGets the number of children for the element.abstract intgetElementIndex(int offset) Gets the child element index closest to the given model offset.abstract intGets the ending offset in the model for the element.intReturns the index ofnodein the receivers children.getName()Gets the name of the element.Returns the parentTreeNodeof the receiver.Gets the parent of the element.Gets the resolving parent.abstract intGets the starting offset in the model for the element.booleanChecks whether a given attribute is defined.booleanisEqual(AttributeSet attr) Checks whether two attribute sets are equal.abstract booleanisLeaf()Checks whether the element is a leaf.voidremoveAttribute(Object name) Removes an attribute from the set.voidremoveAttributes(Enumeration<?> names) Removes a set of attributes for the element.voidremoveAttributes(AttributeSet attrs) Removes a set of attributes for the element.voidsetResolveParent(AttributeSet parent) Sets the resolving parent.
- 
Constructor Details- 
AbstractElementCreates a new AbstractElement.- Parameters:
- parent- the parent element
- a- the attributes for the element
- Since:
- 1.4
 
 
- 
- 
Method Details- 
dumpDumps a debugging representation of the element hierarchy.- Parameters:
- psOut- the output stream
- indentAmount- the indentation level >= 0
 
- 
getAttributeCountpublic int getAttributeCount()Gets the number of attributes that are defined.- Specified by:
- getAttributeCountin interface- AttributeSet
- Returns:
- the number of attributes >= 0
- See Also:
 
- 
isDefinedChecks whether a given attribute is defined.- Specified by:
- isDefinedin interface- AttributeSet
- Parameters:
- attrName- the non-null attribute name
- Returns:
- true if the attribute is defined
- See Also:
 
- 
isEqualChecks whether two attribute sets are equal.- Specified by:
- isEqualin interface- AttributeSet
- Parameters:
- attr- the attribute set to check against
- Returns:
- true if the same
- See Also:
 
- 
copyAttributesCopies a set of attributes.- Specified by:
- copyAttributesin interface- AttributeSet
- Returns:
- the copy
- See Also:
 
- 
getAttributeGets the value of an attribute.- Specified by:
- getAttributein interface- AttributeSet
- Parameters:
- attrName- the non-null attribute name
- Returns:
- the attribute value
- See Also:
 
- 
getAttributeNamesGets the names of all attributes.- Specified by:
- getAttributeNamesin interface- AttributeSet
- Returns:
- the attribute names as an enumeration
- See Also:
 
- 
containsAttributeChecks whether a given attribute name/value is defined.- Specified by:
- containsAttributein interface- AttributeSet
- Parameters:
- name- the non-null attribute name
- value- the attribute value
- Returns:
- true if the name/value is defined
- See Also:
 
- 
containsAttributesChecks whether the element contains all the attributes.- Specified by:
- containsAttributesin interface- AttributeSet
- Parameters:
- attrs- the attributes to check
- Returns:
- true if the element contains all the attributes
- See Also:
 
- 
getResolveParentGets the resolving parent. If not overridden, the resolving parent defaults to the parent element.- Specified by:
- getResolveParentin interface- AttributeSet
- Returns:
- the attributes from the parent, nullif none
- See Also:
 
- 
addAttributeAdds an attribute to the element.- Specified by:
- addAttributein interface- MutableAttributeSet
- Parameters:
- name- the non-null attribute name
- value- the attribute value
- See Also:
 
- 
addAttributesAdds a set of attributes to the element.- Specified by:
- addAttributesin interface- MutableAttributeSet
- Parameters:
- attr- the attributes to add
- See Also:
 
- 
removeAttributeRemoves an attribute from the set.- Specified by:
- removeAttributein interface- MutableAttributeSet
- Parameters:
- name- the non-null attribute name
- See Also:
 
- 
removeAttributesRemoves a set of attributes for the element.- Specified by:
- removeAttributesin interface- MutableAttributeSet
- Parameters:
- names- the attribute names
- See Also:
 
- 
removeAttributesRemoves a set of attributes for the element.- Specified by:
- removeAttributesin interface- MutableAttributeSet
- Parameters:
- attrs- the attributes
- See Also:
 
- 
setResolveParentSets the resolving parent.- Specified by:
- setResolveParentin interface- MutableAttributeSet
- Parameters:
- parent- the parent, null if none
- See Also:
 
- 
getDocumentRetrieves the underlying model.- Specified by:
- getDocumentin interface- Element
- Returns:
- the model
 
- 
getParentElementGets the parent of the element.- Specified by:
- getParentElementin interface- Element
- Returns:
- the parent
 
- 
getAttributesGets the attributes for the element.- Specified by:
- getAttributesin interface- Element
- Returns:
- the attribute set
 
- 
getNameGets the name of the element.
- 
getStartOffsetpublic abstract int getStartOffset()Gets the starting offset in the model for the element.- Specified by:
- getStartOffsetin interface- Element
- Returns:
- the offset >= 0
- See Also:
 
- 
getEndOffsetpublic abstract int getEndOffset()Gets the ending offset in the model for the element.- Specified by:
- getEndOffsetin interface- Element
- Returns:
- the offset >= 0
- See Also:
 
- 
getElementGets a child element.- Specified by:
- getElementin interface- Element
- Parameters:
- index- the child index, >= 0 && < getElementCount()
- Returns:
- the child element
 
- 
getElementCountpublic abstract int getElementCount()Gets the number of children for the element.- Specified by:
- getElementCountin interface- Element
- Returns:
- the number of children >= 0
 
- 
getElementIndexpublic abstract int getElementIndex(int offset) Gets the child element index closest to the given model offset.- Specified by:
- getElementIndexin interface- Element
- Parameters:
- offset- the offset >= 0
- Returns:
- the element index >= 0
 
- 
isLeafpublic abstract boolean isLeaf()Checks whether the element is a leaf.
- 
getChildAtReturns the childTreeNodeat indexchildIndex.- Specified by:
- getChildAtin interface- TreeNode
- Parameters:
- childIndex- index of child
- Returns:
- the child node at given index
 
- 
getChildCountpublic int getChildCount()Returns the number of childrenTreeNode's receiver contains.- Specified by:
- getChildCountin interface- TreeNode
- Returns:
- the number of children TreeNodews's receiver contains
 
- 
getParentReturns the parentTreeNodeof the receiver.
- 
getIndexReturns the index ofnodein the receivers children. If the receiver does not containnode, -1 will be returned.
- 
getAllowsChildrenpublic abstract boolean getAllowsChildren()Returns true if the receiver allows children.- Specified by:
- getAllowsChildrenin interface- TreeNode
- Returns:
- true if the receiver allows children, otherwise false
 
- 
childrenReturns the children of the receiver as anEnumeration.
 
-