Class ChainedNode
java.lang.Object
ch.nolix.base.document.chainednode.ChainedNode
- All Implemented Interfaces:
IOptionalHeaderHolder, IChainedNode, BlanknessRequestable
A
ChainedNode has the following attributes. -0 or 1 header -an
arbitrary number of child ChainedNodes -0 or 1 next
ChainedNode
A ChainedNode is not mutable.- Author:
- Silvan Wyss
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanstatic ChainedNodefromChainedNode(IChainedNode chainedNode) static ChainedNodestatic ChainedNodefromString(String string) getChildNodeAtOneBasedIndex(int index) intstatic StringgetEscapeStringForString(String string) getFirstChildNodeWithHeader(String header) doubleintstatic StringgetStoredginStringFromEscapeString(String escapeString) inthashCode()booleanbooleanbooleanisBlank()doubletoDouble()inttoInt()toNode()toString()static ChainedNodewithChildNodes(INode<?>... nodes) static ChainedNodewithChildNodesFromNodes(Iterable<? extends INode<?>> attributes) Creates a newChainedNodewith the given attributes.static ChainedNodewithHeader(String header) static ChainedNodewithHeaderAndChildNode(String header, IChainedNode childNode) static ChainedNodewithHeaderAndChildNode(String header, INode<?> childNode) static ChainedNodewithHeaderAndChildNodes(String header, IChainedNode... childNodes) static ChainedNodewithHeaderAndChildNodes(String header, Iterable<? extends IChainedNode> attributes) static ChainedNodewithHeaderAndChildNodesFromNodes(String header, INode<?> childNode, INode<?>... childNodes) Creates a newChainedNodewith the given header and attributes.static ChainedNodewithHeaderAndChildNodesFromNodes(String header, Iterable<? extends INode<?>> attributes) Creates a newChainedNodewith the given header and attributes.static ChainedNodewithHeaderAndNextNode(String header, ChainedNode nextNode) Methods inherited from interface IOptionalHeaderHolder
getHeaderOrEmptyString, getOptionalHeader, hasHeader
-
Field Details
-
EMPTY_CHAINED_NODE
-
DOT_CODE
- See Also:
-
COMMA_CODE
- See Also:
-
DOLLAR_SYMBOL_CODE
- See Also:
-
OPEN_BRACKET_CODE
- See Also:
-
CLOSED_BRACKET_CODE
- See Also:
-
-
Method Details
-
fromChainedNode
- Parameters:
chainedNode-- Returns:
- a
ChainedNodefrom the given chainedNode. - Throws:
RuntimeException- if the given chainedNode is null.
-
fromNode
- Parameters:
node-- Returns:
- a new
ChainedNodefrom the given node.
-
fromString
- Parameters:
string-- Returns:
- a new
ChainedNodethe given string represents. - Throws:
RuntimeException- if the given string does not represent aChainedNode.
-
getEscapeStringForString
-
getStoredginStringFromEscapeString
-
withChildNodes
- Parameters:
nodes-- Returns:
- a new
ChainedNodewith the childNodes - Throws:
RuntimeException- if the given nodes is null.RuntimeException- if one of the given nodes is null.
-
withChildNodesFromNodes
Creates a newChainedNodewith the given attributes.- Parameters:
attributes-- Returns:
- a new
ChainedNodewith the given attributes. - Throws:
RuntimeException- if one of the given attributes is null.
-
withHeader
- Parameters:
header-- Returns:
- a new
ChainedNodewith the given header. - Throws:
RuntimeException- if the given header is null.RuntimeException- if the given header is blank.
-
withHeaderAndChildNode
- Parameters:
header-childNode-- Returns:
- a new
ChainedNodewith the given header and childNode. - Throws:
RuntimeException- if the given header is null or blankRuntimeException- if the given childNode is null.
-
withHeaderAndChildNodes
- Parameters:
header-childNodes-- Returns:
- a new
ChainedNodewith the given header and childNodes. - Throws:
RuntimeException- if the given header is null or blank.RuntimeException- if the given header is blank.RuntimeException- if the given childNodes is null.RuntimeException- if one of the given childNodes is null.
-
withHeaderAndChildNode
- Parameters:
header-childNode-- Returns:
- a new
ChainedNodewith the given header and childNode. - Throws:
RuntimeException- if the given header is null or blank.RuntimeException- if the given header is blank.
-
withHeaderAndChildNodes
public static ChainedNode withHeaderAndChildNodes(String header, Iterable<? extends IChainedNode> attributes) - Parameters:
header-attributes-- Returns:
- a new
ChainedNodewith the given header and attributes. - Throws:
RuntimeException- if the given header is null.RuntimeException- if the given header is blank.RuntimeException- if one of the given attribute is null.
-
withHeaderAndChildNodesFromNodes
public static ChainedNode withHeaderAndChildNodesFromNodes(String header, INode<?> childNode, INode<?>... childNodes) Creates a newChainedNodewith the given header and attributes.- Parameters:
header-childNode-childNodes-- Returns:
- a new
ChainedNodewith the given header and attributes. - Throws:
RuntimeException- if the given header is null.RuntimeException- if the given header is blank.RuntimeException- if one of the given attributes is null.
-
withHeaderAndChildNodesFromNodes
public static ChainedNode withHeaderAndChildNodesFromNodes(String header, Iterable<? extends INode<?>> attributes) Creates a newChainedNodewith the given header and attributes.- Parameters:
header-attributes-- Returns:
- a new
ChainedNodewith the given header and attributes. - Throws:
RuntimeException- if the given header is null.RuntimeException- if the given header is blank.RuntimeException- if one of the given attributes is null.
-
withHeaderAndNextNode
- Parameters:
header-nextNode-- Returns:
- a new
ChainedNodewith the given header and nextNode. - Throws:
RuntimeException- if the given header is null.RuntimeException- if the given header is blank.RuntimeException- if the given nextNode is null.
-
containsChildNodes
public boolean containsChildNodes()- Specified by:
containsChildNodesin interfaceIChainedNode- Returns:
- true if the current
IChainedNodecontains child nodes, false otherwise.
-
equals
-
getChildNodeCount
public int getChildNodeCount()- Specified by:
getChildNodeCountin interfaceIChainedNode- Returns:
- the number of attributes of the current
ChainedNode.
-
getChildNodeAtOneBasedIndex
- Specified by:
getChildNodeAtOneBasedIndexin interfaceIChainedNode- Parameters:
index-- Returns:
- the attribute at the given index of the current
ChainedNode. - Throws:
RuntimeException- if the given index is not positive.ArgumentDoesNotHaveAttributeException- if the currentChainedNodedoes not contain an attribute at the given index.
-
getChildNodes
- Specified by:
getChildNodesin interfaceIChainedNode- Returns:
- the attributes of the current
ChainedNode.
-
getFirstChildNodeWithHeader
- Specified by:
getFirstChildNodeWithHeaderin interfaceIChainedNode- Parameters:
header-- Returns:
- the first attribute with the given header from the current
ChainedNode. - Throws:
ArgumentDoesNotHaveAttributeException- if the currentChainedNodedoes not contain an attribute with the given header.
-
getHeader
- Specified by:
getHeaderin interfaceIOptionalHeaderHolder- Returns:
- the header of the current
ChainedNode. - Throws:
ArgumentDoesNotHaveAttributeException- if the currentChainedNodedoes not have a header.
-
getNextNode
- Specified by:
getNextNodein interfaceIChainedNode- Returns:
- the next node of the current
ChainedNode. - Throws:
ArgumentDoesNotHaveAttributeException- if the currentChainedNodedoes not have a next node.
-
getSingleChildNode
- Specified by:
getSingleChildNodein interfaceIChainedNode- Returns:
- the one attribute of the current
ChainedNode. - Throws:
RuntimeException- if the currentChainedNodedoes not contain an attribute.RuntimeException- if the currentChainedNodecontains several attributes.
-
getSingleChildNodeHeader
- Specified by:
getSingleChildNodeHeaderin interfaceIChainedNode- Returns:
- the header of the single child node of the current
IChainedNode.
-
getSingleChildNodeAsDouble
public double getSingleChildNodeAsDouble()- Specified by:
getSingleChildNodeAsDoublein interfaceIChainedNode- Returns:
- a double representation of the single child node of the current
IChainedNode.
-
getSingleChildNodeAsInt
public int getSingleChildNodeAsInt()- Specified by:
getSingleChildNodeAsIntin interfaceIChainedNode- Returns:
- a int representation of the single child node of the current
IChainedNode.
-
getSingleChildNodeAsString
- Specified by:
getSingleChildNodeAsStringin interfaceIChainedNode- Returns:
- a
Stringrepresentation of the single child node of the currentIChainedNode.
-
hashCode
-
hasHeader
public boolean hasHeader()- Specified by:
hasHeaderin interfaceIOptionalHeaderHolder- Returns:
- true if the current
IOptionalHeaderHolderhas a header, false otherwise.
-
hasNextNode
public boolean hasNextNode()- Specified by:
hasNextNodein interfaceIChainedNode- Returns:
- true if the current
IChainedNodehas a next node, false otherwise.
-
isBlank
public boolean isBlank()- Specified by:
isBlankin interfaceBlanknessRequestable- Returns:
- true if
BlanknessRequestableis blank, false otherwise.
-
toDouble
public double toDouble()- Specified by:
toDoublein interfaceIChainedNode- Returns:
- the double the current
IChainedNoderepresents.
-
toInt
public int toInt()- Specified by:
toIntin interfaceIChainedNode- Returns:
- the int the current
IChainedNoderepresents.
-
toNode
AIChainedNoderepresents aINodeif: -TheIChainedNodedoes not have a next node. -Each child nodes of theIChainedNoderepresents aINode.- Specified by:
toNodein interfaceIChainedNode- Returns:
- a
INoderepresentation of the currentIChainedNode.
-
toString
-