org.directwebremoting.json.parse
Interface JsonDecoder

All Known Implementing Classes:
DebuggingJsonDecoder, IgnoreJsonDecoder, JsonRpcCallsJsonDecoder, ReflectionJsonDecoder, SimpleJsonDecoder, StatefulJsonDecoder

public interface JsonDecoder

Used by JsonParser to allow the parse process to be mostly stateless, and to abstract the process of creating objects. It is very likely that StatefulJsonDecoder will be an easier start point than this.

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

Method Summary
 void addBoolean(java.lang.String propertyName, boolean value)
          Add a boolean member.
 void addNull(java.lang.String propertyName)
          Add a null member.
 void addNumber(java.lang.String propertyName, java.lang.String intPart, java.lang.String floatPart, java.lang.String expPart)
          Add a numeric member.
 void addString(java.lang.String propertyName, java.lang.String value)
          Add a string member.
 void beginArray(java.lang.String propertyName)
          We have encountered a [.
 void beginObject(java.lang.String propertyName)
          We have encountered a {.
 void endArray(java.lang.String propertyName)
          We have encountered a ].
 void endObject(java.lang.String propertyName)
          We have encountered a }.
 java.lang.Object getRoot()
          When the parse is finished, this gives access to the result
 

Method Detail

getRoot

java.lang.Object getRoot()
                         throws JsonParseException
When the parse is finished, this gives access to the result

Throws:
JsonParseException

beginObject

void beginObject(java.lang.String propertyName)
                 throws JsonParseException
We have encountered a {. If this object is a top level object, or the object is being added to an array, then the propertyName argument will be null, otherwise it will contain the name that this object will be assigned to in the parent object. What follows is a series of addXxxx() calls, possibly nested arrays and objects, followed by a call to endObject(String)

Throws:
JsonParseException

endObject

void endObject(java.lang.String propertyName)
               throws JsonParseException
We have encountered a }. This is called in a matching pair to beginObject(String) The propertyName argument will match the value given in the corresponding beginObject(String) call.

Throws:
JsonParseException

beginArray

void beginArray(java.lang.String propertyName)
                throws JsonParseException
We have encountered a [. If this object is a top level object, or the object is being added to an array, then the propertyName argument will be null, otherwise it will contain the name that this object will be assigned to in the parent object. What follows is a series of addXxxxx() calls, possibly including nested arrays and objects, followed by a call to endArray(String).

Throws:
JsonParseException

endArray

void endArray(java.lang.String propertyName)
              throws JsonParseException
We have encountered a ]. This is called in a matching pair to beginArray(String) The propertyName argument will match the value given in the corresponding beginArray(String) call.

Throws:
JsonParseException
See Also:
beginArray(String)

addString

void addString(java.lang.String propertyName,
               java.lang.String value)
               throws JsonParseException
Add a string member. If the member is added to an object then the propertyName argument will be the part of the JSON string before the ':'. If the member is added to an array, then propertyName will be null. See the note on beginObject(String)

Throws:
JsonParseException

addNumber

void addNumber(java.lang.String propertyName,
               java.lang.String intPart,
               java.lang.String floatPart,
               java.lang.String expPart)
               throws JsonParseException
Add a numeric member. See the note on addString(String, String) for the meaning of the propertyName argument. The 3 parts are put together like this: {intPart}[.{floatPart}][E{expPart}]. For example:

Throws:
JsonParseException

addBoolean

void addBoolean(java.lang.String propertyName,
                boolean value)
                throws JsonParseException
Add a boolean member. See the note on addString(String, String) for the meaning of the propertyName argument.

Throws:
JsonParseException

addNull

void addNull(java.lang.String propertyName)
             throws JsonParseException
Add a null member. See the note on addString(String, String) for the meaning of the propertyName argument.

Throws:
JsonParseException

Copyright 2008