sunlabs.brazil.sunlabs
Class JSONTemplate

java.lang.Object
  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.sunlabs.JSONTemplate (view source)
All Implemented Interfaces:
TemplateInterface

public class JSONTemplate
extends Template

Template for generating formatted JSON output. This can be used to replace the JSON macros for greater efficiency.

NOTE:
Use JSONTemplate instead. It uses the JSON library from json.org, which does a better job of producing valid JSON than the ad-hoc mechanism used here.


Field Summary
 
Fields inherited from class sunlabs.brazil.template.Template
debug
 
Constructor Summary
JSONTemplate()
           
 
Method Summary
 void comment(RewriteContext hr)
          Remove all comments.
 void string(RewriteContext hr)
          Remove all text between tags.
 void tag_array(RewriteContext hr)
          Begin a JSON array <array> <element...
 void tag_element(RewriteContext hr)
          A JSON array element .
 void tag_item(RewriteContext hr)
          A Json Item.
 void tag_json(RewriteContext hr)
          Stop accumulating tokens.
 void tag_object(RewriteContext hr)
          Begin a JSON object <object> ...
 void tag_slash_array(RewriteContext hr)
           
 void tag_slash_item(RewriteContext hr)
           
 void tag_slash_json(RewriteContext hr)
          Reset token accumulation
 void tag_slash_object(RewriteContext hr)
           
 
Methods inherited from class sunlabs.brazil.template.Template
done, init
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONTemplate

public JSONTemplate()
Method Detail

tag_json

public void tag_json(RewriteContext hr)
Stop accumulating tokens. All output should be explicit. Note: this will interact poorly with templates that reset accumulate() apriori. JSON tags don't nest.
maxLine
Min line length for newline (default=80)
indentLevel
Indent increment (default=2)


tag_slash_json

public void tag_slash_json(RewriteContext hr)
Reset token accumulation


comment

public void comment(RewriteContext hr)
Remove all comments.


string

public void string(RewriteContext hr)
Remove all text between tags.


tag_item

public void tag_item(RewriteContext hr)
A Json Item. <item name="name" value="value" /> <item name="name"> ... </jsonitem>


tag_slash_item

public void tag_slash_item(RewriteContext hr)

tag_element

public void tag_element(RewriteContext hr)
A JSON array element . <element value="..." />


tag_object

public void tag_object(RewriteContext hr)
Begin a JSON object <object> ... </object>


tag_array

public void tag_array(RewriteContext hr)
Begin a JSON array <array> <element... /> ... <element ... /> </array>


tag_slash_array

public void tag_slash_array(RewriteContext hr)

tag_slash_object

public void tag_slash_object(RewriteContext hr)

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.