Class 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
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 JavaBeans has been added to the java.beans
package. Please see XMLEncoder
.
Nested Class Summary
Nested classes/interfaces declared in interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
Field Summary
Fields declared in interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
Constructor Summary
Constructor | Description |
---|---|
AbstractElement |
Creates a new AbstractElement. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void |
addAttribute |
Adds an attribute to the element. |
void |
addAttributes |
Adds a set of attributes to the element. |
abstract Enumeration<TreeNode> |
children() |
Returns the children of the receiver as an Enumeration . |
boolean |
containsAttribute |
Checks whether a given attribute name/value is defined. |
boolean |
containsAttributes |
Checks whether the element contains all the attributes. |
AttributeSet |
copyAttributes() |
Copies a set of attributes. |
void |
dump |
Dumps a debugging representation of the element hierarchy. |
abstract boolean |
getAllowsChildren() |
Returns true if the receiver allows children. |
Object |
getAttribute |
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 |
Returns the child TreeNode at index childIndex . |
int |
getChildCount() |
Returns the number of children TreeNode 's receiver contains. |
Document |
getDocument() |
Retrieves the underlying model. |
abstract Element |
getElement |
Gets a child element. |
abstract int |
getElementCount() |
Gets the number of children for the element. |
abstract int |
getElementIndex |
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 |
Returns the index of node in the receivers children. |
String |
getName() |
Gets the name of the element. |
TreeNode |
getParent() |
Returns the parent TreeNode 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 |
Checks whether a given attribute is defined. |
boolean |
isEqual |
Checks whether two attribute sets are equal. |
abstract boolean |
isLeaf() |
Checks whether the element is a leaf. |
void |
removeAttribute |
Removes an attribute from the set. |
void |
removeAttributes |
Removes a set of attributes for the element. |
void |
removeAttributes |
Removes a set of attributes for the element. |
void |
setResolveParent |
Sets the resolving parent. |
Constructor Details
AbstractElement
public AbstractElement(Element parent, AttributeSet a)
- Parameters:
-
parent
- the parent element -
a
- the attributes for the element - Since:
- 1.4
Method Details
dump
public void dump(PrintStream psOut, int indentAmount)
- Parameters:
-
psOut
- the output stream -
indentAmount
- the indentation level >= 0
getAttributeCount
public int getAttributeCount()
- Specified by:
-
getAttributeCount
in interfaceAttributeSet
- Returns:
- the number of attributes >= 0
- See Also:
isDefined
public boolean isDefined(Object attrName)
- Specified by:
-
isDefined
in interfaceAttributeSet
- Parameters:
-
attrName
- the non-null attribute name - Returns:
- true if the attribute is defined
- See Also:
isEqual
public boolean isEqual(AttributeSet attr)
- Specified by:
-
isEqual
in interfaceAttributeSet
- Parameters:
-
attr
- the attribute set to check against - Returns:
- true if the same
- See Also:
copyAttributes
public AttributeSet copyAttributes()
- Specified by:
-
copyAttributes
in interfaceAttributeSet
- Returns:
- the copy
- See Also:
getAttribute
public Object getAttribute(Object attrName)
- Specified by:
-
getAttribute
in interfaceAttributeSet
- Parameters:
-
attrName
- the non-null attribute name - Returns:
- the attribute value
- See Also:
getAttributeNames
public Enumeration<?> getAttributeNames()
- Specified by:
-
getAttributeNames
in interfaceAttributeSet
- Returns:
- the attribute names as an enumeration
- See Also:
containsAttribute
public boolean containsAttribute(Object name, Object value)
- Specified by:
-
containsAttribute
in interfaceAttributeSet
- Parameters:
-
name
- the non-null attribute name -
value
- the attribute value - Returns:
- true if the name/value is defined
- See Also:
containsAttributes
public boolean containsAttributes(AttributeSet attrs)
- Specified by:
-
containsAttributes
in interfaceAttributeSet
- Parameters:
-
attrs
- the attributes to check - Returns:
- true if the element contains all the attributes
- See Also:
getResolveParent
public AttributeSet getResolveParent()
- Specified by:
-
getResolveParent
in interfaceAttributeSet
- Returns:
- the attributes from the parent,
null
if none - See Also:
addAttribute
public void addAttribute(Object name, Object value)
- Specified by:
-
addAttribute
in interfaceMutableAttributeSet
- Parameters:
-
name
- the non-null attribute name -
value
- the attribute value - See Also:
addAttributes
public void addAttributes(AttributeSet attr)
- Specified by:
-
addAttributes
in interfaceMutableAttributeSet
- Parameters:
-
attr
- the attributes to add - See Also:
removeAttribute
public void removeAttribute(Object name)
- Specified by:
-
removeAttribute
in interfaceMutableAttributeSet
- Parameters:
-
name
- the non-null attribute name - See Also:
removeAttributes
public void removeAttributes(Enumeration<?> names)
- Specified by:
-
removeAttributes
in interfaceMutableAttributeSet
- Parameters:
-
names
- the attribute names - See Also:
removeAttributes
public void removeAttributes(AttributeSet attrs)
- Specified by:
-
removeAttributes
in interfaceMutableAttributeSet
- Parameters:
-
attrs
- the attributes - See Also:
setResolveParent
public void setResolveParent(AttributeSet parent)
- Specified by:
-
setResolveParent
in interfaceMutableAttributeSet
- Parameters:
-
parent
- the parent, null if none - See Also:
getDocument
public Document getDocument()
- Specified by:
-
getDocument
in interfaceElement
- Returns:
- the model
getParentElement
public Element getParentElement()
- Specified by:
-
getParentElement
in interfaceElement
- Returns:
- the parent
getAttributes
public AttributeSet getAttributes()
- Specified by:
-
getAttributes
in interfaceElement
- Returns:
- the attribute set
getName
public String getName()
getStartOffset
public abstract int getStartOffset()
- Specified by:
-
getStartOffset
in interfaceElement
- Returns:
- the offset >= 0
- See Also:
getEndOffset
public abstract int getEndOffset()
- Specified by:
-
getEndOffset
in interfaceElement
- Returns:
- the offset >= 0
- See Also:
getElement
public abstract Element getElement(int index)
- Specified by:
-
getElement
in interfaceElement
- Parameters:
-
index
- the child index, >= 0 && < getElementCount() - Returns:
- the child element
getElementCount
public abstract int getElementCount()
- Specified by:
-
getElementCount
in interfaceElement
- Returns:
- the number of children >= 0
getElementIndex
public abstract int getElementIndex(int offset)
- Specified by:
-
getElementIndex
in interfaceElement
- Parameters:
-
offset
- the offset >= 0 - Returns:
- the element index >= 0
isLeaf
public abstract boolean isLeaf()
getChildAt
public TreeNode getChildAt(int childIndex)
TreeNode
at index childIndex
.- Specified by:
-
getChildAt
in interfaceTreeNode
- Parameters:
-
childIndex
- index of child - Returns:
- the child node at given index
getChildCount
public int getChildCount()
TreeNode
's receiver contains.- Specified by:
-
getChildCount
in interfaceTreeNode
- Returns:
- the number of children
TreeNodews
's receiver contains
getParent
public TreeNode getParent()
TreeNode
of the receiver.getIndex
public int getIndex(TreeNode node)
node
in the receivers children. If the receiver does not contain node
, -1 will be returned.getAllowsChildren
public abstract boolean getAllowsChildren()
- Specified by:
-
getAllowsChildren
in interfaceTreeNode
- Returns:
- true if the receiver allows children, otherwise false
children
public abstract Enumeration<TreeNode> children()
Enumeration
.
© 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/AbstractDocument.AbstractElement.html