- java.lang.Object
-
- javax.swing.text.AbstractDocument.AbstractElement
-
- All Implemented Interfaces:
- Serializable, AttributeSet, Element, MutableAttributeSet, TreeNode
- Direct Known Subclasses:
- AbstractDocument.BranchElement, AbstractDocument.LeafElement
- Enclosing class:
- AbstractDocument
public abstract class AbstractDocument.AbstractElement extends Object implements Element, MutableAttributeSet, Serializable, TreeNode
Implements the abstract part of an element. By default elements support attributes by having a field that represents the immutable part of the current attribute set for the element. The element itself implements MutableAttributeSet which can be used to modify the set by fetching a new immutable set. The immutable sets are provided by the AttributeContext associated with the document.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the
java.beans
package. Please seeXMLEncoder
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
-
-
Field Summary
-
Fields inherited from interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
-
-
Constructor Summary
Constructors Constructor and Description AbstractDocument.AbstractElement(Element parent, AttributeSet a)
Creates a new AbstractElement.
-
Method Summary
Methods Modifier and Type Method and Description void
addAttribute(Object name, Object value)
Adds an attribute to the element.void
addAttributes(AttributeSet attr)
Adds a set of attributes to the element.abstract Enumeration
children()
Returns the children of the receiver as anEnumeration
.boolean
containsAttribute(Object name, Object value)
Checks whether a given attribute name/value is defined.boolean
containsAttributes(AttributeSet attrs)
Checks whether the element contains all the attributes.AttributeSet
copyAttributes()
Copies a set of attributes.void
dump(PrintStream psOut, int indentAmount)
Dumps a debugging representation of the element hierarchy.abstract boolean
getAllowsChildren()
Returns true if the receiver allows children.Object
getAttribute(Object attrName)
Gets the value of an attribute.int
getAttributeCount()
Gets the number of attributes that are defined.Enumeration<?>
getAttributeNames()
Gets the names of all attributes.AttributeSet
getAttributes()
Gets the attributes for the element.TreeNode
getChildAt(int childIndex)
Returns the childTreeNode
at indexchildIndex
.int
getChildCount()
Returns the number of childrenTreeNode
's receiver contains.Document
getDocument()
Retrieves the underlying model.abstract Element
getElement(int index)
Gets a child element.abstract int
getElementCount()
Gets the number of children for the element.abstract int
getElementIndex(int offset)
Gets the child element index closest to the given model offset.abstract int
getEndOffset()
Gets the ending offset in the model for the element.int
getIndex(TreeNode node)
Returns the index ofnode
in the receivers children.String
getName()
Gets the name of the element.TreeNode
getParent()
Returns the parentTreeNode
of the receiver.Element
getParentElement()
Gets the parent of the element.AttributeSet
getResolveParent()
Gets the resolving parent.abstract int
getStartOffset()
Gets the starting offset in the model for the element.boolean
isDefined(Object attrName)
Checks whether a given attribute is defined.boolean
isEqual(AttributeSet attr)
Checks whether two attribute sets are equal.abstract boolean
isLeaf()
Checks whether the element is a leaf.void
removeAttribute(Object name)
Removes an attribute from the set.void
removeAttributes(AttributeSet attrs)
Removes a set of attributes for the element.void
removeAttributes(Enumeration<?> names)
Removes a set of attributes for the element.void
setResolveParent(AttributeSet parent)
Sets the resolving parent.
-
-
-
Constructor Detail
-
AbstractDocument.AbstractElement
public AbstractDocument.AbstractElement(Element parent, AttributeSet a)
Creates a new AbstractElement.- Parameters:
parent
- the parent elementa
- the attributes for the element- Since:
- 1.4
-
-
Method Detail
-
dump
public void dump(PrintStream psOut, int indentAmount)
Dumps a debugging representation of the element hierarchy.- Parameters:
psOut
- the output streamindentAmount
- the indentation level >= 0
-
getAttributeCount
public int getAttributeCount()
Gets the number of attributes that are defined.- Specified by:
getAttributeCount
in interfaceAttributeSet
- Returns:
- the number of attributes >= 0
- See Also:
AttributeSet.getAttributeCount()
-
isDefined
public boolean isDefined(Object attrName)
Checks whether a given attribute is defined.- Specified by:
isDefined
in interfaceAttributeSet
- Parameters:
attrName
- the non-null attribute name- Returns:
- true if the attribute is defined
- See Also:
AttributeSet.isDefined(java.lang.Object)
-
isEqual
public boolean isEqual(AttributeSet attr)
Checks whether two attribute sets are equal.- Specified by:
isEqual
in interfaceAttributeSet
- Parameters:
attr
- the attribute set to check against- Returns:
- true if the same
- See Also:
AttributeSet.isEqual(javax.swing.text.AttributeSet)
-
copyAttributes
public AttributeSet copyAttributes()
Copies a set of attributes.- Specified by:
copyAttributes
in interfaceAttributeSet
- Returns:
- the copy
- See Also:
AttributeSet.copyAttributes()
-
getAttribute
public Object getAttribute(Object attrName)
Gets the value of an attribute.- Specified by:
getAttribute
in interfaceAttributeSet
- Parameters:
attrName
- the non-null attribute name- Returns:
- the attribute value
- See Also:
AttributeSet.getAttribute(java.lang.Object)
-
getAttributeNames
public Enumeration<?> getAttributeNames()
Gets the names of all attributes.- Specified by:
getAttributeNames
in interfaceAttributeSet
- Returns:
- the attribute names as an enumeration
- See Also:
AttributeSet.getAttributeNames()
-
containsAttribute
public boolean containsAttribute(Object name, Object value)
Checks whether a given attribute name/value is defined.- Specified by:
containsAttribute
in interfaceAttributeSet
- Parameters:
name
- the non-null attribute namevalue
- the attribute value- Returns:
- true if the name/value is defined
- See Also:
AttributeSet.containsAttribute(java.lang.Object, java.lang.Object)
-
containsAttributes
public boolean containsAttributes(AttributeSet attrs)
Checks whether the element contains all the attributes.- Specified by:
containsAttributes
in interfaceAttributeSet
- Parameters:
attrs
- the attributes to check- Returns:
- true if the element contains all the attributes
- See Also:
AttributeSet.containsAttributes(javax.swing.text.AttributeSet)
-
getResolveParent
public AttributeSet getResolveParent()
Gets the resolving parent. If not overridden, the resolving parent defaults to the parent element.- Specified by:
getResolveParent
in interfaceAttributeSet
- Returns:
- the attributes from the parent,
null
if none - See Also:
AttributeSet.getResolveParent()
-
addAttribute
public void addAttribute(Object name, Object value)
Adds an attribute to the element.- Specified by:
addAttribute
in interfaceMutableAttributeSet
- Parameters:
name
- the non-null attribute namevalue
- the attribute value- See Also:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
-
addAttributes
public void addAttributes(AttributeSet attr)
Adds a set of attributes to the element.- Specified by:
addAttributes
in interfaceMutableAttributeSet
- Parameters:
attr
- the attributes to add- See Also:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
-
removeAttribute
public void removeAttribute(Object name)
Removes an attribute from the set.- Specified by:
removeAttribute
in interfaceMutableAttributeSet
- Parameters:
name
- the non-null attribute name- See Also:
MutableAttributeSet.removeAttribute(java.lang.Object)
-
removeAttributes
public void removeAttributes(Enumeration<?> names)
Removes a set of attributes for the element.- Specified by:
removeAttributes
in interfaceMutableAttributeSet
- Parameters:
names
- the attribute names- See Also:
MutableAttributeSet.removeAttributes(java.util.Enumeration<?>)
-
removeAttributes
public void removeAttributes(AttributeSet attrs)
Removes a set of attributes for the element.- Specified by:
removeAttributes
in interfaceMutableAttributeSet
- Parameters:
attrs
- the attributes- See Also:
MutableAttributeSet.removeAttributes(java.util.Enumeration<?>)
-
setResolveParent
public void setResolveParent(AttributeSet parent)
Sets the resolving parent.- Specified by:
setResolveParent
in interfaceMutableAttributeSet
- Parameters:
parent
- the parent, null if none- See Also:
MutableAttributeSet.setResolveParent(javax.swing.text.AttributeSet)
-
getDocument
public Document getDocument()
Retrieves the underlying model.- Specified by:
getDocument
in interfaceElement
- Returns:
- the model
-
getParentElement
public Element getParentElement()
Gets the parent of the element.- Specified by:
getParentElement
in interfaceElement
- Returns:
- the parent
-
getAttributes
public AttributeSet getAttributes()
Gets the attributes for the element.- Specified by:
getAttributes
in interfaceElement
- Returns:
- the attribute set
-
getName
public String getName()
Gets the name of the element.
-
getStartOffset
public abstract int getStartOffset()
Gets the starting offset in the model for the element.- Specified by:
getStartOffset
in interfaceElement
- Returns:
- the offset >= 0
- See Also:
Document
,AbstractDocument
-
getEndOffset
public abstract int getEndOffset()
Gets the ending offset in the model for the element.- Specified by:
getEndOffset
in interfaceElement
- Returns:
- the offset >= 0
- See Also:
Document
,AbstractDocument
-
getElement
public abstract Element getElement(int index)
Gets a child element.- Specified by:
getElement
in interfaceElement
- Parameters:
index
- the child index, >= 0 && < getElementCount()- Returns:
- the child element
-
getElementCount
public abstract int getElementCount()
Gets the number of children for the element.- Specified by:
getElementCount
in interfaceElement
- Returns:
- the number of children >= 0
-
getElementIndex
public abstract int getElementIndex(int offset)
Gets the child element index closest to the given model offset.- Specified by:
getElementIndex
in interfaceElement
- Parameters:
offset
- the offset >= 0- Returns:
- the element index >= 0
-
isLeaf
public abstract boolean isLeaf()
Checks whether the element is a leaf.
-
getChildAt
public TreeNode getChildAt(int childIndex)
Returns the childTreeNode
at indexchildIndex
.- Specified by:
getChildAt
in interfaceTreeNode
-
getChildCount
public int getChildCount()
Returns the number of childrenTreeNode
's receiver contains.- Specified by:
getChildCount
in interfaceTreeNode
- Returns:
- the number of children
TreeNodews
's receiver contains
-
getParent
public TreeNode getParent()
Returns the parentTreeNode
of the receiver.
-
getIndex
public int getIndex(TreeNode node)
Returns the index ofnode
in the receivers children. If the receiver does not containnode
, -1 will be returned.
-
getAllowsChildren
public abstract boolean getAllowsChildren()
Returns true if the receiver allows children.- Specified by:
getAllowsChildren
in interfaceTreeNode
- Returns:
- true if the receiver allows children, otherwise false
-
children
public abstract Enumeration children()
Returns the children of the receiver as anEnumeration
.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/text/AbstractDocument.AbstractElement.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.