Class AbstractDocument.BranchElement
- All Implemented Interfaces:
Serializable, AttributeSet, Element, MutableAttributeSet, TreeNode
- Direct Known Subclasses:
DefaultStyledDocument.SectionElement, HTMLDocument.BlockElement
- Enclosing class:
AbstractDocument
public class AbstractDocument.BranchElement extends AbstractDocument.AbstractElement
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 AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute | Modifier and Type | Interface | Description |
|---|---|---|
static interface |
AttributeSet.CharacterAttribute |
This interface is the type signature that is expected to be present on any attribute key that contributes to character level presentation. |
static interface |
AttributeSet.ColorAttribute |
This interface is the type signature that is expected to be present on any attribute key that contributes to presentation of color. |
static interface |
AttributeSet.FontAttribute |
This interface is the type signature that is expected to be present on any attribute key that contributes to the determination of what font to use to render some text. |
static interface |
AttributeSet.ParagraphAttribute |
This interface is the type signature that is expected to be present on any attribute key that contributes to the paragraph level presentation. |
Field Summary
Fields declared in interface AttributeSet
NameAttribute, ResolveAttribute | Modifier and Type | Field | Description |
|---|---|---|
static final Object |
NameAttribute |
Attribute name used to name the collection of attributes. |
static final Object |
ResolveAttribute |
Attribute name used to identify the resolving parent set of attributes, if one is defined. |
Constructor Summary
| Constructor | Description |
|---|---|
BranchElement |
Constructs a composite element that initially contains no children. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Enumeration |
children() |
Returns the children of the receiver as an Enumeration. |
boolean |
getAllowsChildren() |
Returns true if the receiver allows children. |
Element |
getElement |
Gets a child element. |
int |
getElementCount() |
Gets the number of children for the element. |
int |
getElementIndex |
Gets the child element index closest to the given model offset. |
int |
getEndOffset() |
Gets the ending offset in the model for the element. |
String |
getName() |
Gets the element name. |
int |
getStartOffset() |
Gets the starting offset in the model for the element. |
boolean |
isLeaf() |
Checks whether the element is a leaf. |
Element |
positionToElement |
Gets the child element that contains the given model position. |
void |
replace |
Replaces content with a new set of elements. |
String |
toString() |
Converts the element to a string. |
Methods declared in class AbstractDocument.AbstractElement
addAttribute, addAttributes, containsAttribute, containsAttributes, copyAttributes, dump, getAttribute, getAttributeCount, getAttributeNames, getAttributes, getChildAt, getChildCount, getDocument, getIndex, getParent, getParentElement, getResolveParent, isDefined, isEqual, removeAttribute, removeAttributes, removeAttributes, setResolveParent | Modifier and Type | Method | Description |
|---|---|---|
void |
addAttribute |
Adds an attribute to the element. |
void |
addAttributes |
Adds a set of attributes to the element. |
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. |
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. |
int |
getIndex |
Returns the index of node in the receivers children. |
TreeNode |
getParent() |
Returns the parent TreeNode of the receiver. |
Element |
getParentElement() |
Gets the parent of the element. |
AttributeSet |
getResolveParent() |
Gets the resolving parent. |
boolean |
isDefined |
Checks whether a given attribute is defined. |
boolean |
isEqual |
Checks whether two attribute sets are equal. |
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. |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
BranchElement
public BranchElement(Element parent, AttributeSet a)
- Parameters:
-
parent- The parent element -
a- the attributes for the element - Since:
- 1.4
Method Details
positionToElement
public Element positionToElement(int pos)
- Parameters:
-
pos- the position >= 0 - Returns:
- the element, null if none
replace
public void replace(int offset, int length, Element[] elems)
- Parameters:
-
offset- the starting offset >= 0 -
length- the length to replace >= 0 -
elems- the new elements
toString
getName
public String getName()
- Specified by:
-
getNamein interfaceElement - Overrides:
-
getNamein classAbstractDocument.AbstractElement - Returns:
- the element name
getStartOffset
public int getStartOffset()
- Specified by:
-
getStartOffsetin interfaceElement - Specified by:
-
getStartOffsetin classAbstractDocument.AbstractElement - Returns:
- the offset >= 0
- See Also:
getEndOffset
public int getEndOffset()
- Specified by:
-
getEndOffsetin interfaceElement - Specified by:
-
getEndOffsetin classAbstractDocument.AbstractElement - Returns:
- the offset >= 0
- Throws:
-
NullPointerException- if this element has no children - See Also:
getElement
public Element getElement(int index)
- Specified by:
-
getElementin interfaceElement - Specified by:
-
getElementin classAbstractDocument.AbstractElement - Parameters:
-
index- the child index, >= 0 && < getElementCount() - Returns:
- the child element, null if none
getElementCount
public int getElementCount()
- Specified by:
-
getElementCountin interfaceElement - Specified by:
-
getElementCountin classAbstractDocument.AbstractElement - Returns:
- the number of children >= 0
getElementIndex
public int getElementIndex(int offset)
- Specified by:
-
getElementIndexin interfaceElement - Specified by:
-
getElementIndexin classAbstractDocument.AbstractElement - Parameters:
-
offset- the offset >= 0 - Returns:
- the element index >= 0
isLeaf
getAllowsChildren
public boolean getAllowsChildren()
- Specified by:
-
getAllowsChildrenin interfaceTreeNode - Specified by:
-
getAllowsChildrenin classAbstractDocument.AbstractElement - Returns:
- true if the receiver allows children, otherwise false
children
public Enumeration<TreeNode> children()
Enumeration.- Specified by:
-
childrenin interfaceTreeNode - Specified by:
-
childrenin classAbstractDocument.AbstractElement - Returns:
- the children of the receiver
© 1993, 2025, 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.