Package groovy.json
Class StreamingJsonBuilder.StreamingJsonDelegate
- java.lang.Object
- 
- groovy.lang.GroovyObjectSupport
- 
- groovy.json.StreamingJsonBuilder.StreamingJsonDelegate
 
 
- 
- All Implemented Interfaces:
- GroovyObject
 - Enclosing class:
- StreamingJsonBuilder
 
 public static class StreamingJsonBuilder.StreamingJsonDelegate extends GroovyObjectSupport The delegate used when invoking closures
- 
- 
Constructor SummaryConstructors Constructor Description StreamingJsonDelegate(java.io.Writer w, boolean first)StreamingJsonDelegate(java.io.Writer w, boolean first, JsonGenerator generator)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcall(java.lang.String name, JsonOutput.JsonUnescaped json)Writes an unescaped value.voidcall(java.lang.String name, Closure value)Writes the name and another JSON objectvoidcall(java.lang.String name, Writable json)Writes the given Writable as the value of the given attribute namevoidcall(java.lang.String name, java.lang.Iterable coll, Closure c)A collection and closure passed to a JSON builder will create a root JSON array applying the closure to each object in the collectionvoidcall(java.lang.String name, java.lang.Object value)Writes the name and value of a JSON attributevoidcall(java.lang.String name, java.lang.Object... array)Writes the name and a JSON arrayvoidcall(java.lang.String name, java.lang.Object value, Closure callable)Writes the name and value of a JSON attributevoidcall(java.lang.String name, java.util.Collection coll, Closure c)Delegates tocall(String, Iterable, Closure)voidcall(java.lang.String name, java.util.List<java.lang.Object> list)Writes the name and a JSON arraystatic voidcloneDelegateAndGetContent(java.io.Writer w, Closure c)static voidcloneDelegateAndGetContent(java.io.Writer w, Closure c, boolean first)static voidcurryDelegateAndGetContent(java.io.Writer w, Closure c, java.lang.Object o)static voidcurryDelegateAndGetContent(java.io.Writer w, Closure c, java.lang.Object o, boolean first)java.io.WritergetWriter()java.lang.ObjectinvokeMethod(java.lang.String name, java.lang.Object args)Invokes the given method.static booleanisCollectionWithClosure(java.lang.Object[] args)protected voidverifyValue()protected voidwriteArray(java.util.List<java.lang.Object> list)static java.lang.ObjectwriteCollectionWithClosure(java.io.Writer writer, java.util.Collection coll, Closure closure)protected voidwriteName(java.lang.String name)protected voidwriteValue(java.lang.Object value)- 
Methods inherited from class groovy.lang.GroovyObjectSupportgetMetaClass, getProperty, setMetaClass, setProperty
 
- 
 
- 
- 
- 
Constructor Detail- 
StreamingJsonDelegatepublic StreamingJsonDelegate(java.io.Writer w, boolean first)
 - 
StreamingJsonDelegatepublic StreamingJsonDelegate(java.io.Writer w, boolean first, JsonGenerator generator)
 
- 
 - 
Method Detail- 
getWriterpublic java.io.Writer getWriter() - Returns:
- Obtains the current writer
 
 - 
invokeMethodpublic java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)Description copied from interface:GroovyObjectInvokes the given method.- Specified by:
- invokeMethodin interface- GroovyObject
- Overrides:
- invokeMethodin class- GroovyObjectSupport
- Parameters:
- name- the name of the method to call
- args- the arguments to use for the method call
- Returns:
- the result of invoking the method
 
 - 
callpublic void call(java.lang.String name, java.util.List<java.lang.Object> list) throws java.io.IOExceptionWrites the name and a JSON array- Parameters:
- name- The name of the JSON attribute
- list- The list representing the array
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, java.lang.Object... array) throws java.io.IOExceptionWrites the name and a JSON array- Parameters:
- name- The name of the JSON attribute
- array- The list representing the array
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, java.lang.Iterable coll, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure c) throws java.io.IOExceptionA collection and closure passed to a JSON builder will create a root JSON array applying the closure to each object in the collectionExample: class Author { String name } def authorList = [new Author (name: "Guillaume"), new Author (name: "Jochen"), new Author (name: "Paul")] new StringWriter().with { w->def json = new groovy.json.StreamingJsonBuilder(w) json.book { authors authorList, { Author author->name author.name } } assert w.toString() == '{"book":{"authors":[{"name":"Guillaume"},{"name":"Jochen"},{"name":"Paul"}]}}' }- Parameters:
- coll- a collection
- c- a closure used to convert the objects of coll
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, java.util.Collection coll, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure c) throws java.io.IOExceptionDelegates tocall(String, Iterable, Closure)- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, java.lang.Object value) throws java.io.IOExceptionWrites the name and value of a JSON attribute- Parameters:
- name- The attribute name
- value- The value
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, java.lang.Object value, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure callable) throws java.io.IOExceptionWrites the name and value of a JSON attribute- Parameters:
- name- The attribute name
- value- The value
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure value) throws java.io.IOExceptionWrites the name and another JSON object- Parameters:
- name- The attribute name
- value- The value
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, JsonOutput.JsonUnescaped json) throws java.io.IOExceptionWrites an unescaped value. Note: can cause invalid JSON if passed JSON is invalid- Parameters:
- name- The attribute name
- json- The value
- Throws:
- java.io.IOException
 
 - 
callpublic void call(java.lang.String name, Writable json) throws java.io.IOExceptionWrites the given Writable as the value of the given attribute name- Parameters:
- name- The attribute name
- json- The writable value
- Throws:
- java.io.IOException
 
 - 
verifyValueprotected void verifyValue() 
 - 
writeNameprotected void writeName(java.lang.String name) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
writeValueprotected void writeValue(java.lang.Object value) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
writeArrayprotected void writeArray(java.util.List<java.lang.Object> list) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
isCollectionWithClosurepublic static boolean isCollectionWithClosure(java.lang.Object[] args) 
 - 
writeCollectionWithClosurepublic static java.lang.Object writeCollectionWithClosure(java.io.Writer writer, java.util.Collection coll, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure closure) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
cloneDelegateAndGetContentpublic static void cloneDelegateAndGetContent(java.io.Writer w, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure c)
 - 
cloneDelegateAndGetContentpublic static void cloneDelegateAndGetContent(java.io.Writer w, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure c, boolean first)
 - 
curryDelegateAndGetContentpublic static void curryDelegateAndGetContent(java.io.Writer w, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure c, java.lang.Object o)
 - 
curryDelegateAndGetContentpublic static void curryDelegateAndGetContent(java.io.Writer w, @DelegatesTo(value=StreamingJsonDelegate.class,strategy=1) Closure c, java.lang.Object o, boolean first)
 
- 
 
-