Class SNode

  • All Implemented Interfaces:
    SNode
    Direct Known Subclasses:
    InterfaceSNode, LazySNode

    public class SNode
    extends Object
    implements SNode
    As a tribute to legacy code, we do allow access to constant and meta-info objects of a node without read access. It's not encouraged for a new code, though, and might change in future, that's why it's stated here and not in openapi.SNode
    • Method Detail

      • getConcept

        @NotNull
        public SConcept getConcept()
        Description copied from interface: SNode
        The concept that this node represents. Concepts can be checked for equality with equals().
        Specified by:
        getConcept in interface SNode
      • insertChildAfter

        public void insertChildAfter​(@NotNull
                                     SContainmentLink role,
                                     @NotNull
                                     SNode child,
                                     @Nullable
                                     SNode anchor)
        Description copied from interface: SNode
        Inserts the given node as a child of the current node of the specified role right after the anchor node.
        Specified by:
        insertChildAfter in interface SNode
        Parameters:
        role - a role to insert new child into
        child - a node to insert
        anchor - a new child node will be inserted just after this node. If anchor is not specified, a new child is inserted as a first child. If anchor is the last child element, newly added child becomes tail of collection
      • assertCanRead

        protected final void assertCanRead()
      • getNodeId

        public SNodeId getNodeId()
        Description copied from interface: SNode
        Uniquely identifies the node within its containing model. May also be null. Does not produce node read event as the result value can't be changed.
        Specified by:
        getNodeId in interface SNode
      • getContainingRoot

        @NotNull
        public SNode getContainingRoot()
        Description copied from interface: SNode
        Returns the ancestor of current node, which parent is null Does not produce read on current as current is already obtained
        Specified by:
        getContainingRoot in interface SNode
        Returns:
        root containing this node
      • getName

        public String getName()
        Description copied from interface: SNode
        For instances of INamedConcept concepts retrieves "name" property
        Specified by:
        getName in interface SNode
        Returns:
        null if node is not instance of INamedConcept
      • getParent

        public final SNode getParent()
        Description copied from interface: SNode
        Returns the parent of this node Does not produce read on current as current is already obtained, does notify read for the parent.
        Specified by:
        getParent in interface SNode
        Returns:
        parent of this node
      • removeChild

        public void removeChild​(@NotNull
                                SNode child)
        Removes child from current node. This affects only link between current node and its child, but not links in subtree of child node.

        Differs from delete(). FIXME please explain how it differs from delete()

        Specified by:
        removeChild in interface SNode
        Parameters:
        child -
      • getPresentation

        public String getPresentation()
        Description copied from interface: SNode
        A string representing the node used to show the node in UI
        Specified by:
        getPresentation in interface SNode
      • getReference

        @NotNull
        public SNodeReference getReference()
        Description copied from interface: SNode
        Uniquely identifies the node in a repository. Never changes between subsequent read and write actions and behaves as a "weak reference" for a node Represents the only correct way to pass or store nodes between read/write actions. Does not produce node read event as the node is already obtained, and the read event has already happened. If obtained for a node that is not in repository, can return invalid reference
        Specified by:
        getReference in interface SNode
      • getChildren

        @NotNull
        public List<SNode> getChildren()
        Description copied from interface: SNode
        Returns an immutable collection of all children. Read access policy is same to getChildren(role)
        Specified by:
        getChildren in interface SNode
      • getReferences

        @NotNull
        public List<SReference> getReferences()
        Description copied from interface: SNode
        Retrieves all SReferences from the node. Since SReference can refer to nodes by name and resolve them dynamically, this method may be able to help you resolve the target nodes even when working with invalid code.

        The returned collection is immutable. Produces read access on the node.

        Specified by:
        getReferences in interface SNode
      • getFirstChild

        public SNode getFirstChild()
        Description copied from interface: SNode
        Works together with getLastChild(). Allows to iterate through a collection of all children.
        Specified by:
        getFirstChild in interface SNode
        Returns:
        first element in a collection of children
      • getLastChild

        public SNode getLastChild()
        Description copied from interface: SNode
        Works together with getFirstChild(). Allows to iterate through a collection of all children.
        Specified by:
        getLastChild in interface SNode
        Returns:
        last element in a collection of children
      • getPrevSibling

        public SNode getPrevSibling()
        Description copied from interface: SNode
        no parent -> no sibling. Root has no siblings Does not produce read on current as current is already obtained Notifies read for the parent node and sibling node, if any.
        Specified by:
        getPrevSibling in interface SNode
      • getNextSibling

        public SNode getNextSibling()
        Description copied from interface: SNode
        no parent -> no sibling. Root has no siblings Does not produce read on current as current is already obtained. Notifies read for the parent node and sibling node, if any.
        Specified by:
        getNextSibling in interface SNode
      • getModel

        public SModel getModel()
        Description copied from interface: SNode
        Containing model or null if the node is not contained in any model Does not produce node read event as the function depending on model is not a pure node function.
        Specified by:
        getModel in interface SNode
        See Also:
        SNodeAccessListener
      • firstChild

        protected SNode firstChild()
      • treePrevious

        protected SNode treePrevious()
      • treeNext

        public SNode treeNext()
      • treeParent

        protected SNode treeParent()
      • children_insertBefore

        protected void children_insertBefore​(SNode anchor,
                                             @NotNull
                                             SNode node)
      • children_remove

        protected void children_remove​(@NotNull
                                       SNode node)
      • getContainmentLink

        public SContainmentLink getContainmentLink()
        Description copied from interface: SNode
        Returns role of this node in parent node Returns null if a node has no parent
        Specified by:
        getContainmentLink in interface SNode
      • getProperty

        public String getProperty​(@NotNull
                                  SProperty property)
        Description copied from interface: SNode
        Returns the value of this property
        Specified by:
        getProperty in interface SNode
        Returns:
        value of a property or null if the property was not set
      • setProperty

        public void setProperty​(@NotNull
                                SProperty property,
                                String propertyValue)
        Description copied from interface: SNode
        Sets the value of the raw property. Constraints are not checked.
        Specified by:
        setProperty in interface SNode
      • getReferenceTarget

        public SNode getReferenceTarget​(@NotNull
                                        SReferenceLink role)
        Description copied from interface: SNode
        Null means the reference has not been set or was set to null. It's impossible to the distinguish the two cases.
        Specified by:
        getReferenceTarget in interface SNode
      • getReference

        public SReference getReference​(@NotNull
                                       SReferenceLink role)
        Description copied from interface: SNode
        Retrieves an SReference of the given role to a node. Since SReference can refer to nodes by name and resolve them dynamically, this method may be able to help you resolve the target node even when working with invalid code.
        Specified by:
        getReference in interface SNode
      • setReference

        public void setReference​(@NotNull
                                 SReferenceLink role,
                                 SReference toAdd)
        Description copied from interface: SNode
        Sets a reference of the given role to a node that is resolved from the SReference. Since SReference can refer to nodes by name and resolve them dynamically, this method may be able to resolve the target node even when working with invalid code.
        Specified by:
        setReference in interface SNode
      • insertChildBefore

        public void insertChildBefore​(@NotNull
                                      SContainmentLink role,
                                      @NotNull
                                      SNode child,
                                      @Nullable
                                      SNode anchor)
        Description copied from interface: SNode
        Inserts the given node as a child of the current node of the specified role right in front of the anchor node.
        Specified by:
        insertChildBefore in interface SNode
        Parameters:
        role - a role to insert new child into
        child - a node to insert
        anchor - a new child node will be inserted just before this node. If anchor is not specified, a new child is inserted as a last child. If anchor is the first child element, newly added child becomes head of collection
      • getChildren

        @NotNull
        public List<SNode> getChildren​(SContainmentLink role)
        Description copied from interface: SNode
        Returns an immutable collection of children in the specified role. Does not produce read on current as current is already obtained, produces read accesses to child nodes lazily (when really accessed), does not produce read accesses for skipped children
        Specified by:
        getChildren in interface SNode