This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.text
class AbstractDocument.AbstractElement

java.lang.Object extended by javax.swing.text.AbstractDocument.AbstractElement
All Implemented Interfaces:
Serializable, 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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Constructor Summary

          Creates a new AbstractElement.
 
Method Summary
 void
addAttribute(Object name, Object value)

          Adds an attribute to the element.
 void

          Adds a set of attributes to the element.
abstract Enumeration

          Returns the children of the receiver as an Enumeration.
 boolean

          Checks whether a given attribute name/value is defined.
 boolean

          Checks whether the element contains all the attributes.
 AttributeSet

          Copies a set of attributes.
 void
dump(PrintStream psOut, int indentAmount)

          Dumps a debugging representation of the element hierarchy.
abstract boolean

          Returns true if the receiver allows children.
 Object
getAttribute(Object attrName)

          Gets the value of an attribute.
 int

          Gets the number of attributes that are defined.
 Enumeration

          Gets the names of all attributes.
 AttributeSet

          Gets the attributes for the element.
 TreeNode
getChildAt(int childIndex)

          Returns the child TreeNode at index childIndex.
 int

          Returns the number of children TreeNode's receiver contains.
 Document

          Retrieves the underlying model.
abstract Element
getElement(int index)

          Gets a child element.
abstract int

          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

          Gets the ending offset in the model for the element.
 int

          Returns the index of node in the receivers children.
 String

          Gets the name of the element.
 TreeNode

          Returns the parent TreeNode of the receiver.
 Element

          Gets the parent of the element.
 AttributeSet

          Gets the resolving parent.
abstract int

          Gets the starting offset in the model for the element.
 boolean
isDefined(Object attrName)

          Checks whether a given attribute is defined.
 boolean

          Checks whether two attribute sets are equal.
abstract boolean

          Checks whether the element is a leaf.
 void

          Removes an attribute from the set.
 void

          Removes a set of attributes for the element.
 void

          Removes a set of attributes for the element.
 void

          Sets the resolving parent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDocument.AbstractElement

public AbstractDocument.AbstractElement(Element parent,
                                        AttributeSet a)
Creates a new AbstractElement.

Parameters:
parent - the parent element
a - the attributes for the element
Method Detail

addAttribute

public void addAttribute(Object name,
                         Object value)
Adds an attribute to the element.

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

addAttributes

public void addAttributes(AttributeSet attr)
Adds a set of attributes to the element.

Parameters:
attr - the attributes to add

children

public abstract Enumeration children()
Returns the children of the receiver as an Enumeration.

Returns:
the children of the receiver as an Enumeration

containsAttribute

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

containsAttributes

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

copyAttributes

public AttributeSet copyAttributes()
Copies a set of attributes.

Returns:
the copy

dump

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

getAllowsChildren

public abstract boolean getAllowsChildren()
Returns true if the receiver allows children.

Returns:
true if the receiver allows children, otherwise false

getAttribute

public Object getAttribute(Object attrName)
Gets the value of an attribute.

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

getAttributeCount

public int getAttributeCount()
Gets the number of attributes that are defined.

Returns:
the number of attributes >= 0

getAttributeNames

public Enumeration getAttributeNames()
Gets the names of all attributes.

Returns:
the attribute names as an enumeration

getAttributes

public AttributeSet getAttributes()
Gets the attributes for the element.

Returns:
the attribute set

getChildAt

public TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex.

Parameters:
childIndex

getChildCount

public int getChildCount()
Returns the number of children TreeNode's receiver contains.

Returns:
the number of children TreeNodews's receiver contains

getDocument

public Document getDocument()
Retrieves the underlying model.

Returns:
the model

getElement

public abstract Element getElement(int index)
Gets a child element.

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

getElementCount

public abstract int getElementCount()
Gets the number of children for the element.

Returns:
the number of children >= 0

getElementIndex

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

getEndOffset

public abstract int getEndOffset()
Gets the ending offset in the model for the element.

Returns:
the offset >= 0

getIndex

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

getName

public String getName()
Gets the name of the element.

Returns:
the name, null if none

getParent

public TreeNode getParent()
Returns the parent TreeNode of the receiver.

Returns:
the parent TreeNode of the receiver

getParentElement

public Element getParentElement()
Gets the parent of the element.

Returns:
the parent

getResolveParent

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

getStartOffset

public abstract int getStartOffset()
Gets the starting offset in the model for the element.

Returns:
the offset >= 0

isDefined

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

isEqual

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

isLeaf

public abstract boolean isLeaf()
Checks whether the element is a leaf.

Returns:
true if a leaf

removeAttribute

public void removeAttribute(Object name)
Removes an attribute from the set.

Parameters:
name - the non-null attribute name

removeAttributes

public void removeAttributes(AttributeSet attrs)
Removes a set of attributes for the element.

Parameters:
attrs - the attributes

removeAttributes

public void removeAttributes(Enumeration names)
Removes a set of attributes for the element.

Parameters:
names - the attribute names

setResolveParent

public void setResolveParent(AttributeSet parent)
Sets the resolving parent.

Parameters:
parent - the parent, null if none


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.