FileDocCategorySizeDatePackage
Element.javaAPI DocJava SE 5 API3749Fri Aug 26 14:58:14 BST 2005javax.swing.text

Element

public interface Element
Interface to describe a structural piece of a document. It is intended to capture the spirit of an SGML element.
author
Timothy Prinzing
version
1.23 12/19/03

Fields Summary
Constructors Summary
Methods Summary
public javax.swing.text.AttributeSetgetAttributes()
Fetches the collection of attributes this element contains.

return
the attributes for the element

public javax.swing.text.DocumentgetDocument()
Fetches the document associated with this element.

return
the document

public javax.swing.text.ElementgetElement(int index)
Fetches the child element at the given index.

param
index the specified index >= 0
return
the child element

public intgetElementCount()
Gets the number of child elements contained by this element. If this element is a leaf, a count of zero is returned.

return
the number of child elements >= 0

public intgetElementIndex(int offset)
Gets the child element index closest to the given offset. The offset is specified relative to the beginning of the document. Returns -1 if the Element is a leaf, otherwise returns the index of the Element that best represents the given location. Returns 0 if the location is less than the start offset. Returns getElementCount() - 1 if the location is greater than or equal to the end offset.

param
offset the specified offset >= 0
return
the element index >= 0

public intgetEndOffset()
Fetches the offset from the beginning of the document that this element ends at. If this element has children, this will be the end offset of the last child. As a document position, there is an implied backward bias.

All the default Document implementations descend from AbstractDocument. AbstractDocument models an implied break at the end of the document. As a result of this, it is possible for this to return a value greater than the length of the document.

return
the ending offset > getStartOffset() and <= getDocument().getLength() + 1
see
Document
see
AbstractDocument

public java.lang.StringgetName()
Fetches the name of the element. If the element is used to represent some type of structure, this would be the type name.

return
the element name

public javax.swing.text.ElementgetParentElement()
Fetches the parent element. If the element is a root level element returns null.

return
the parent element

public intgetStartOffset()
Fetches the offset from the beginning of the document that this element begins at. If this element has children, this will be the offset of the first child. As a document position, there is an implied forward bias.

return
the starting offset >= 0 and < getEndOffset();
see
Document
see
AbstractDocument

public booleanisLeaf()
Is this element a leaf element? An element that may have children, even if it currently has no children, would return false.

return
true if a leaf element else false