Interface Element
- All Known Implementing Classes:
-
AbstractDocument.AbstractElement
,AbstractDocument.BranchElement
,AbstractDocument.LeafElement
,DefaultStyledDocument.SectionElement
,HTMLDocument.BlockElement
,HTMLDocument.RunElement
public interface Element
Method Summary
Modifier and Type | Method | Description |
---|---|---|
AttributeSet |
getAttributes() |
Fetches the collection of attributes this element contains. |
Document |
getDocument() |
Fetches the document associated with this element. |
Element |
getElement |
Fetches the child element at the given index. |
int |
getElementCount() |
Gets the number of child elements contained by this element. |
int |
getElementIndex |
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 Details
getDocument
Document getDocument()
- Returns:
- the document
getParentElement
Element getParentElement()
null
.- Returns:
- the parent element
getName
String getName()
- Returns:
- the element name
getAttributes
AttributeSet getAttributes()
- Returns:
- the attributes for the element
getStartOffset
int getStartOffset()
- Returns:
- the starting offset >= 0 and < getEndOffset();
- See Also:
getEndOffset
int getEndOffset()
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:
getElementIndex
int getElementIndex(int offset)
-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
int getElementCount()
- Returns:
- the number of child elements >= 0
getElement
Element getElement(int index)
- Parameters:
-
index
- the specified index >= 0 - Returns:
- the child element
isLeaf
boolean isLeaf()
false
.- Returns:
- true if a leaf element else false
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/text/Element.html