Modifier and Type | Method and Description |
---|---|
T |
get()
Return the object associated with this element
|
List<PathMap.Element<T>> |
getChildren()
Return an iterator over all of this element's children.
|
int |
getChildrenCount()
Return the children count of this element
|
int |
getDepth()
Return the depth of this element.
|
PathMap.Element<T> |
getDescendant(Path relPath,
boolean exact)
Map a relPath starting at
this Element. |
int |
getIndex()
Return the non-normalized 1-based index of this element.
|
Name |
getName()
Return the name of this element
|
int |
getNormalizedIndex()
Return the 1-based index of this element.
|
PathMap.Element<T> |
getParent()
Return the parent of this element
|
Path |
getPath()
Return the path of this element.
|
Path.Element |
getPathElement()
Return a path element pointing to this element
|
boolean |
hasPath(Path path)
Checks whether this element has the specified path.
|
void |
insert(Path.Element nameIndex)
Insert an empty child.
|
boolean |
isAncestorOf(PathMap.Element<T> other)
Return a flag indicating whether the specified node is a
child of this node.
|
void |
put(Path.Element nameIndex,
PathMap.Element<T> element)
Link a child of this node.
|
void |
remove()
Remove this element.
|
void |
remove(boolean shift)
Remove this element.
|
PathMap.Element<T> |
remove(Path.Element nameIndex)
Remove a child.
|
void |
removeAll()
Remove all children of this element.
|
void |
set(T obj)
Set the object associated with this element
|
void |
setChildren(Map<Path.Element,PathMap.Element<T>> children)
Sets a new list of children of this element.
|
void |
traverse(PathMap.ElementVisitor<T> visitor,
boolean includeEmpty)
Recursively invoked traversal method.
|
public void insert(Path.Element nameIndex)
nameIndex
- position where child is insertedpublic void put(Path.Element nameIndex, PathMap.Element<T> element)
nameIndex
.nameIndex
- position where child should be locatedelement
- element to addpublic PathMap.Element<T> remove(Path.Element nameIndex)
nameIndex
- child's path elementnull
public void remove()
public void remove(boolean shift)
shift
- if index of same name siblings will be shifted.public void removeAll()
public void setChildren(Map<Path.Element,PathMap.Element<T>> children)
children
- map of children; keys are of type
Path.PathElement
and values
are of type Element
public T get()
public void set(T obj)
obj
- object associated with this elementpublic Name getName()
public int getIndex()
getNormalizedIndex()
public int getNormalizedIndex()
getIndex()
except that an undefined index
value is automatically converted to the
default index
value.public Path.Element getPathElement()
public Path getPath() throws MalformedPathException
MalformedPathException
- if building the path failspublic boolean hasPath(Path path)
MalformedPathException
for simple
path comparisons.path
- path to compare totrue
if this child has the path
path
, false
otherwisepublic void traverse(PathMap.ElementVisitor<T> visitor, boolean includeEmpty)
visitor
- visitor to invokeincludeEmpty
- if true
invoke call back on every
element regardless, whether the associated object is empty
or not; otherwise call back on non-empty children onlypublic int getDepth()
0
for the
root element and n + 1
for some element if the depth of
its parent is n
.public boolean isAncestorOf(PathMap.Element<T> other)
other
- node to checkpublic PathMap.Element<T> getParent()
null
if this is the root elementpublic int getChildrenCount()
public List<PathMap.Element<T>> getChildren()
PathMap.Element
.public PathMap.Element<T> getDescendant(Path relPath, boolean exact)
this
Element. If
exact
is false
, returns the last available
item along the relPath that is stored in the map.relPath
- relPath to mapexact
- flag indicating whether an exact match is requirednull
if exact
is
true
Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.