Package JsonFse

Class NodeArray


  • public class NodeArray
    extends NodeValue
    Node representing an array of values.
    Author:
    Friedemann Seebass
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected NodeElements mNodeElements
      Holds all elements of the array.
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeArray()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(NodeValue nv)
      Appends the value to the end of the element list.
      NodeValue get​(int idx)
      If the node is of type NodeObj or NodeArray get() delivers the element with index idx.
      java.lang.String getAsString​(int columnOffset, boolean hasLabel)
      Delivers recursively a node and all of its children as a formatted string.
      NodeValue getNext()
      If the node is of type NodeObj or NodeArray getNext() delivers the next element (of type NodePair or NodeValue).
      void setIdx​(int idx)
      Sets the index used by the getNext() method.
      int size()
      Returns the number of elements in the NodeArray.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mNodeElements

        protected NodeElements mNodeElements
        Holds all elements of the array.
    • Constructor Detail

      • NodeArray

        public NodeArray()
    • Method Detail

      • add

        public void add​(NodeValue nv)
        Appends the value to the end of the element list.
        Parameters:
        nv - The value to add.
      • getAsString

        public java.lang.String getAsString​(int columnOffset,
                                            boolean hasLabel)
        Description copied from class: Node
        Delivers recursively a node and all of its children as a formatted string. Child nodes and their elements are indented according to the following rules:
        • Each pair (of label and value) is in its own line.
        • Values containing sub elements (i. e. JSON objects and arrays) start in the same line as the label.
        • If they contain no or only one element they are written in the same line, following directly after the label.
        • If they contain more than one element the opening bracket is written into the same line as the label, but each element in its own line. The elements are indented further mTabWidth spaces. The closing bracket is written in its own line, but in the same column as the opening bracket.
        Overrides:
        getAsString in class Node
        Parameters:
        columnOffset - Number of spaces an element is indented.
        hasLabel - If true this node starts in a line with a label. The element must not be indented then but follows immediately after the label.
        Returns:
        Formatted string of the node and its childs.
      • setIdx

        public void setIdx​(int idx)
        Sets the index used by the getNext() method.
        Parameters:
        idx - index where the next getNext() call is reading from
      • getNext

        public NodeValue getNext()
        Description copied from class: Node
        If the node is of type NodeObj or NodeArray getNext() delivers the next element (of type NodePair or NodeValue). The index the element is read from can be set with setIdx(). The index is incremented on each call automatically.
        Overrides:
        getNext in class Node
        Returns:
        The next element in a list of NodePairs or NoveValues or null if no more elements are available.
      • get

        public NodeValue get​(int idx)
        Description copied from class: Node
        If the node is of type NodeObj or NodeArray get() delivers the element with index idx.
        Overrides:
        get in class Node
        Parameters:
        idx - Index of the wanted NodePair or NodeValue out of a list of these elements.
        Returns:
        The element with index idx.
      • size

        public int size()
        Returns the number of elements in the NodeArray.
        Returns:
        The number of elements in this object.