java.lang.Object
com.northconcepts.datapipeline.core.Node
All Implemented Interfaces:
Session, Serializable
Direct Known Subclasses:
Field, ValueNode

public abstract class Node extends Object implements Session, Serializable
Node is the base class for all persistent data in Data Pipeline. It is the superclass for records, fields, arrays, and values.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    DuplicateNodeAction lists all actions that can be taken automatically when a target field already exists during a record copy or lookup.
    static enum 
    NodeType lists all concrete data node types used in Data Pipeline.

    Nested classes/interfaces inherited from interface com.northconcepts.datapipeline.core.Session

    Session.SessionImpl
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Throws a DataException if the proposed parent is this node or one of its descendants, which would create a cycle.
    <T> boolean
    Returns true if a session property exists for the given type.
    <T> boolean
    Returns true if a session property exists for the given type and name combination.
    boolean
    Returns true if a session property exists with the given name.
    void
    Copies all session properties from the given source session into this one.
    int
    Returns this node's distance from its root node.
    abstract Node.NodeType
    Returns the concrete Node.NodeType of this node.
    Returns the closest parent record's field that this node is the child of, otherwise null if one does not exist.
    abstract Node
    Returns the parent node that this node belongs to, or null if this is a root node.
    Returns the closest parent record that this node is the child of, otherwise null if one does not exist.
    <T> T
    Returns the session property value associated with the given type.
    <T> T
    Returns the session property value associated with the given type and name combination.
    <T> T
    Returns the session property value associated with the given name.
    abstract boolean
    Returns true if this node contains any sub nodes.
    abstract boolean
    Returns true if this node contains any descendant, record nodes.
    boolean
    Returns true if the supplied node is a descendant of this one.
    boolean
    Indicates if this record has a parent record (i.e.
    abstract boolean
    Returns true if this node does not contain a null value.
    abstract boolean
    Returns true if this node contains a null value.
    boolean
    Returns true if this node is a ValueNode (Record, ArrayValue, or SingleValue).
    Returns the set of all session property keys.
    protected abstract void
    Detaches the given child (matched by identity) from this node; called when the child is moved to another parent.
    void
    Removes all session properties from this session.
    <T> void
    setSessionProperty(Class<T> type, Object value)
    Sets a session property value keyed by type.
    <T> void
    setSessionProperty(Class<T> type, String name, Object value)
    Sets a session property value keyed by the given type and name combination.
    void
    Sets a session property value keyed by name.
    abstract String
    Returns a human-readable string representation of this node and its contents.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Node

      public Node()
  • Method Details

    • getParentNode

      public abstract Node getParentNode()
      Returns the parent node that this node belongs to, or null if this is a root node.
      Returns:
      the parent node, or null
    • removeChildNode

      protected abstract void removeChildNode(Node child)
      Detaches the given child (matched by identity) from this node; called when the child is moved to another parent.
    • isNull

      public abstract boolean isNull()
      Returns true if this node contains a null value. In concrete terms, only Field and SingleValue can contain nulls while not being null themselves. Both Record and ArrayValue will return false even if they have no values or null only values.
    • isNotNull

      public abstract boolean isNotNull()
      Returns true if this node does not contain a null value. In concrete terms, only Field and SingleValue can contain nulls while not being null themselves. Both Record and ArrayValue will return true even if they have no values or null only values.
    • getParentField

      public Field getParentField()
      Returns the closest parent record's field that this node is the child of, otherwise null if one does not exist.
      See Also:
    • getParentRecord

      public Record getParentRecord()
      Returns the closest parent record that this node is the child of, otherwise null if one does not exist.
      See Also:
    • getNodeType

      public abstract Node.NodeType getNodeType()
      Returns the concrete Node.NodeType of this node.
      Returns:
      the node type, never null
    • isChildNode

      public boolean isChildNode()
      Indicates if this record has a parent record (i.e. this record is part of a hierarchical structure). If this method returns true, getParentField() can be used to retrieve the parent record's field that this record is attached to.
      See Also:
    • hasChildNodes

      public abstract boolean hasChildNodes()
      Returns true if this node contains any sub nodes.
    • hasChildRecords

      public abstract boolean hasChildRecords()
      Returns true if this node contains any descendant, record nodes.
    • getNodeDepth

      public int getNodeDepth()
      Returns this node's distance from its root node. It returns 0 if it is the root node (i.e. it has no parents), 1 if it is the direct child of the root node, 2 if it is the grandchild of the root, and so on.
    • isAncestorOf

      public boolean isAncestorOf(Node node)
      Returns true if the supplied node is a descendant of this one.
    • assertNotAncestorOf

      protected void assertNotAncestorOf(Node parentNode)
      Throws a DataException if the proposed parent is this node or one of its descendants, which would create a cycle.
    • isValueNode

      public boolean isValueNode()
      Returns true if this node is a ValueNode (Record, ArrayValue, or SingleValue).
    • toString

      public abstract String toString()
      Returns a human-readable string representation of this node and its contents.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this node
    • keySet

      public Set<String> keySet()
      Returns the set of all session property keys.

      Returns the set of session property keys stored on this node. Returns an empty set if no session properties have been assigned.

      Specified by:
      keySet in interface Session
      Returns:
      the set of property keys, never null
    • containsSessionProperty

      public <T> boolean containsSessionProperty(Class<T> type, String name)
      Returns true if a session property exists for the given type and name combination.
      Specified by:
      containsSessionProperty in interface Session
      Type Parameters:
      T - the type used as part of the property key
      Parameters:
      type - the class used as part of the property key, or null to match by name only
      name - the property name, or null to match by type only
      Returns:
      true if the property exists
    • containsSessionProperty

      public <T> boolean containsSessionProperty(Class<T> type)
      Returns true if a session property exists for the given type.
      Specified by:
      containsSessionProperty in interface Session
      Type Parameters:
      T - the type used as the property key
      Parameters:
      type - the class used as the property key
      Returns:
      true if the property exists
    • containsSessionProperty

      public boolean containsSessionProperty(String name)
      Returns true if a session property exists with the given name.
      Specified by:
      containsSessionProperty in interface Session
      Parameters:
      name - the property name
      Returns:
      true if the property exists
    • copySessionPropertiesFrom

      public void copySessionPropertiesFrom(Session sourceSession)
      Copies all session properties from the given source session into this one.

      Copies all session properties from the given source session into this node's session. If the source session is null or empty, this method does nothing.

      Specified by:
      copySessionPropertiesFrom in interface Session
      Parameters:
      sourceSession - the source session to copy from, may be null
    • removeSessionProperties

      public void removeSessionProperties()
      Removes all session properties from this session.

      Removes all session properties from this node by discarding the internal session store.

      Specified by:
      removeSessionProperties in interface Session
    • getSessionProperty

      public <T> T getSessionProperty(Class<T> type, String name)
      Returns the session property value associated with the given type and name combination.
      Specified by:
      getSessionProperty in interface Session
      Type Parameters:
      T - the expected value type
      Parameters:
      type - the class used as part of the property key, or null to match by name only
      name - the property name, or null to match by type only
      Returns:
      the property value, or null if not found
    • getSessionProperty

      public <T> T getSessionProperty(Class<T> type)
      Returns the session property value associated with the given type.
      Specified by:
      getSessionProperty in interface Session
      Type Parameters:
      T - the expected value type
      Parameters:
      type - the class used as the property key
      Returns:
      the property value, or null if not found
    • getSessionProperty

      public <T> T getSessionProperty(String name)
      Returns the session property value associated with the given name.
      Specified by:
      getSessionProperty in interface Session
      Type Parameters:
      T - the expected value type
      Parameters:
      name - the property name
      Returns:
      the property value, or null if not found
    • setSessionProperty

      public <T> void setSessionProperty(Class<T> type, String name, Object value)
      Sets a session property value keyed by the given type and name combination.
      Specified by:
      setSessionProperty in interface Session
      Type Parameters:
      T - the type used as part of the property key
      Parameters:
      type - the class used as part of the property key, or null to match by name only
      name - the property name, or null to match by type only
      value - the value to store
    • setSessionProperty

      public <T> void setSessionProperty(Class<T> type, Object value)
      Sets a session property value keyed by type.
      Specified by:
      setSessionProperty in interface Session
      Type Parameters:
      T - the type used as the property key
      Parameters:
      type - the class used as the property key
      value - the value to store
    • setSessionProperty

      public void setSessionProperty(String name, Object value)
      Sets a session property value keyed by name.
      Specified by:
      setSessionProperty in interface Session
      Parameters:
      name - the property name
      value - the value to store