org.mentawai.ajax.renderer
Class JSONGenericRenderer

java.lang.Object
  extended by org.mentawai.ajax.renderer.JSONGenericRenderer
All Implemented Interfaces:
AjaxRenderer

public class JSONGenericRenderer
extends Object
implements AjaxRenderer

Author:
Robert Willian Gil This renderer build a JSON text:

Example:
Map map = new LinkedHashMap();
map.put("key1", "value1");
map.put("key2", "value2");
Return this:
With default constructor JSONGenericRenderer();
{"obj":[{"key":"key1","value":"value1"},{"key":"key2","value":"value2"}]}

Field Summary
 
Fields inherited from interface org.mentawai.ajax.AjaxRenderer
APP_JS, APP_JSON, APP_URLENCODED, TEXT_HTML, TEXT_PLAIN, TEXT_XML
 
Constructor Summary
JSONGenericRenderer()
           
JSONGenericRenderer(int levels)
           
JSONGenericRenderer(String dateFormat)
           
JSONGenericRenderer(String dateFormat, int levels)
           
 
Method Summary
protected  net.sf.json.JSONObject buildJSON(Object obj, Locale loc)
           
 String encode(Object object, Locale loc, boolean pretty)
           
 String getCharset()
           
 String getContentType()
           
protected static boolean isValidBean(Object o)
           
protected static boolean isWrapper(Object o)
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONGenericRenderer

public JSONGenericRenderer()

JSONGenericRenderer

public JSONGenericRenderer(String dateFormat)

JSONGenericRenderer

public JSONGenericRenderer(int levels)

JSONGenericRenderer

public JSONGenericRenderer(String dateFormat,
                           int levels)
Method Detail

encode

public String encode(Object object,
                     Locale loc,
                     boolean pretty)
              throws Exception
Specified by:
encode in interface AjaxRenderer
Throws:
Exception

getContentType

public String getContentType()
Specified by:
getContentType in interface AjaxRenderer

getCharset

public String getCharset()
Specified by:
getCharset in interface AjaxRenderer

buildJSON

protected net.sf.json.JSONObject buildJSON(Object obj,
                                           Locale loc)

isWrapper

protected static boolean isWrapper(Object o)

isValidBean

protected static boolean isValidBean(Object o)

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2013. All Rights Reserved.