This documentation differs from the official API.
Jadeite adds
extra features to the API including:
variable font sizes,
constructions examples,
placeholders for classes and methods, and auto-generated “See Also” links.
Additionally it
is missing some items found in standard Javadoc documentation, including:
generics type information,
“Deprecated” tags and comments,
“See Also” links,
along with other minor differences.
Please send any questions or feedback to
bam@cs.cmu.edu.
javax.swing.text
interface Element
- All Known Implementing Classes:
- AbstractDocument.AbstractElement, AbstractDocument.BranchElement, AbstractDocument.LeafElement, DefaultStyledDocument.SectionElement, HTMLDocument.BlockElement, HTMLDocument.RunElement
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 |
Fetches the collection of attributes this element contains.
|
Document |
Fetches the document associated with this element.
|
Element |
Fetches the child element at the given index.
|
int |
Gets the number of child elements contained by this element.
|
int |
Gets the child element index closest to the given offset.
|
int |
Fetches the offset from the beginning of the document
that this element ends at.
|
String |
Fetches the name of the element.
|
Element |
Fetches the parent element.
|
int |
Fetches the offset from the beginning of the document
that this element begins at.
|
boolean |
Is this element a leaf element? An element that
may have children, even if it currently
has no children, would return false .
|
getAttributes
public AttributeSet getAttributes()
-
Fetches the collection of attributes this element contains.
- Returns:
- the attributes for the element
getDocument
public Document getDocument()
-
Fetches the document associated with this element.
- Returns:
- the document
getElement
public Element getElement(int index)
-
Fetches the child element at the given index.
- Parameters:
index
- the specified index >= 0
- Returns:
- the child element
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
getElementIndex
public int getElementIndex(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.
- Parameters:
offset
- the specified offset >= 0
- Returns:
- the element index >= 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.
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
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
getParentElement
public Element getParentElement()
-
Fetches the parent element. If the element is a root level
element returns
null
.
- Returns:
- the parent 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.
As a document position, there is an implied forward bias.
- Returns:
- the starting offset >= 0 and < getEndOffset();
isLeaf
public boolean isLeaf()
-
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
This documentation differs from the official API.
Jadeite adds
extra features to the API including:
variable font sizes,
constructions examples,
placeholders for classes and methods, and auto-generated “See Also” links.
Additionally it
is missing some items found in standard Javadoc documentation, including:
generics type information,
“Deprecated” tags and comments,
“See Also” links,
along with other minor differences.
Please send any questions or feedback to
bam@cs.cmu.edu.
This page displays the
Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
The official Sun™ documentation can be found here at
http://java.sun.com/javase/6/docs/api/.