APIdia Launch Partner
Top Description Methods
javax.swing.text

public Interface Element

Known Direct Implementers
javax.swing.text.AbstractDocument.AbstractElement

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

Method Summary

Modifier and TypeMethod and Description
public AttributeSet

Returns:

the attributes for the element
getAttributes
()

Fetches the collection of attributes this element contains.

public Document

Returns:

the document
getDocument
()

Fetches the document associated with this element.

public Element

Returns:

the child element
getElement
(int
the specified index >= 0
index
)

Fetches the child element at the given index.

public int

Returns:

the number of child elements >= 0
getElementCount
()

Gets the number of child elements contained by this element.

public int

Returns:

the element index >= 0
getElementIndex
(int
the specified offset >= 0
offset
)

Gets the child element index closest to the given offset.

public int

Returns:

the ending offset > getStartOffset() and <= getDocument().getLength() + 1
getEndOffset
()

Fetches the offset from the beginning of the document that this element ends at.

public String

Returns:

the element name
getName
()

Fetches the name of the element.

public Element

Returns:

the parent element
getParentElement
()

Fetches the parent element.

public int

Returns:

the starting offset >= 0 and < getEndOffset();
getStartOffset
()

Fetches the offset from the beginning of the document that this element begins at.

public boolean

Returns:

true if a leaf element else false
isLeaf
()

Is this element a leaf element?

Method Detail

getAttributesback to summary
public AttributeSet getAttributes()

Fetches the collection of attributes this element contains.

Returns:AttributeSet

the attributes for the element

getDocumentback to summary
public Document getDocument()

Fetches the document associated with this element.

Returns:Document

the document

getElementback to summary
public Element getElement(int index)

Fetches the child element at the given index.

Parameters
index:int

the specified index >= 0

Returns:Element

the child element

getElementCountback to summary
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:int

the number of child elements >= 0

getElementIndexback to summary
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:int

the specified offset >= 0

Returns:int

the element index >= 0

getEndOffsetback to summary
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:int

the ending offset > getStartOffset() and <= getDocument().getLength() + 1

See Also
Document, AbstractDocument
getNameback to summary
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:String

the element name

getParentElementback to summary
public Element getParentElement()

Fetches the parent element. If the element is a root level element returns null.

Returns:Element

the parent element

getStartOffsetback to summary
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:int

the starting offset >= 0 and < getEndOffset();

See Also
Document, AbstractDocument
isLeafback to summary
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:boolean

true if a leaf element else false