Class Node

  • All Implemented Interfaces:
    Direct Known Subclasses:
    Element, Page

    public abstract class Node
    extends Object
    implements Freezable<Node>
    A node contains elements, but is not necessarily an element itself. A node can also have references to pages. A node can have a captured body.
    • Field Detail

      • lock

        protected final Object lock
      • frozen

        protected volatile boolean frozen
    • Constructor Detail

      • Node

        public Node()
    • Method Detail

      • 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 to null still marks the property as used and associates it with null.
        true when the property was added or false when the property already existed (including possibly with a null value).
        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.
      • getLabel

        public abstract String getLabel()
        Gets a short description, useful for links and lists, for this node.
      • findTopLevelElements

        public <E extends ElementList<E> findTopLevelElements​(Class<E> elementType)

        Looks for the nearest nested elements of the given class. These elements may be direct descendents or descendents further down the tree, but only the top-most descendents are returned.

        If the node is a page, its elements are checked, but the elements of its child pages are not.

        The unmodifiable list of top-level matches, in the order they were declared in the page, or empty list if none found.