|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.tree.DefaultMutableTreeNode
weka.core.json.JSONNode
public class JSONNode
Container class for storing a JSON data structure.
| Nested Class Summary | |
|---|---|
static class |
JSONNode.NodeType
The type of a node. |
| Field Summary |
|---|
| Fields inherited from class javax.swing.tree.DefaultMutableTreeNode |
|---|
EMPTY_ENUMERATION |
| Constructor Summary | |
|---|---|
JSONNode()
Initializes the root container. |
|
JSONNode(String name,
Boolean value)
Initializes the primitive container. |
|
JSONNode(String name,
Double value)
Initializes the primitive container. |
|
JSONNode(String name,
Integer value)
Initializes the primitive container. |
|
JSONNode(String name,
String value)
Initializes the primitive container. |
|
| Method Summary | |
|---|---|
JSONNode |
addArray(String name)
Adds an array child to the object. |
JSONNode |
addArrayElement(Object value)
Adds an array element child to the array. |
JSONNode |
addNull(String name)
Adds a "null" child to the object. |
JSONNode |
addNullArrayElement()
Adds a null array element child to the array. |
JSONNode |
addObject(String name)
Adds an object child to the object. |
JSONNode |
addPrimitive(String name,
Boolean value)
Adds a key-value child to the object. |
JSONNode |
addPrimitive(String name,
Double value)
Adds a key-value child to the object. |
JSONNode |
addPrimitive(String name,
Integer value)
Adds a key-value child to the object. |
JSONNode |
addPrimitive(String name,
String value)
Adds a key-value child to the object. |
JSONNode |
getChild(String name)
Returns the child with the given name. |
String |
getName()
Returns the name of the node. |
JSONNode.NodeType |
getNodeType()
Returns the type of the container. |
Object |
getValue()
Returns the stored value. |
Object |
getValue(Object defValue)
Returns the stored value. |
boolean |
hasChild(String name)
Checks whether the node has a child with the given name. |
boolean |
isAnonymous()
Checks whether the node is anonymous. |
boolean |
isArray()
Returns wether the node is an array. |
boolean |
isObject()
Returns wether the node is an object. |
boolean |
isPrimitive()
Returns whether the node stores a primitive value or a an array/object. |
static void |
main(String[] args)
Only for testing. |
static JSONNode |
read(Reader reader)
Reads the JSON object from the given reader. |
String |
toString()
Returns a string representation of the node. |
void |
toString(StringBuffer buffer)
Dumps the node structure into JSON format. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JSONNode()
public JSONNode(String name,
Boolean value)
name - the namevalue - the primitive value
public JSONNode(String name,
Integer value)
name - the namevalue - the primitive value
public JSONNode(String name,
Double value)
name - the namevalue - the primitive value
public JSONNode(String name,
String value)
name - the namevalue - the primitive value| Method Detail |
|---|
public boolean isAnonymous()
public String getName()
public Object getValue()
public Object getValue(Object defValue)
defValue - the default value, if value is null
public boolean isPrimitive()
public boolean isArray()
public boolean isObject()
public JSONNode.NodeType getNodeType()
public JSONNode addNull(String name)
name - the name of the null value
public JSONNode addPrimitive(String name,
Boolean value)
name - the name of the pairvalue - the value
public JSONNode addPrimitive(String name,
Integer value)
name - the name of the pairvalue - the value
public JSONNode addPrimitive(String name,
Double value)
name - the name of the pairvalue - the value
public JSONNode addPrimitive(String name,
String value)
name - the name of the pairvalue - the value
public JSONNode addArray(String name)
name - the name of the pair
public JSONNode addNullArrayElement()
public JSONNode addArrayElement(Object value)
value - the value of the element array
public JSONNode addObject(String name)
name - the name of the pair
public boolean hasChild(String name)
name - the name of the child
public JSONNode getChild(String name)
name - the name of the child
public void toString(StringBuffer buffer)
buffer - the buffer to add the data topublic String toString()
toString in class DefaultMutableTreeNode
public static JSONNode read(Reader reader)
throws Exception
reader - the reader to read the JSON object from
Exception - if parsing fails
public static void main(String[] args)
throws Exception
args - ignored
Exception - if something goes wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||