JavaTM 2 Platform
Std. Ed. v1.3.1

javax.swing.text
Interface Element

All Known Implementing Classes:
AbstractDocument.AbstractElement

public interface Element

Interface to describe a structural piece of a document. It is intended to capture the spirit of an SGML element.


Method Summary
 AttributeSet getAttributes()
          Fetches the collection of attributes this element contains.
 Document getDocument()
          Fetches the document associated with this element.
 Element getElement(int index)
          Fetches the child element at the given index.
 int getElementCount()
          Gets the number of child elements contained by this element.
 int getElementIndex(int offset)
          Gets the child element index closest to the given offset.
 int getEndOffset()
          Fetches the offset from the beginning of the document that this element ends at.
 String getName()
          Fetches the name of the element.
 Element getParentElement()
          Fetches the parent element.
 int getStartOffset()
          Fetches the offset from the beginning of the document that this element begins at.
 boolean isLeaf()
          Is this element a leaf element?
 

Method Detail

getDocument

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

getParentElement

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

getName

public String getName()
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()
Fetches the collection of attributes this element contains.
Returns:
the attributes for the element

getStartOffset

public int getStartOffset()
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.
Returns:
the starting offset >= 0

getEndOffset

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

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 >= 0
See Also:
AbstractDocument

getElementIndex

public int getElementIndex(int offset)
Gets the child element index closest to the given offset. The offset is specified relative to the begining of the document.
Parameters:
offset - the specified offset >= 0
Returns:
the element index >= 0

getElementCount

public int getElementCount()
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)
Fetches the child element at the given index.
Parameters:
index - the specified index >= 0
Returns:
the child element

isLeaf

public boolean isLeaf()
Is this element a leaf element?
Returns:
true if a leaf element else false

JavaTM 2 Platform
Std. Ed. v1.3.1

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.



Spec-Zone.ru - all specs in one place



free hit counter