|
||||||||||
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(java.lang.String name,
java.lang.Boolean value)
Initializes the primitive container. |
|
JSONNode(java.lang.String name,
java.lang.Double value)
Initializes the primitive container. |
|
JSONNode(java.lang.String name,
java.lang.Integer value)
Initializes the primitive container. |
|
JSONNode(java.lang.String name,
java.lang.String value)
Initializes the primitive container. |
Method Summary | |
---|---|
JSONNode |
addArray(java.lang.String name)
Adds an array child to the object. |
JSONNode |
addArrayElement(java.lang.Object value)
Adds an array element child to the array. |
JSONNode |
addNull(java.lang.String name)
Adds a "null" child to the object. |
JSONNode |
addObject(java.lang.String name)
Adds an object child to the object. |
JSONNode |
addPrimitive(java.lang.String name,
java.lang.Boolean value)
Adds a key-value child to the object. |
JSONNode |
addPrimitive(java.lang.String name,
java.lang.Double value)
Adds a key-value child to the object. |
JSONNode |
addPrimitive(java.lang.String name,
java.lang.Integer value)
Adds a key-value child to the object. |
JSONNode |
addPrimitive(java.lang.String name,
java.lang.String value)
Adds a key-value child to the object. |
JSONNode |
getChild(java.lang.String name)
Returns the child with the given name. |
java.lang.String |
getName()
Returns the name of the node. |
JSONNode.NodeType |
getNodeType()
Returns the type of the container. |
java.lang.Object |
getValue()
Returns the stored value. |
java.lang.Object |
getValue(java.lang.Object defValue)
Returns the stored value. |
boolean |
hasChild(java.lang.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(java.lang.String[] args)
Only for testing. |
static JSONNode |
read(java.io.Reader reader)
Reads the JSON object from the given reader. |
java.lang.String |
toString()
Returns a string representation of the node. |
void |
toString(java.lang.StringBuffer buffer)
Dumps the node structure into JSON format. |
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode |
---|
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JSONNode()
public JSONNode(java.lang.String name, java.lang.Boolean value)
name
- the namevalue
- the primitive valuepublic JSONNode(java.lang.String name, java.lang.Integer value)
name
- the namevalue
- the primitive valuepublic JSONNode(java.lang.String name, java.lang.Double value)
name
- the namevalue
- the primitive valuepublic JSONNode(java.lang.String name, java.lang.String value)
name
- the namevalue
- the primitive valueMethod Detail |
---|
public boolean isAnonymous()
public java.lang.String getName()
public java.lang.Object getValue()
public java.lang.Object getValue(java.lang.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(java.lang.String name)
name
- the name of the null value
public JSONNode addPrimitive(java.lang.String name, java.lang.Boolean value)
name
- the name of the pairvalue
- the value
public JSONNode addPrimitive(java.lang.String name, java.lang.Integer value)
name
- the name of the pairvalue
- the value
public JSONNode addPrimitive(java.lang.String name, java.lang.Double value)
name
- the name of the pairvalue
- the value
public JSONNode addPrimitive(java.lang.String name, java.lang.String value)
name
- the name of the pairvalue
- the value
public JSONNode addArray(java.lang.String name)
name
- the name of the pair
public JSONNode addArrayElement(java.lang.Object value)
value
- the value of the element array
public JSONNode addObject(java.lang.String name)
name
- the name of the pair
public boolean hasChild(java.lang.String name)
name
- the name of the child
public JSONNode getChild(java.lang.String name)
name
- the name of the child
public void toString(java.lang.StringBuffer buffer)
buffer
- the buffer to add the data topublic java.lang.String toString()
toString
in class javax.swing.tree.DefaultMutableTreeNode
public static JSONNode read(java.io.Reader reader) throws java.lang.Exception
reader
- the reader to read the JSON object from
java.lang.Exception
- if parsing failspublic static void main(java.lang.String[] args) throws java.lang.Exception
args
- ignored
java.lang.Exception
- if something goes wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |