com.dyuproject.json
Class StandardJSON

java.lang.Object
  extended by org.mortbay.util.ajax.JSON
      extended by com.dyuproject.json.StandardJSON
Direct Known Subclasses:
JSONDispatcher, Parser

public class StandardJSON
extends org.mortbay.util.ajax.JSON

Standard JSON serialization of pojos using cached convertors with configurable classloading. Enhancement for jetty-util's org.mortbay.util.ajax.JSON

Author:
David Yu
Date created:
Feb 23, 2009

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mortbay.util.ajax.JSON
org.mortbay.util.ajax.JSON.Convertible, org.mortbay.util.ajax.JSON.Convertor, org.mortbay.util.ajax.JSON.Generator, org.mortbay.util.ajax.JSON.Literal, org.mortbay.util.ajax.JSON.Output, org.mortbay.util.ajax.JSON.ReaderSource, org.mortbay.util.ajax.JSON.Source, org.mortbay.util.ajax.JSON.StringSource
 
Field Summary
protected  boolean _addClass
           
protected  ConvertorCache _convertorCache
           
 
Constructor Summary
StandardJSON()
           
StandardJSON(boolean addClass)
           
StandardJSON(ConvertorCache convertorCache)
           
StandardJSON(ConvertorCache convertorCache, boolean addClass)
           
 
Method Summary
protected  org.mortbay.util.ajax.JSON.Convertor getConvertor(Class clazz)
           
 ConvertorCache getConvertorCache()
          Gets the convertor cache.
static URL getResource(String path)
          Gets a URL resource from the classloader.
static URL getResource(String path, Class<?> context, boolean checkParents)
          Gets a URL resource from the classloader; If not found, the classloader of the context class specified will be used along with its parent if the flag checkParents is true.
 boolean isAddClass()
          Checks whether the classname of a pojo is included upon serialization.
static boolean isCheckParents()
          Checks whether classloading should check parent classloaders.
static Class<?> loadClass(String className)
          Loads a class from the classloader.
static Class<?> loadClass(String className, Class<?> context, boolean checkParents)
          Loads a class from the classloader; If not found, the classloader of the context class specified will be used along with its parent if the flag checkParents is true.
protected  Object parseObject(org.mortbay.util.ajax.JSON.Source source)
           
 void setAddClass(boolean addClass)
          Sets the addClass to determine whether the classname of a pojo is included upon serialization.
static void setCheckParents(boolean checkParents)
          Sets the checkParents to determine whether classloading should check parent classloaders.
 
Methods inherited from class org.mortbay.util.ajax.JSON
addConvertor, addConvertorFor, append, appendArray, appendArray, appendBoolean, appendJSON, appendJSON, appendJSON, appendMap, appendNull, appendNumber, appendString, complete, contextFor, contextForArray, convertTo, fromJSON, getConvertorFor, getDefault, getStringBufferSize, handleUnknown, newArray, newMap, parse, parse, parse, parse, parse, parse, parse, parse, parseArray, parseNumber, parseString, registerConvertor, seekTo, seekTo, setDefault, setStringBufferSize, toJSON, toString, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_convertorCache

protected final ConvertorCache _convertorCache

_addClass

protected boolean _addClass
Constructor Detail

StandardJSON

public StandardJSON()

StandardJSON

public StandardJSON(ConvertorCache convertorCache)

StandardJSON

public StandardJSON(ConvertorCache convertorCache,
                    boolean addClass)

StandardJSON

public StandardJSON(boolean addClass)
Method Detail

isCheckParents

public static boolean isCheckParents()
Checks whether classloading should check parent classloaders.


setCheckParents

public static void setCheckParents(boolean checkParents)
Sets the checkParents to determine whether classloading should check parent classloaders.


loadClass

public static Class<?> loadClass(String className,
                                 Class<?> context,
                                 boolean checkParents)
Loads a class from the classloader; If not found, the classloader of the context class specified will be used along with its parent if the flag checkParents is true.


loadClass

public static Class<?> loadClass(String className)
Loads a class from the classloader.


getResource

public static URL getResource(String path,
                              Class<?> context,
                              boolean checkParents)
Gets a URL resource from the classloader; If not found, the classloader of the context class specified will be used along with its parent if the flag checkParents is true.


getResource

public static URL getResource(String path)
Gets a URL resource from the classloader.


getConvertorCache

public ConvertorCache getConvertorCache()
Gets the convertor cache.


isAddClass

public boolean isAddClass()
Checks whether the classname of a pojo is included upon serialization.


setAddClass

public void setAddClass(boolean addClass)
Sets the addClass to determine whether the classname of a pojo is included upon serialization.


getConvertor

protected org.mortbay.util.ajax.JSON.Convertor getConvertor(Class clazz)
Overrides:
getConvertor in class org.mortbay.util.ajax.JSON

parseObject

protected Object parseObject(org.mortbay.util.ajax.JSON.Source source)
Overrides:
parseObject in class org.mortbay.util.ajax.JSON


Copyright © 2008-2013. All Rights Reserved.