org.restlet.gwt.resource
Class JsonRepresentation

java.lang.Object
  extended by org.restlet.gwt.resource.Variant
      extended by org.restlet.gwt.resource.Representation
          extended by org.restlet.gwt.resource.JsonRepresentation

public class JsonRepresentation
extends Representation

JSON representation based on an JSON value. JSON (JavaScript Object Notation) is a common serialization format similar to XML but lighter.

Author:
Jerome Louvel
See Also:
JSON

Field Summary
 
Fields inherited from class org.restlet.gwt.resource.Representation
UNKNOWN_SIZE
 
Constructor Summary
JsonRepresentation(MediaType mediaType)
          Constructor for an empty document.
JsonRepresentation(MediaType mediaType, JSONValue value)
          Constructor from an existing DOM document.
JsonRepresentation(Representation jsonRepresentation)
          Constructor.
 
Method Summary
 java.lang.String getText()
          Converts the representation to a string value.
 JSONValue getValue()
          Returns the wrapped JSON value.
 void release()
          Releases the wrapped JSON value and the source JSON representation if they have been defined.
 void setValue(JSONValue json)
          Sets the wrapped JSON value.
 
Methods inherited from class org.restlet.gwt.resource.Representation
createEmpty, getDownloadName, getExpirationDate, getModificationDate, getSize, getTag, isAvailable, isDownloadable, isTransient, setAvailable, setDownloadable, setDownloadName, setExpirationDate, setModificationDate, setSize, setTag, setTransient
 
Methods inherited from class org.restlet.gwt.resource.Variant
getCharacterSet, getEncodings, getIdentifier, getLanguages, getMediaType, setCharacterSet, setEncodings, setIdentifier, setIdentifier, setLanguages, setMediaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonRepresentation

public JsonRepresentation(MediaType mediaType)
Constructor for an empty document.

Parameters:
mediaType - The representation's media type.

JsonRepresentation

public JsonRepresentation(MediaType mediaType,
                          JSONValue value)
Constructor from an existing DOM document.

Parameters:
mediaType - The representation's media type.
value - The source JSON value.

JsonRepresentation

public JsonRepresentation(Representation jsonRepresentation)
Constructor.

Parameters:
jsonRepresentation - A source JSON representation to parse.
Method Detail

getText

public java.lang.String getText()
Description copied from class: Representation
Converts the representation to a string value. Be careful when using this method as the conversion of large content to a string fully stored in memory can result in OutOfMemoryErrors being thrown.

Specified by:
getText in class Representation
Returns:
The representation as a string value.

getValue

public JSONValue getValue()
Returns the wrapped JSON value. If no value is defined yet, it attempts to parse the JSON representation eventually given at construction time. Otherwise, it just creates a null JSON value.

Returns:
The wrapped DOM document.

release

public void release()
Releases the wrapped JSON value and the source JSON representation if they have been defined.

Overrides:
release in class Representation

setValue

public void setValue(JSONValue json)
Sets the wrapped JSON value.

Parameters:
json - The wrapped JSON value.


Copyright © 2005-2008 Noelios Technologies.