org.directwebremoting.json.types
Class JsonValue

java.lang.Object
  extended by org.directwebremoting.json.types.JsonValue
Direct Known Subclasses:
JsonArray, JsonBoolean, JsonNull, JsonNumber, JsonObject, JsonString

public abstract class JsonValue
extends java.lang.Object

JsonValue allows you to hold any of the JSON types and to get a string version without needing to know what type you have.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
JsonValue()
           
 
Method Summary
 boolean getBoolean()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a boolean and get the Java value quickly.
 double getDouble()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a number and get the Java value quickly.
 int getInteger()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a number and get the Java value quickly.
 JsonArray getJsonArray()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a JsonArray and get it quickly
 JsonObject getJsonObject()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a JsonObject and get it quickly
 long getLong()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a number and get the Java value quickly.
 java.lang.String getString()
          Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a string and get the Java value quickly.
abstract  java.lang.String toExternalRepresentation()
          i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonValue

public JsonValue()
Method Detail

toExternalRepresentation

public abstract java.lang.String toExternalRepresentation()
i.e. How do we send this from one system to another?

Returns:
A string representing the portable version of this data

getString

public java.lang.String getString()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a string and get the Java value quickly.

Returns:
A String representing the JsonNumber implementing this
Throws:
java.lang.ClassCastException - if this is not a JsonString

getInteger

public int getInteger()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a number and get the Java value quickly.

Returns:
An int representing the JsonNumber implementing this
Throws:
java.lang.ClassCastException - if this is not a JsonNumber

getLong

public long getLong()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a number and get the Java value quickly.

Returns:
A long representing the JsonNumber implementing this
Throws:
java.lang.ClassCastException - if this is not a JsonNumber

getDouble

public double getDouble()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a number and get the Java value quickly.

Returns:
A double representing the JsonNumber implementing this
Throws:
java.lang.ClassCastException - if this is not a JsonNumber

getBoolean

public boolean getBoolean()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a boolean and get the Java value quickly.

Returns:
A boolean representing the JsonNumber implementing this
Throws:
java.lang.ClassCastException - if this is not a JsonNumber

getJsonArray

public JsonArray getJsonArray()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a JsonArray and get it quickly

Returns:
A cast of this to JsonArray
Throws:
java.lang.ClassCastException - if this is not a JsonArray

getJsonObject

public JsonObject getJsonObject()
Often when dealing with a JsonValue you know which subtype it is, this allows you to assume it is a JsonObject and get it quickly

Returns:
A cast of this to JsonObject
Throws:
java.lang.ClassCastException - if this is not a JsonObject

Copyright 2008