Package com.bfo.json
Class JsonBuilder
java.lang.Object
com.bfo.json.JsonBuilder
- All Implemented Interfaces:
JsonStream
A
JsonStream that can be used to build a Json object by calling build() when complete.
Extending this class and overriding the various create... method can be used for special
processing, such as storing large strings or buffers on disk, for example
import java.lang.ref.Cleaner;
import java.io.*;
class StoringJsonBuilder extends JsonBuilder {
final Cleaner cleaner = Cleaner.create();-
Nested Class Summary
Nested classes/interfaces inherited from interface com.bfo.json.JsonStream
JsonStream.Event -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()If the stream is complete, return theJsonobject created by this builder, ornullif the builder is incompletebooleanevent(JsonStream.Event event) Process an event.booleanisList()Return true if any objects being created will be added to a listbooleanisMap()Return true if any objects being created are being added to a mapkeys()Return the list of currently open keys as a stack, with the current one at the end of the list.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.bfo.json.JsonStream
isSorted, reset
-
Constructor Details
-
JsonBuilder
public JsonBuilder()
-
-
Method Details
-
build
If the stream is complete, return theJsonobject created by this builder, ornullif the builder is incomplete -
isList
public boolean isList()Return true if any objects being created will be added to a list -
isMap
public boolean isMap()Return true if any objects being created are being added to a map -
keys
Return the list of currently open keys as a stack, with the current one at the end of the list. The list is a copy and may be modified.- Returns:
- the list of keys
-
event
Description copied from interface:JsonStreamProcess an event. Return true if the stream has completed. Any events submitted after this will cause an error- Specified by:
eventin interfaceJsonStream- Returns:
- true if the stream has completed
- Throws:
IOException
-