public abstract class

AbstractDocument.AbstractElement

extends Object
implements Serializable Element MutableAttributeSet TreeNode
java.lang.Object
   ↳ javax.swing.text.AbstractDocument.AbstractElement
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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 JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

Summary

[Expand]
Inherited Fields
From interface javax.swing.text.AttributeSet
Public Constructors
AbstractDocument.AbstractElement(Element parent, AttributeSet a)
Creates a new AbstractElement.
Public Methods
void addAttribute(Object name, Object value)
Adds an attribute to the element.
void addAttributes(AttributeSet attr)
Adds a set of attributes to the element.
abstract Enumeration children()
Returns the children of the receiver as an Enumeration.
boolean containsAttribute(Object name, Object value)
Checks whether a given attribute name/value is defined.
boolean containsAttributes(AttributeSet attrs)
Checks whether the element contains all the attributes.
AttributeSet copyAttributes()
Copies a set of attributes.
void dump(PrintStream psOut, int indentAmount)
Dumps a debugging representation of the element hierarchy.
abstract boolean getAllowsChildren()
Returns true if the receiver allows children.
Object getAttribute(Object attrName)
Gets the value of an attribute.
int getAttributeCount()
Gets the number of attributes that are defined.
Enumeration<?> getAttributeNames()
Gets the names of all attributes.
AttributeSet getAttributes()
Gets the attributes for the element.
TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex.
int getChildCount()
Returns the number of children TreeNode's receiver contains.
Document getDocument()
Retrieves the underlying model.
abstract Element getElement(int index)
Gets a child element.
abstract int getElementCount()
Gets the number of children for the element.
abstract int getElementIndex(int offset)
Gets the child element index closest to the given model offset.
abstract int getEndOffset()
Gets the ending offset in the model for the element.
int getIndex(TreeNode node)
Returns the index of node in the receivers children.
String getName()
Gets the name of the element.
TreeNode getParent()
Returns the parent TreeNode of the receiver.
Element getParentElement()
Gets the parent of the element.
AttributeSet getResolveParent()
Gets the resolving parent.
abstract int getStartOffset()
Gets the starting offset in the model for the element.
boolean isDefined(Object attrName)
Checks whether a given attribute is defined.
boolean isEqual(AttributeSet attr)
Checks whether two attribute sets are equal.
abstract boolean isLeaf()
Checks whether the element is a leaf.
void removeAttribute(Object name)
Removes an attribute from the set.
void removeAttributes(AttributeSet attrs)
Removes a set of attributes for the element.
void removeAttributes(Enumeration<?> names)
Removes a set of attributes for the element.
void setResolveParent(AttributeSet parent)
Sets the resolving parent.
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.swing.text.AttributeSet
From interface javax.swing.text.Element
From interface javax.swing.text.MutableAttributeSet
From interface javax.swing.tree.TreeNode

Public Constructors

public AbstractDocument.AbstractElement (Element parent, AttributeSet a)

Creates a new AbstractElement.

Parameters
parent the parent element
a the attributes for the element

Public Methods

public void addAttribute (Object name, Object value)

Adds an attribute to the element.

Parameters
name the non-null attribute name
value the attribute value

public void addAttributes (AttributeSet attr)

Adds a set of attributes to the element.

Parameters
attr the attributes to add

public abstract Enumeration children ()

Returns the children of the receiver as an Enumeration.

Returns
  • the children of the receiver as an Enumeration

public boolean containsAttribute (Object name, Object value)

Checks whether a given attribute name/value is defined.

Parameters
name the non-null attribute name
value the attribute value
Returns
  • true if the name/value is defined

public boolean containsAttributes (AttributeSet attrs)

Checks whether the element contains all the attributes.

Parameters
attrs the attributes to check
Returns
  • true if the element contains all the attributes

public AttributeSet copyAttributes ()

Copies a set of attributes.

Returns
  • the copy
See Also

public void dump (PrintStream psOut, int indentAmount)

Dumps a debugging representation of the element hierarchy.

Parameters
psOut the output stream
indentAmount the indentation level >= 0

public abstract boolean getAllowsChildren ()

Returns true if the receiver allows children.

Returns
  • true if the receiver allows children, otherwise false

public Object getAttribute (Object attrName)

Gets the value of an attribute.

Parameters
attrName the non-null attribute name
Returns
  • the attribute value

public int getAttributeCount ()

Gets the number of attributes that are defined.

Returns
  • the number of attributes >= 0

public Enumeration<?> getAttributeNames ()

Gets the names of all attributes.

Returns
  • the attribute names as an enumeration

public AttributeSet getAttributes ()

Gets the attributes for the element.

Returns
  • the attribute set

public TreeNode getChildAt (int childIndex)

Returns the child TreeNode at index childIndex.

public int getChildCount ()

Returns the number of children TreeNode's receiver contains.

Returns
  • the number of children TreeNodews's receiver contains

public Document getDocument ()

Retrieves the underlying model.

Returns
  • the model

public abstract Element getElement (int index)

Gets a child element.

Parameters
index the child index, >= 0 && < getElementCount()
Returns
  • the child element

public abstract int getElementCount ()

Gets the number of children for the element.

Returns
  • the number of children >= 0

public abstract int getElementIndex (int offset)

Gets the child element index closest to the given model offset.

Parameters
offset the offset >= 0
Returns
  • the element index >= 0

public abstract int getEndOffset ()

Gets the ending offset in the model for the element.

Returns
  • the offset >= 0

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.

Parameters
node the location of interest
Returns
  • the index of node in the receiver's children, or -1 if absent

public String getName ()

Gets the name of the element.

Returns
  • the name, null if none

public TreeNode getParent ()

Returns the parent TreeNode of the receiver.

Returns
  • the parent TreeNode of the receiver

public Element getParentElement ()

Gets the parent of the element.

Returns
  • the parent

public AttributeSet getResolveParent ()

Gets the resolving parent. If not overridden, the resolving parent defaults to the parent element.

Returns
  • the attributes from the parent, null if none

public abstract int getStartOffset ()

Gets the starting offset in the model for the element.

Returns
  • the offset >= 0

public boolean isDefined (Object attrName)

Checks whether a given attribute is defined.

Parameters
attrName the non-null attribute name
Returns
  • true if the attribute is defined

public boolean isEqual (AttributeSet attr)

Checks whether two attribute sets are equal.

Parameters
attr the attribute set to check against
Returns
  • true if the same

public abstract boolean isLeaf ()

Checks whether the element is a leaf.

Returns
  • true if a leaf

public void removeAttribute (Object name)

Removes an attribute from the set.

Parameters
name the non-null attribute name

public void removeAttributes (AttributeSet attrs)

Removes a set of attributes for the element.

Parameters
attrs the attributes

public void removeAttributes (Enumeration<?> names)

Removes a set of attributes for the element.

Parameters
names the attribute names

public void setResolveParent (AttributeSet parent)

Sets the resolving parent.

Parameters
parent the parent, null if none