javax.swing.text
public class AbstractDocument.BranchElement extends AbstractDocument.AbstractElement
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
NameAttribute, ResolveAttribute
Constructor and Description |
---|
AbstractDocument.BranchElement(Element parent,
AttributeSet attributes)
Creates a new
BranchElement with the specified
parent and attributes. |
Modifier and Type | Method and Description |
---|---|
Enumeration |
children()
Returns the children of this
BranchElement . |
boolean |
getAllowsChildren()
Returns
true since BranchElements allow
child elements. |
Element |
getElement(int index)
Returns the child element at the specified
index . |
int |
getElementCount()
Returns the number of child elements of this element.
|
int |
getElementIndex(int offset)
Returns the index of the child element that spans the specified
offset in the document model.
|
int |
getEndOffset()
Returns the offset inside the document model that is after the last
character of this element.
|
String |
getName()
Returns the name of this element.
|
int |
getStartOffset()
Returns the start offset of this element inside the document model.
|
boolean |
isLeaf()
Returns
false since BranchElement are no
leafes. |
Element |
positionToElement(int position)
Returns the
Element at the specified Document
offset. |
void |
replace(int offset,
int length,
Element[] elements)
Replaces a set of child elements with a new set of child elemens.
|
String |
toString()
Returns a string representation of this element.
|
addAttribute, addAttributes, containsAttribute, containsAttributes, copyAttributes, dump, getAttribute, getAttributeCount, getAttributeNames, getAttributes, getChildAt, getChildCount, getDocument, getIndex, getParent, getParentElement, getResolveParent, isDefined, isEqual, removeAttribute, removeAttributes, removeAttributes, setResolveParent
public AbstractDocument.BranchElement(Element parent, AttributeSet attributes)
BranchElement
with the specified
parent and attributes.parent
- the parent element of this BranchElement
attributes
- the attributes to set on this
BranchElement
public Enumeration children()
BranchElement
.children
in interface TreeNode
children
in class AbstractDocument.AbstractElement
BranchElement
public boolean getAllowsChildren()
true
since BranchElements
allow
child elements.getAllowsChildren
in interface TreeNode
getAllowsChildren
in class AbstractDocument.AbstractElement
true
since BranchElements
allow
child elementspublic Element getElement(int index)
index
.getElement
in interface Element
getElement
in class AbstractDocument.AbstractElement
index
- the index of the requested child elementpublic int getElementCount()
getElementCount
in interface Element
getElementCount
in class AbstractDocument.AbstractElement
public int getElementIndex(int offset)
getElementIndex
in interface Element
getElementIndex
in class AbstractDocument.AbstractElement
offset
- the offset for which the responsible element is searchedpublic int getEndOffset()
NullPointerException
.getEndOffset
in interface Element
getEndOffset
in class AbstractDocument.AbstractElement
NullPointerException
- if this branch element has no childrenpublic String getName()
AbstractDocument.ParagraphElementName
in this case.getName
in interface Element
getName
in class AbstractDocument.AbstractElement
public int getStartOffset()
NullPointerException
.getStartOffset
in interface Element
getStartOffset
in class AbstractDocument.AbstractElement
NullPointerException
- if this branch element has no children and
no startOffset value has been cachedpublic boolean isLeaf()
false
since BranchElement
are no
leafes.public Element positionToElement(int position)
Element
at the specified Document
offset.Element
at the specified Document
offsetgetElementIndex(int)
public void replace(int offset, int length, Element[] elements)
offset
- the start index of the elements to be removedlength
- the number of elements to be removedelements
- the new elements to be insertedpublic String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)