Class CipTree

  • Direct Known Subclasses:
    CipTreeCtx

    public class CipTree
    extends java.lang.Object
    Implement a Hierarchy of objects where children know their parent and children are "named" by a single CIP Path Segment. Access to children is thread-safe without synchronization.

    Subclasses, like CipObject, provide all other functionality.

    • Method Detail

      • getEPathImpl

        protected CipPath getEPathImpl()
        Retrieve the application path that leads to this object starting at the root (no parent). Will be called by getEPath() and the result cached by default.

        Root elements must override this to return an empty CipPath.

        Returns:
      • getEPath

        public CipPath getEPath()
        Retrieve the application path that leads to this object starting at the device.
        Returns:
      • cleanup

        protected void cleanup​(CipTree oldParent,
                               CipTree replacement)
        When an element is removed from a parent's map of children, the element is notified by this method, which is given the prior parent element, and the replacement element (if known).
        Parameters:
        oldParent -
        replacement -
      • setChild

        public CipTree setChild​(CipTree child,
                                PathSegment seg)
        Assign a given CipTree as a child of this CipTree identified by a specific PathSegment. If that path segment is already registered to a different child CipTree, replace it and return that old child.
        Parameters:
        child - The CipTree to register.
        seg - The Path Segment that identifies this child.
        Returns:
        The replaced CipTree, if any.
      • removeChild

        public boolean removeChild​(CipTree child,
                                   PathSegment seg)
        Conditionally remove a particular Segment from the children map if it currently points to the given child.
        Parameters:
        child - The CipTree to remove.
        seg - The segment that identifies the child.
      • getChild

        public CipTree getChild​(PathSegment seg)
        Lookup a child for a particular segment.
        Parameters:
        seg -
        Returns:
      • getChildren

        public java.util.List<CipTree> getChildren()
      • follow

        public CipTree follow​(java.util.List<PathSegment> path)
        Follow a path to the given descendant. If the path cannot be completely followed, throw an exception containing the last CipTree found and the remaining path.
      • getParent

        public CipTree getParent()
      • setParent

        public CipTree setParent​(CipTree parent)
        Set or remove the parent of this CipTree, possibly removing this object from a previous parent before assigning to the new parent. Override this method if additional housekeeping is required when assigning or removing parents.
        Parameters:
        parent - The new parent of this object.
        Returns:
        The object replaced by this object in the parent, if any.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object