atg.taglib.json
Class JsonEntity

java.lang.Object
  extended by atg.taglib.json.JsonEntity

public class JsonEntity
extends java.lang.Object

Wrapper object for JSON Entities. A JSON Entity can be either a JSONObject or JSONArray. One of these object types will always be sitting on the top of the object stack, so this class provides a wrapper that can be used to either add a property to an object or append a property to an array.

Version:
$Id$
Author:
James Wiltshire

Constructor Summary
JsonEntity(java.lang.Object pWrapped)
          Create a new JsonEntity object
 
Method Summary
 void add(java.lang.Object pEntity, java.lang.String pName)
          Add a named entity to a JSONObject or append an entity to a JSONArray depending on whether the wrapped object is an object or array.
 java.lang.Object getWrappedObject()
          Get the underlying wrapped JSONObject or JSONArray object
 boolean isArray()
          Is this entity wrapping a JSONArray?
 boolean isObject()
          Is this entity wrapping a JSONObject?
 java.lang.String toString()
          Serialize the underlying wrapped entity to a JSON string
 java.lang.String toString(int pIndentFactor)
          Serialize the underlying wrapped entity to a JSON string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonEntity

public JsonEntity(java.lang.Object pWrapped)
Create a new JsonEntity object

Parameters:
pWrapped - The underlying object to wrap
Method Detail

add

public void add(java.lang.Object pEntity,
                java.lang.String pName)
         throws JSONException
Add a named entity to a JSONObject or append an entity to a JSONArray depending on whether the wrapped object is an object or array.

Parameters:
pEntity - The entity to add to the wrapped object
pName - The property name of the entity, or null if not available
Throws:
JSONException

getWrappedObject

public java.lang.Object getWrappedObject()
Get the underlying wrapped JSONObject or JSONArray object

Returns:
The wrapped object

isArray

public boolean isArray()
Is this entity wrapping a JSONArray?

Returns:
true if this entity wraps a JSONArray, false otherwise

isObject

public boolean isObject()
Is this entity wrapping a JSONObject?

Returns:
true if this entity wraps a JSONObject, false otherwise

toString

public java.lang.String toString()
Serialize the underlying wrapped entity to a JSON string

Overrides:
toString in class java.lang.Object
Returns:
The wrapped JSON entity as a string
See Also:
Object.toString()

toString

public java.lang.String toString(int pIndentFactor)
                          throws JSONException
Serialize the underlying wrapped entity to a JSON string

Parameters:
pIndentFactor - The number of spaces to use to pretty-print the data
Returns:
The wrapped JSON entity as a string
Throws:
JSONException


Copyright © 2008 Art Technology Group, Inc. (ATG). All Rights Reserved.