- java.lang.Object
-
- com.semanticcms.core.model.Node
-
-
Constructor Summary
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Long
addChildElement(Element childElement, ElementWriter elementWriter)
Adds a child element to this node.void
addPageLink(PageRef pageLink)
void
appendLabel(Appendable out)
Deprecated, for removal: This API element is subject to removal in a future version.Please usegetLabel()
protected void
checkNotFrozen()
<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.Node
freeze()
BufferResult
getBody()
Every node may potentially have HTML body.List<Element>
getChildElements()
Every node may potentially have child elements.abstract String
getLabel()
Gets a short description, useful for links and lists, for this node.Set<PageRef>
getPageLinks()
Gets the set of all pages this node directly links to; this does not include pages linked to by child elements.Map<String,Object>
getProperty()
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.String
toString()
The toString callsgetLabel()
.
-
-
-
Field Detail
-
lock
protected final Object lock
-
frozen
protected volatile boolean frozen
-
-
Method Detail
-
toString
public String toString()
The toString callsgetLabel()
.
-
checkNotFrozen
protected void checkNotFrozen() throws FrozenException
- Throws:
FrozenException
-
getProperty
public Map<String,Object> 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
public boolean setProperty(String name, Object value) throws FrozenException
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
public List<Element> getChildElements()
Every node may potentially have child elements.
-
addChildElement
public Long addChildElement(Element childElement, ElementWriter elementWriter)
Adds a child element to this node.
-
getPageLinks
public Set<PageRef> getPageLinks()
Gets the set of all pages this node directly links to; this does not include pages linked to by child elements.
-
addPageLink
public void addPageLink(PageRef pageLink)
-
getBody
public BufferResult getBody()
Every node may potentially have HTML body.
-
setBody
public void setBody(BufferResult body)
-
getLabel
public abstract String getLabel()
Gets a short description, useful for links and lists, for this node.
-
appendLabel
@Deprecated(forRemoval=true) public final void appendLabel(Appendable out) throws IOException
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
public <E> List<E> findTopLevelElements(Class<E> elementType)
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
public <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 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
public <E> Optional<E> findChildElement(Class<E> elementType)
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
public <E> E requireChildElement(Class<E> elementType) throws NoSuchElementException
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.
-
-