-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddChildElement
(Element childElement, ElementWriter elementWriter) Adds a child element to this node.void
addPageLink
(PageRef pageLink) final void
appendLabel
(Appendable out) Deprecated, for removal: This API element is subject to removal in a future version.protected void
<E> Optional
<E> findChildElement
(Class<E> elementType) Finds the first descendant element of the given class or interface, with a depth-first traversal.<E> Optional
<E> findChildElement
(Class<E> elementType, Predicate<? super E> filter) Finds the first descendant element of the given class or interface and matching the givenPredicate
, with a depth-first traversal.<E> List
<E> findTopLevelElements
(Class<E> elementType) Looks for the nearest nested elements of the given class.freeze()
getBody()
Every node may potentially have HTML body.Every node may potentially have child elements.abstract String
getLabel()
Gets a short description, useful for links and lists, for this node.Gets the set of all pages this node directly links to; this does not include pages linked to by child elements.Gets an unmodifiable snapshot of all properties associated with a node.<E> E
requireChildElement
(Class<E> elementType) Finds the first descendant element of the given class or interface, with a depth-first traversal.<E> E
requireChildElement
(Class<E> elementType, Predicate<? super E> filter) Finds the first descendant element of the given class or interface and matching the givenPredicate
, with a depth-first traversal.void
setBody
(BufferResult body) boolean
setProperty
(String name, Object value) Sets a property on this node, if the property has not already been set.toString()
The toString callsgetLabel()
.
-
Field Details
-
lock
-
frozen
protected volatile boolean frozen
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
toString
The toString callsgetLabel()
. -
freeze
-
checkNotFrozen
- Throws:
FrozenException
-
getProperty
Gets an unmodifiable snapshot of all properties associated with a node. The returned map will not change, even if properties are added to the node. -
setProperty
Sets a property on this node, if the property has not already been set. Setting a property tonull
still marks the property as used and associates it withnull
.- Returns:
true
when the property was added orfalse
when the property already existed (including possibly with anull
value).- Throws:
FrozenException
- properties may not be set once the node is frozen
-
getChildElements
Every node may potentially have child elements. -
addChildElement
Adds a child element to this node. -
getPageLinks
Gets the set of all pages this node directly links to; this does not include pages linked to by child elements. -
addPageLink
-
getBody
Every node may potentially have HTML body. -
setBody
-
getLabel
Gets a short description, useful for links and lists, for this node. -
appendLabel
Deprecated, for removal: This API element is subject to removal in a future version.Please usegetLabel()
Appends a short description, useful for links and lists, for this node.- Throws:
IOException
-
findTopLevelElements
Looks for the nearest nested elements of the given class. These elements may be direct descendants or descendants further down the tree, but only the top-most descendants are returned.
If the node is a page, its elements are checked, but the elements of its child pages are not.
- Returns:
- The unmodifiable list of top-level matches, in the order they were declared in the page, or empty list if none found.
-
findChildElement
Finds the first descendant element of the given class or interface and matching the given
Predicate
, with a depth-first traversal.If the node is a page, its elements are checked, but the elements of its child pages are not.
- Returns:
- The element or
Optional.empty()
when not found.
-
findChildElement
Finds the first descendant element of the given class or interface, with a depth-first traversal.
If the node is a page, its elements are checked, but the elements of its child pages are not.
- Returns:
- The element or
Optional.empty()
when not found.
-
requireChildElement
public <E> E requireChildElement(Class<E> elementType, Predicate<? super E> filter) throws NoSuchElementException Finds the first descendant element of the given class or interface and matching the given
Predicate
, with a depth-first traversal.If the node is a page, its elements are checked, but the elements of its child pages are not.
- Returns:
- The element.
- Throws:
NoSuchElementException
- when not found.
-
requireChildElement
Finds the first descendant element of the given class or interface, with a depth-first traversal.
If the node is a page, its elements are checked, but the elements of its child pages are not.
- Returns:
- The element.
- Throws:
NoSuchElementException
- when not found.
-
getLabel()