Package JsonFse
Class NodeObj
- java.lang.Object
-
- JsonFse.Node
-
- JsonFse.NodeValue
-
- JsonFse.NodeObj
-
public class NodeObj extends NodeValue
Represents a whole JSON object, i. e. its members, i. e. a list of pairs consisting out of a label and a value.- Author:
- Friedemann Seebass
-
-
Field Summary
Fields Modifier and Type Field Description protected NodeMembers
mNodeMembers
-
Constructor Summary
Constructors Constructor Description NodeObj()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(NodePair np)
Adds a new pair to the end of the member list.NodePair
get(int idx)
Returns the element with index idx from mNodeMembers.java.lang.String
getAsString(int columnOffset, boolean hasLabel)
Delivers recursively a node and all of its children as a formatted string.NodePair
getNext()
Returns the next NodePair element from mNodeMembers.NodeValue
getValue(java.lang.String string)
Gets the value of the pair with the string (i. e. the label) given in the parameter.void
setIdx(int idx)
Sets the index used by the getNext() method.-
Methods inherited from class JsonFse.Node
getAsString, getAsStrippedString, indent
-
-
-
-
Field Detail
-
mNodeMembers
protected NodeMembers mNodeMembers
-
-
Method Detail
-
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 classNode
- 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 NodePair getNext()
Returns the next NodePair element from mNodeMembers.
-
get
public NodePair get(int idx)
Returns the element with index idx from mNodeMembers.
-
getValue
public NodeValue getValue(java.lang.String string)
Gets the value of the pair with the string (i. e. the label) given in the parameter. The search starts at index 0, and only the first pair is found if there should be more than one with the same label.- Parameters:
string
- The label to search.- Returns:
- The value of the label or null if not found.
-
add
public void add(NodePair np)
Adds a new pair to the end of the member list.- Parameters:
np
- the pair to add
-
-