001package com.hfg.javascript; 002 003 004import java.io.Writer; 005 006//------------------------------------------------------------------------------ 007/** 008 JSON interface for Collections. 009 010 @author J. Alex Taylor, hairyfatguy.com 011 */ 012//------------------------------------------------------------------------------ 013// com.hfg Library 014// 015// This library is free software; you can redistribute it and/or 016// modify it under the terms of the GNU Lesser General Public 017// License as published by the Free Software Foundation; either 018// version 2.1 of the License, or (at your option) any later version. 019// 020// This library is distributed in the hope that it will be useful, 021// but WITHOUT ANY WARRANTY; without even the implied warranty of 022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 023// Lesser General Public License for more details. 024// 025// You should have received a copy of the GNU Lesser General Public 026// License along with this library; if not, write to the Free Software 027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 028// 029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 030// jataylor@hairyfatguy.com 031//------------------------------------------------------------------------------ 032 033public interface JsCollection 034{ 035 //-------------------------------------------------------------------------- 036 /** 037 Produces a JSON serialization of the Collection. Ex: <span style='font-family:monospace'>[ "foo", { "key1": 1.0, "key2": "Hello" } ]</span> 038 */ 039 public String toJSON(); 040 041 //-------------------------------------------------------------------------- 042 /** 043 Produces a JSON serialization of the Collection. Ex: <span style='font-family:monospace'>[ "foo", { "key1": 1.0, "key2": "Hello" } ]</span> 044 @param inWriter where to send the JSON to 045 */ 046 public void toJSON(Writer inWriter); 047 048 //-------------------------------------------------------------------------- 049 /** 050 Produces a javascript serialization that will generally be the same as produced 051 by toJSON() except when values have been added via the putUnquoted() method. 052 */ 053 public String toJavascript(); 054 055 //-------------------------------------------------------------------------- 056 /** 057 Produces a javascript serialization that will generally be the same as produced 058 by toJSON() except when values have been added via the putUnquoted() method. 059 @param inWriter where to send the javascript to 060 */ 061 public void toJavascript(Writer inWriter); 062 063}