Restlet Framework 2.2.2
Google Web Toolkit

org.restlet.client.ext.json
Class JsonRepresentation

java.lang.Object
  extended by org.restlet.client.representation.Variant
      extended by org.restlet.client.representation.RepresentationInfo
          extended by org.restlet.client.representation.Representation
              extended by org.restlet.client.ext.json.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.client.representation.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.
JsonRepresentation(String jsonString)
          Constructor from a JSON string.
 
Method Summary
 JSONArray getJsonArray()
          Converts the representation to a JSON array.
 JSONBoolean getJsonBoolean()
          Converts the representation to a JSON Boolean.
 JSONNull getJsonNull()
          Converts the representation to a JSON null value.
 JSONObject getJsonObject()
          Converts the representation to a JSON object.
 JSONString getJsonString()
          Converts the representation to a JSON string.
 Reader getReader()
           
 long getSize()
           
 InputStream getStream()
           
 String getText()
           
 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.client.representation.Representation
append, exhaust, getAvailableSize, getDisposition, getExpirationDate, getRange, hasKnownSize, isAvailable, isEmpty, isTransient, setAvailable, setDisposition, setExpirationDate, setRange, setSize, setTransient
 
Methods inherited from class org.restlet.client.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
 
Methods inherited from class org.restlet.client.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, 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.

JsonRepresentation

public JsonRepresentation(String jsonString)
Constructor from a JSON string.

Parameters:
jsonString - The JSON string.
Method Detail

getJsonArray

public JSONArray getJsonArray()
                       throws IOException
Converts the representation to a JSON array. This method might trigger the parsing of the wrapped JSON textual representation.

Returns:
The converted JSON array.
Throws:
IOException

getJsonBoolean

public JSONBoolean getJsonBoolean()
                           throws IOException
Converts the representation to a JSON Boolean. This method might trigger the parsing of the wrapped JSON textual representation.

Returns:
The converted JSON Boolean.
Throws:
IOException

getJsonNull

public JSONNull getJsonNull()
                     throws IOException
Converts the representation to a JSON null value. This method might trigger the parsing of the wrapped JSON textual representation.

Returns:
The converted JSON null value.
Throws:
IOException

getJsonObject

public JSONObject getJsonObject()
                         throws IOException
Converts the representation to a JSON object. This method might trigger the parsing of the wrapped JSON textual representation.

Returns:
The converted JSON object.
Throws:
IOException

getJsonString

public JSONString getJsonString()
                         throws IOException
Converts the representation to a JSON string. This method might trigger the parsing of the wrapped JSON textual representation.

Returns:
The converted JSON string.
Throws:
IOException

getReader

public Reader getReader()
                 throws IOException
Specified by:
getReader in class Representation
Throws:
IOException

getSize

public long getSize()
Overrides:
getSize in class Representation

getStream

public InputStream getStream()
                      throws IOException
Specified by:
getStream in class Representation
Throws:
IOException

getText

public String getText()
               throws IOException
Specified by:
getText in class Representation
Throws:
IOException

getValue

public JSONValue getValue()
                   throws IOException
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.
Throws:
IOException

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.

Restlet Framework 2.2.2
Google Web Toolkit

Copyright © 2005-2014 Restlet.