Class Node
java.lang.Object
com.northconcepts.datapipeline.core.Node
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionstatic enumDuplicateNodeAction lists all actions that can be taken automatically when a target field already exists during a record copy or lookup.static enumNodeType 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertNotAncestorOf(Node parentNode) Throws aDataExceptionif the proposed parent is this node or one of its descendants, which would create a cycle.<T> booleancontainsSessionProperty(Class<T> type) Returnstrueif a session property exists for the given type.<T> booleancontainsSessionProperty(Class<T> type, String name) Returnstrueif a session property exists for the given type and name combination.booleanReturnstrueif a session property exists with the given name.voidcopySessionPropertiesFrom(Session sourceSession) Copies all session properties from the given source session into this one.intReturns this node's distance from its root node.abstract Node.NodeTypeReturns the concreteNode.NodeTypeof this node.Returns the closest parent record's field that this node is the child of, otherwise null if one does not exist.abstract NodeReturns the parent node that this node belongs to, ornullif 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> TgetSessionProperty(Class<T> type) Returns the session property value associated with the given type.<T> TgetSessionProperty(Class<T> type, String name) Returns the session property value associated with the given type and name combination.<T> TgetSessionProperty(String name) Returns the session property value associated with the given name.abstract booleanReturnstrueif this node contains any sub nodes.abstract booleanReturnstrueif this node contains any descendant, record nodes.booleanisAncestorOf(Node node) Returnstrueif the supplied node is a descendant of this one.booleanIndicates if this record has a parent record (i.e.abstract booleanReturnstrueif this node does not contain a null value.abstract booleanisNull()Returnstrueif this node contains a null value.booleanReturnstrueif this node is a ValueNode (Record, ArrayValue, or SingleValue).keySet()Returns the set of all session property keys.protected abstract voidremoveChildNode(Node child) Detaches the given child (matched by identity) from this node; called when the child is moved to another parent.voidRemoves all session properties from this session.<T> voidsetSessionProperty(Class<T> type, Object value) Sets a session property value keyed by type.<T> voidsetSessionProperty(Class<T> type, String name, Object value) Sets a session property value keyed by the given type and name combination.voidsetSessionProperty(String name, Object value) Sets a session property value keyed by name.abstract StringtoString()Returns a human-readable string representation of this node and its contents.
-
Field Details
-
session
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
getParentNode
Returns the parent node that this node belongs to, ornullif this is a root node.- Returns:
- the parent node, or
null
-
removeChildNode
Detaches the given child (matched by identity) from this node; called when the child is moved to another parent. -
isNull
public abstract boolean isNull()Returnstrueif this node contains a null value. In concrete terms, onlyFieldandSingleValuecan contain nulls while not being null themselves. BothRecordandArrayValuewill returnfalseeven if they have no values or null only values. -
isNotNull
public abstract boolean isNotNull()Returnstrueif this node does not contain a null value. In concrete terms, onlyFieldandSingleValuecan contain nulls while not being null themselves. BothRecordandArrayValuewill returntrueeven if they have no values or null only values. -
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
Returns the closest parent record that this node is the child of, otherwise null if one does not exist.- See Also:
-
getNodeType
Returns the concreteNode.NodeTypeof 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()Returnstrueif this node contains any sub nodes. -
hasChildRecords
public abstract boolean hasChildRecords()Returnstrueif 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
Returnstrueif the supplied node is a descendant of this one. -
assertNotAncestorOf
Throws aDataExceptionif the proposed parent is this node or one of its descendants, which would create a cycle. -
isValueNode
public boolean isValueNode()Returnstrueif this node is a ValueNode (Record, ArrayValue, or SingleValue). -
toString
Returns a human-readable string representation of this node and its contents. -
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.
-
containsSessionProperty
Returnstrueif a session property exists for the given type and name combination.- Specified by:
containsSessionPropertyin interfaceSession- Type Parameters:
T- the type used as part of the property key- Parameters:
type- the class used as part of the property key, ornullto match by name onlyname- the property name, ornullto match by type only- Returns:
trueif the property exists
-
containsSessionProperty
Returnstrueif a session property exists for the given type.- Specified by:
containsSessionPropertyin interfaceSession- Type Parameters:
T- the type used as the property key- Parameters:
type- the class used as the property key- Returns:
trueif the property exists
-
containsSessionProperty
Returnstrueif a session property exists with the given name.- Specified by:
containsSessionPropertyin interfaceSession- Parameters:
name- the property name- Returns:
trueif the property exists
-
copySessionPropertiesFrom
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
nullor empty, this method does nothing.- Specified by:
copySessionPropertiesFromin interfaceSession- Parameters:
sourceSession- the source session to copy from, may benull
-
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:
removeSessionPropertiesin interfaceSession
-
getSessionProperty
Returns the session property value associated with the given type and name combination.- Specified by:
getSessionPropertyin interfaceSession- Type Parameters:
T- the expected value type- Parameters:
type- the class used as part of the property key, ornullto match by name onlyname- the property name, ornullto match by type only- Returns:
- the property value, or
nullif not found
-
getSessionProperty
Returns the session property value associated with the given type.- Specified by:
getSessionPropertyin interfaceSession- Type Parameters:
T- the expected value type- Parameters:
type- the class used as the property key- Returns:
- the property value, or
nullif not found
-
getSessionProperty
Returns the session property value associated with the given name.- Specified by:
getSessionPropertyin interfaceSession- Type Parameters:
T- the expected value type- Parameters:
name- the property name- Returns:
- the property value, or
nullif not found
-
setSessionProperty
Sets a session property value keyed by the given type and name combination.- Specified by:
setSessionPropertyin interfaceSession- Type Parameters:
T- the type used as part of the property key- Parameters:
type- the class used as part of the property key, ornullto match by name onlyname- the property name, ornullto match by type onlyvalue- the value to store
-
setSessionProperty
Sets a session property value keyed by type.- Specified by:
setSessionPropertyin interfaceSession- Type Parameters:
T- the type used as the property key- Parameters:
type- the class used as the property keyvalue- the value to store
-
setSessionProperty
Sets a session property value keyed by name.- Specified by:
setSessionPropertyin interfaceSession- Parameters:
name- the property namevalue- the value to store
-