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
.
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
NameAttribute, ResolveAttribute
public AbstractElement(Element parent, AttributeSet a)
Creates a new AbstractElement.
parent
- the parent elementa
- the attributes for the elementpublic void dump(PrintStream psOut, int indentAmount)
Dumps a debugging representation of the element hierarchy.
psOut
- the output streamindentAmount
- the indentation level >= 0public int getAttributeCount()
Gets the number of attributes that are defined.
getAttributeCount
in interface AttributeSet
AttributeSet.getAttributeCount()
public boolean isDefined(Object attrName)
Checks whether a given attribute is defined.
isDefined
in interface AttributeSet
attrName
- the non-null attribute nameAttributeSet.isDefined(java.lang.Object)
public boolean isEqual(AttributeSet attr)
Checks whether two attribute sets are equal.
isEqual
in interface AttributeSet
attr
- the attribute set to check againstAttributeSet.isEqual(javax.swing.text.AttributeSet)
public AttributeSet copyAttributes()
Copies a set of attributes.
copyAttributes
in interface AttributeSet
AttributeSet.copyAttributes()
public Object getAttribute(Object attrName)
Gets the value of an attribute.
getAttribute
in interface AttributeSet
attrName
- the non-null attribute nameAttributeSet.getAttribute(java.lang.Object)
public Enumeration<?> getAttributeNames()
Gets the names of all attributes.
getAttributeNames
in interface AttributeSet
AttributeSet.getAttributeNames()
public boolean containsAttribute(Object name, Object value)
Checks whether a given attribute name/value is defined.
containsAttribute
in interface AttributeSet
name
- the non-null attribute namevalue
- the attribute valueAttributeSet.containsAttribute(java.lang.Object, java.lang.Object)
public boolean containsAttributes(AttributeSet attrs)
Checks whether the element contains all the attributes.
containsAttributes
in interface AttributeSet
attrs
- the attributes to checkAttributeSet.containsAttributes(javax.swing.text.AttributeSet)
public AttributeSet getResolveParent()
Gets the resolving parent. If not overridden, the resolving parent defaults to the parent element.
getResolveParent
in interface AttributeSet
null
if noneAttributeSet.getResolveParent()
public void addAttribute(Object name, Object value)
Adds an attribute to the element.
addAttribute
in interface MutableAttributeSet
name
- the non-null attribute namevalue
- the attribute valueMutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
public void addAttributes(AttributeSet attr)
Adds a set of attributes to the element.
addAttributes
in interface MutableAttributeSet
attr
- the attributes to addMutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
public void removeAttribute(Object name)
Removes an attribute from the set.
removeAttribute
in interface MutableAttributeSet
name
- the non-null attribute nameMutableAttributeSet.removeAttribute(java.lang.Object)
public void removeAttributes(Enumeration<?> names)
Removes a set of attributes for the element.
removeAttributes
in interface MutableAttributeSet
names
- the attribute namesMutableAttributeSet.removeAttributes(java.util.Enumeration<?>)
public void removeAttributes(AttributeSet attrs)
Removes a set of attributes for the element.
removeAttributes
in interface MutableAttributeSet
attrs
- the attributesMutableAttributeSet.removeAttributes(java.util.Enumeration<?>)
public void setResolveParent(AttributeSet parent)
Sets the resolving parent.
setResolveParent
in interface MutableAttributeSet
parent
- the parent, null if noneMutableAttributeSet.setResolveParent(javax.swing.text.AttributeSet)
public Document getDocument()
Retrieves the underlying model.
getDocument
in interface Element
public Element getParentElement()
Gets the parent of the element.
getParentElement
in interface Element
public AttributeSet getAttributes()
Gets the attributes for the element.
getAttributes
in interface Element
public String getName()
Gets the name of the element.
public abstract int getStartOffset()
Gets the starting offset in the model for the element.
getStartOffset
in interface Element
Document
, AbstractDocument
public abstract int getEndOffset()
Gets the ending offset in the model for the element.
getEndOffset
in interface Element
Document
, AbstractDocument
public abstract Element getElement(int index)
Gets a child element.
getElement
in interface Element
index
- the child index, >= 0 && < getElementCount()public abstract int getElementCount()
Gets the number of children for the element.
getElementCount
in interface Element
public abstract int getElementIndex(int offset)
Gets the child element index closest to the given model offset.
getElementIndex
in interface Element
offset
- the offset >= 0public abstract boolean isLeaf()
Checks whether the element is a leaf.
isLeaf
in interface Element
isLeaf
in interface TreeNode
public TreeNode getChildAt(int childIndex)
Returns the child TreeNode
at index childIndex
.
getChildAt
in interface TreeNode
public int getChildCount()
Returns the number of children TreeNode
's receiver contains.
getChildCount
in interface TreeNode
TreeNodews
's receiver containspublic TreeNode getParent()
Returns the parent TreeNode
of the receiver.
public int getIndex(TreeNode node)
Returns the index of node
in the receivers children. If the receiver does not contain node
, -1 will be returned.
getIndex
in interface TreeNode
node
- the location of interestnode
in the receiver's children, or -1 if absentpublic abstract boolean getAllowsChildren()
Returns true if the receiver allows children.
getAllowsChildren
in interface TreeNode
public abstract Enumeration children()
Returns the children of the receiver as an Enumeration
.
children
in interface TreeNode
Enumeration
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.