com.google.visualization.datasource.render
Class JsonRenderer

java.lang.Object
  extended by com.google.visualization.datasource.render.JsonRenderer

public class JsonRenderer
extends Object

Takes a data table and returns a json string.

Author:
Nimrod T.

Method Summary
static StringBuilder appendCellJson(TableCell cell, StringBuilder sb, boolean includeFormatting, boolean isLastColumn, boolean renderDateAsDateConstructor)
          Appends a Json representing a cell to the string buffer.
static StringBuilder appendColumnDescriptionJson(ColumnDescription col, StringBuilder sb)
          Appends a Json representing a column description to the string buffer.
static String getSignature(DataTable data)
          Returns a String-form 32-bit hash of this table's json.
static CharSequence renderDataTable(DataTable dataTable, boolean includeValues, boolean includeFormatting, boolean renderDateAsDateConstructor)
          Generates a JSON representation of the data table object.
static CharSequence renderJsonResponse(DataSourceParameters dsParams, ResponseStatus responseStatus, DataTable data)
          Returns the json response for the given data table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSignature

public static String getSignature(DataTable data)
Returns a String-form 32-bit hash of this table's json. Note: the signature ignores formatting.

Parameters:
data - The data table.
Returns:
a String-form 64-bit hash of this table.

renderJsonResponse

public static CharSequence renderJsonResponse(DataSourceParameters dsParams,
                                              ResponseStatus responseStatus,
                                              DataTable data)
Returns the json response for the given data table.

Parameters:
dsParams - The datasource parameters.
responseStatus - The response status.
data - The data table.
Returns:
The json response for the given data table and parameters.

renderDataTable

public static CharSequence renderDataTable(DataTable dataTable,
                                           boolean includeValues,
                                           boolean includeFormatting,
                                           boolean renderDateAsDateConstructor)
Generates a JSON representation of the data table object.

Parameters:
includeValues - False if the json should contain just meta-data and column descriptions but without the data rows.
includeFormatting - False if formatting information should be omitted from the generated json.
renderDateAsDateConstructor - True -> date constructor, False -> date string. True if date values should be rendered into the json string as a call to Date object constructor (usually used when rendering jsonp string). False if it should should be rendered as string. For example, when rendering the date 1/1/2011 as Date object constructor its value in the json string will be new Date(2011,1,1), and when rendered as string will be "Date(2011,1,1)"
Returns:
The char sequence with the Json string.

appendCellJson

public static StringBuilder appendCellJson(TableCell cell,
                                           StringBuilder sb,
                                           boolean includeFormatting,
                                           boolean isLastColumn,
                                           boolean renderDateAsDateConstructor)
Appends a Json representing a cell to the string buffer.

Parameters:
cell - The cell to write Json for.
sb - The string buffer to append to.
includeFormatting - Flase if formatting information should be omitted from the json.
isLastColumn - Is this the last column in the row.
renderDateAsDateConstructor - True -> date constructor, False -> date string. True if date values should be rendered into the json string as a call to Date object constructor (usually used when rendering jsonp string). False if it should should be rendered as string. For example, when rendering the date 1/1/2011 as Date object constructor its value in the json string will be new Date(2011,1,1), and when rendered as string will be "Date(2011,1,1)"
Returns:
The input string builder.

appendColumnDescriptionJson

public static StringBuilder appendColumnDescriptionJson(ColumnDescription col,
                                                        StringBuilder sb)
Appends a Json representing a column description to the string buffer.

Parameters:
col - The column description to write Json for.
sb - The string builder to append to.
Returns:
The input string builder.


Copyright © 2012 Google. All Rights Reserved.