# Class AbstractDocument.LeafElement

java.lang.Object
javax.swing.text.AbstractDocument.AbstractElement
javax.swing.text.AbstractDocument.LeafElement

All Implemented Interfaces:
  `Serializable, AttributeSet, Element, MutableAttributeSet, TreeNode`

Direct Known Subclasses:
  `HTMLDocument.RunElement`

Enclosing class:
  `AbstractDocument`

public class AbstractDocument.LeafElement extends AbstractDocument.AbstractElement
Implements an element that directly represents content of some kind.

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`.

See Also:
  - `Element`

## Nested Class Summary

### Nested classes/interfaces declared in interface AttributeSet

`AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute`
Modifier and Type
Interface
Description
`static interface`
`AttributeSet.CharacterAttribute`
This interface is the type signature that is expected to be present on any attribute key that contributes to character level presentation.
`static interface`
`AttributeSet.ColorAttribute`
This interface is the type signature that is expected to be present on any attribute key that contributes to presentation of color.
`static interface`
`AttributeSet.FontAttribute`
This interface is the type signature that is expected to be present on any attribute key that contributes to the determination of what font to use to render some text.
`static interface`
`AttributeSet.ParagraphAttribute`
This interface is the type signature that is expected to be present on any attribute key that contributes to the paragraph level presentation.

## Field Summary

### Fields declared in interface AttributeSet

`NameAttribute, ResolveAttribute`
Modifier and Type
Field
Description
`static final Object`
`NameAttribute`
Attribute name used to name the collection of attributes.
`static final Object`
`ResolveAttribute`
Attribute name used to identify the resolving parent set of attributes, if one is defined.

## Constructor Summary

Constructors
Constructor
Description
`LeafElement(Element parent, AttributeSet a, int offs0, int offs1)`
Constructs an element that represents content within the document (has no children).

## Method Summary

Modifier and Type
Method
Description
`Enumeration<TreeNode>`
`children()`
Returns the children of the receiver as an `Enumeration`.
`boolean`
`getAllowsChildren()`
Returns true if the receiver allows children.
`Element`
`getElement(int index)`
Gets a child element.
`int`
`getElementCount()`
Returns the number of child elements.
`int`
`getElementIndex(int pos)`
Gets the child element index closest to the given model offset.
`int`
`getEndOffset()`
Gets the ending offset in the model for the element.
`String`
`getName()`
Gets the element name.
`int`
`getStartOffset()`
Gets the starting offset in the model for the element.
`boolean`
`isLeaf()`
Checks whether the element is a leaf.
`String`
`toString()`
Converts the element to a string.

### Methods declared in class AbstractDocument.AbstractElement

`addAttribute, addAttributes, containsAttribute, containsAttributes, copyAttributes, dump, getAttribute, getAttributeCount, getAttributeNames, getAttributes, getChildAt, getChildCount, getDocument, getIndex, getParent, getParentElement, getResolveParent, isDefined, isEqual, removeAttribute, removeAttributes, removeAttributes, setResolveParent`
Modifier and Type
Method
Description
`void`
`addAttribute(Object name, Object value)`
Adds an attribute to the element.
`void`
`addAttributes(AttributeSet attr)`
Adds a set of attributes to the element.
`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.
`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.
`int`
`getIndex(TreeNode node)`
Returns the index of `node` in the receivers children.
`TreeNode`
`getParent()`
Returns the parent `TreeNode` of the receiver.
`Element`
`getParentElement()`
Gets the parent of the element.
`AttributeSet`
`getResolveParent()`
Gets the resolving parent.
`boolean`
`isDefined(Object attrName)`
Checks whether a given attribute is defined.
`boolean`
`isEqual(AttributeSet attr)`
Checks whether two attribute sets are equal.
`void`
`removeAttribute(Object name)`
Removes an attribute from the set.
`void`
`removeAttributes(Enumeration<?> names)`
Removes a set of attributes for the element.
`void`
`removeAttributes(AttributeSet attrs)`
Removes a set of attributes for the element.
`void`
`setResolveParent(AttributeSet parent)`
Sets the resolving parent.

### Methods declared in class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
Modifier and Type
Method
Description
`protected Object`
`clone()`
Creates and returns a copy of this object.
`boolean`
`equals(Object obj)`
Indicates whether some other object is "equal to" this one.
`protected void`
`finalize()`
Deprecated, for removal: This API element is subject to removal in a future version.
Finalization is deprecated and subject to removal in a future release.
`final Class<?>`
`getClass()`
Returns the runtime class of this `Object`.
`int`
`hashCode()`
Returns a hash code value for this object.
`final void`
`notify()`
Wakes up a single thread that is waiting on this object's monitor.
`final void`
`notifyAll()`
Wakes up all threads that are waiting on this object's monitor.
`final void`
`wait()`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
`final void`
`wait(long timeoutMillis)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
`final void`
`wait(long timeoutMillis, int nanos)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

## Constructor Details

### LeafElement

public LeafElement(Element parent, AttributeSet a, int offs0, int offs1)
Constructs an element that represents content within the document (has no children).

Parameters:
  `parent` - The parent element
  `a` - The element attributes
  `offs0` - The start offset >= 0
  `offs1` - The end offset >= offs0
Since:
  1.4

## Method Details

### toString

public String toString()
Converts the element to a string.

Overrides:
  `toString` in class `Object`
Returns:
  the string

### getStartOffset

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

Specified by:
  `getStartOffset` in interface `Element`
Specified by:
  `getStartOffset` in class `AbstractDocument.AbstractElement`
Returns:
  the offset >= 0
See Also:
  - `Document`
  - `AbstractDocument`

### getEndOffset

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

Specified by:
  `getEndOffset` in interface `Element`
Specified by:
  `getEndOffset` in class `AbstractDocument.AbstractElement`
Returns:
  the offset >= 0
See Also:
  - `Document`
  - `AbstractDocument`

### getName

public String getName()
Gets the element name.

Specified by:
  `getName` in interface `Element`
Overrides:
  `getName` in class `AbstractDocument.AbstractElement`
Returns:
  the name

### getElementIndex

public int getElementIndex(int pos)
Gets the child element index closest to the given model offset.

Specified by:
  `getElementIndex` in interface `Element`
Specified by:
  `getElementIndex` in class `AbstractDocument.AbstractElement`
Parameters:
  `pos` - the offset >= 0
Returns:
  the element index >= 0

### getElement

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

Specified by:
  `getElement` in interface `Element`
Specified by:
  `getElement` in class `AbstractDocument.AbstractElement`
Parameters:
  `index` - the child index, >= 0 && < getElementCount()
Returns:
  the child element

### getElementCount

public int getElementCount()
Returns the number of child elements.

Specified by:
  `getElementCount` in interface `Element`
Specified by:
  `getElementCount` in class `AbstractDocument.AbstractElement`
Returns:
  the number of children >= 0

### isLeaf

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

Specified by:
  `isLeaf` in interface `Element`
Specified by:
  `isLeaf` in interface `TreeNode`
Specified by:
  `isLeaf` in class `AbstractDocument.AbstractElement`
Returns:
  true if a leaf

### getAllowsChildren

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

Specified by:
  `getAllowsChildren` in interface `TreeNode`
Specified by:
  `getAllowsChildren` in class `AbstractDocument.AbstractElement`
Returns:
  true if the receiver allows children, otherwise false

### children

public Enumeration<TreeNode> children()
Returns the children of the receiver as an `Enumeration`.

Specified by:
  `children` in interface `TreeNode`
Specified by:
  `children` in class `AbstractDocument.AbstractElement`
Returns:
  the children of the receiver