java.lang.Object
esa.opensf.osfi.ArrayNode<V,S>
- Type Parameters:
V- Type used to store values. May be an array for parsed nodes, or a String for unparsed.S- CRTP parameter, used so thatgetSubNodes()and similar return the same type.
- Direct Known Subclasses:
ArrayNode.Parsed,ArrayNode.Raw
public abstract sealed class ArrayNode<V,S extends ArrayNode<V,S>>
extends Object
permits ArrayNode.Raw, ArrayNode.Parsed<A>
Class that represents a tree with data (leaf) nodes and internal nodes. The data
may be raw (a String with the unparsed values) or fully parsed.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA parsed tree that represents the values of (part of) an ARRAY-valued parameter.static final classAn unparsed tree that represents (part of) an ARRAY-valued parameter. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringgetData()final VgetDataAtSub(int... indices) Equivalent togetSubNodeAt(indices).getData(), except that if indices is empty, this this method returns the result of callinggetData()on this instead of throwing.protected abstract intfinal intgetDim()Compute the rectangular envelope for the dimensions of this array node, considering all nodes below it in the tree.final SgetSubNodeAt(int... indices) Equivalent to callings = s.getSubNodes().get(i)for each index given, starting with this object.protected booleaninnerEquals(ArrayNode<?, ?> o) Helper for subclasses to implementObject.equals(Object)for internal nodes.protected intHelper for subclasses to implementObject.hashCode()in internal nodesfinal booleantoString()
-
Field Details
-
elems
Elements for a data node. If null, this is an internal node.
-
-
Constructor Details
-
ArrayNode
Create a data node with the given contents.- Parameters:
values- Data to store in the leaf node.
-
ArrayNode
Create an internal node with the given subnodes.- Parameters:
subNodes- Child nodes. The list is used as-is, not copied.
-
-
Method Details
-
isDataNode
public final boolean isDataNode()- Returns:
- true if this node was built with data elements, false if it was built with subnodes.
-
getData
- Returns:
- the raw data elements, or null if this is an internal node without data.
-
getSubNodes
- Returns:
- the list of subnodes, or the empty list if this is a data node without subnodes.
-
getSubNodeAt
Equivalent to callings = s.getSubNodes().get(i)for each index given, starting with this object. The final value ofsis returned.- Parameters:
indices- Index values for each dimension.- Returns:
- the subnode at the given index position in the tree.
- Throws:
IllegalArgumentException- if s is empty.IndexOutOfBoundsException- if one of the indices is invalid.
-
getDataAtSub
Equivalent togetSubNodeAt(indices).getData(), except that if indices is empty, this this method returns the result of callinggetData()on this instead of throwing.- Parameters:
indices- Index values for each dimension.- Returns:
- the data at the given index position in the tree.
- Throws:
IndexOutOfBoundsException- if one of the indices is invalid.- See Also:
-
getDim
public final int getDim()- Returns:
- the size of this array node (i.e. of this dimension level).
-
getDataDim
protected abstract int getDataDim()- Returns:
- the size of the data elements (for a data node).
-
getDimsEnvelope
Compute the rectangular envelope for the dimensions of this array node, considering all nodes below it in the tree.- Returns:
- Size of the rectangular multi-dimensional array that can contain this subtree.
-
toString
-
innerEquals
Helper for subclasses to implementObject.equals(Object)for internal nodes. -
innerHashCode
protected int innerHashCode()Helper for subclasses to implementObject.hashCode()in internal nodes -
dataToStr
- Returns:
- String version of the data elements.
-