-
- 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
Methods Modifier and Type Method and Description 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? An element that may have children, even if it currently has no children, would returnfalse
.
-
-
-
Method Detail
-
getDocument
Document getDocument()
Fetches the document associated with this element.- Returns:
- the document
-
getParentElement
Element getParentElement()
Fetches the parent element. If the element is a root level element returnsnull
.- Returns:
- the parent element
-
getName
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
AttributeSet getAttributes()
Fetches the collection of attributes this element contains.- Returns:
- the attributes for the element
-
getStartOffset
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();
- See Also:
Document
,AbstractDocument
-
getEndOffset
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 fromAbstractDocument
.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
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 theElement
is a leaf, otherwise returns the index of theElement
that best represents the given location. Returns0
if the location is less than the start offset. ReturnsgetElementCount() - 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()
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
Element getElement(int index)
Fetches the child element at the given index.- Parameters:
index
- the specified index >= 0- Returns:
- the child element
-
isLeaf
boolean isLeaf()
Is this element a leaf element? An element that may have children, even if it currently has no children, would returnfalse
.- Returns:
- true if a leaf element else false
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
05/11/2024 16:31:16 Cette version de la page est en cache (à la date du 05/11/2024 16:31:16) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 13/07/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/text/Element.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.