Package JsonFse
Class NodePair
- java.lang.Object
-
- JsonFse.Node
-
- JsonFse.NodePair
-
public class NodePair extends Node
Represents a pair consisting of a label and a value.- Author:
- fs
-
-
Field Summary
Fields Modifier and Type Field Description protected NodeString
mString
The label of the pair.protected NodeValue
mValue
The value of the pair.
-
Constructor Summary
Constructors Constructor Description NodePair()
NodePair(java.lang.String string)
Constructor for creating a pair containing a null as value.NodePair(java.lang.String string, boolean value)
Constructor for creating a pair containing a boolean as value.NodePair(java.lang.String string, double value)
Constructor for creating a pair containing a number as value.NodePair(java.lang.String string, int value)
Constructor for creating a pair containing an integer number as value.NodePair(java.lang.String string, java.lang.String value)
Constructor for creating a pair containing a string as value.NodePair(java.lang.String string, JsonObj value)
Constructor for creating a pair containing a NodeObj as value.NodePair(java.lang.String string, NodeArray value)
Constructor for creating a pair containing a NodeArray as value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAsString(int columnOffset, boolean hasLabel)
Delivers recursively a node and all of its children as a formatted string.NodeString
getString()
NodeValue
getValue()
-
Methods inherited from class JsonFse.Node
get, getAsString, getAsStrippedString, getNext, indent
-
-
-
-
Field Detail
-
mString
protected NodeString mString
The label of the pair.
-
mValue
protected NodeValue mValue
The value of the pair.
-
-
Constructor Detail
-
NodePair
public NodePair()
-
NodePair
public NodePair(java.lang.String string, java.lang.String value)
Constructor for creating a pair containing a string as value. The additional quotes needed by the JSON syntax for enclosing the strings are added automatically and must not be given.- Parameters:
string
- The label of the pair.value
- The value of the pair.
-
NodePair
public NodePair(java.lang.String string, int value)
Constructor for creating a pair containing an integer number as value. The additional quotes needed by the JSON syntax for enclosing the label are added automatically and must not be given.- Parameters:
string
- The label of the pair.value
- The value of the pair.
-
NodePair
public NodePair(java.lang.String string, double value)
Constructor for creating a pair containing a number as value. The additional quotes needed by the JSON syntax for enclosing the label are added automatically and must not be given.- Parameters:
string
- The label of the pair.value
- The value of the pair.
-
NodePair
public NodePair(java.lang.String string, boolean value)
Constructor for creating a pair containing a boolean as value. The additional quotes needed by the JSON syntax for enclosing the label are added automatically and must not be given.- Parameters:
string
- The label of the pair.value
- The value of the pair.
-
NodePair
public NodePair(java.lang.String string)
Constructor for creating a pair containing a null as value. The additional quotes needed by the JSON syntax for enclosing the label are added automatically and must not be given.- Parameters:
string
- The label of the pair.
-
NodePair
public NodePair(java.lang.String string, NodeArray value)
Constructor for creating a pair containing a NodeArray as value. The additional quotes needed by the JSON syntax for enclosing the label are added automatically and must not be given.- Parameters:
string
- The label of the pair.value
- The value of the pair.
-
NodePair
public NodePair(java.lang.String string, JsonObj value)
Constructor for creating a pair containing a NodeObj as value. The additional quotes needed by the JSON syntax for enclosing the label are added automatically and must not be given.- Parameters:
string
- The label of the pair.value
- The value of the pair.
-
-
Method Detail
-
getString
public NodeString getString()
-
getValue
public NodeValue getValue()
-
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.
-
-