javax.swing.text
Interface Element

All Known Implementing Classes:
javax.swing.text.AbstractDocument.AbstractElement

public interface Element

Unsafe:


Method Summary
 AttributeSet getAttributes()
          Enabled: Fetches the collection of attributes this element contains.
 Document getDocument()
          Enabled: Fetches the document associated with this element.
 Element getElement(int index)
          Enabled: Fetches the child element at the given index.
 int getElementCount()
          Enabled: Gets the number of child elements contained by this element.
 int getElementIndex(int offset)
          Enabled: Gets the child element index closest to the given offset.
 int getEndOffset()
          Enabled: Fetches the offset from the beginning of the document that this element ends at.
 String getName()
          Enabled: Fetches the name of the element.
 Element getParentElement()
          Enabled: Fetches the parent element.
 int getStartOffset()
          Enabled: Fetches the offset from the beginning of the document that this element begins at.
 boolean isLeaf()
          Enabled: Is this element a leaf element? An element that may have children, even if it currently has no children, would return false.
 

Method Detail

getDocument

public Document getDocument()
Enabled: Fetches the document associated with this element.

Returns:
the document

getParentElement

public Element getParentElement()
Enabled: Fetches the parent element. If the element is a root level element returns null.

Returns:
the parent element

getName

public String getName()
Enabled: Fetches the name of the element. If the element is used to represent some type of structure, this would be the type name.

Returns:
the element name

getAttributes

public AttributeSet getAttributes()
Enabled: Fetches the collection of attributes this element contains.

Returns:
the attributes for the element

getStartOffset

public int getStartOffset()
Enabled: 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.

Returns:
the starting offset >= 0 and < getEndOffset();
See Also:
Document, AbstractDocument

getEndOffset

public int getEndOffset()
Enabled: 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.

Returns:
the ending offset > getStartOffset() and <= getDocument().getLength() + 1
See Also:
Document, AbstractDocument

getElementIndex

public int getElementIndex(int offset)
Enabled: 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.

Parameters:
offset - the specified offset >= 0
Returns:
the element index >= 0

getElementCount

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

Returns:
the number of child elements >= 0

getElement

public Element getElement(int index)
Enabled: Fetches the child element at the given index.

Parameters:
index - the specified index >= 0
Returns:
the child element

isLeaf

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

Returns:
true if a leaf element else false


comments?