javax.json
Interface JsonObjectBuilder<T>


public interface JsonObjectBuilder<T>

Helps in building a JSON object. This is an intermediary class and the actual build process is started from JsonBuilder or JsonGenerator

Author:
Jitendra Kotamraju
See Also:
JsonBuilder, JsonGenerator

Method Summary
 JsonObjectBuilder<T> add(String name, BigDecimal value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, BigInteger value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, boolean value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, double value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, int value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, JsonValue value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, long value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> add(String name, String value)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<T> addNull(String name)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonArrayBuilder<JsonObjectBuilder<T>> beginArray(String name)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 JsonObjectBuilder<JsonObjectBuilder<T>> beginObject(String name)
          Associates the specified value with the specified name/key in the JSON object that is being built.
 T endObject()
          Indicates the end of the JSON object that is being built.
 

Method Detail

endObject

T endObject()
Indicates the end of the JSON object that is being built.

Returns:
the enclosing object of type T
Throws:
IllegalStateException - when endObject method is already called

add

JsonObjectBuilder<T> add(String name,
                         JsonValue value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called

add

JsonObjectBuilder<T> add(String name,
                         String value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called

add

JsonObjectBuilder<T> add(String name,
                         BigInteger value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called
See Also:
JsonNumber

add

JsonObjectBuilder<T> add(String name,
                         BigDecimal value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called
See Also:
JsonNumber

add

JsonObjectBuilder<T> add(String name,
                         int value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called
See Also:
JsonNumber

add

JsonObjectBuilder<T> add(String name,
                         long value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called
See Also:
JsonNumber

add

JsonObjectBuilder<T> add(String name,
                         double value)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called
NumberFormatException - if value is Not-a-Number(NaN) or infinity
See Also:
JsonNumber

add

JsonObjectBuilder<T> add(String name,
                         boolean value)
Associates the specified value with the specified name/key in the JSON object that is being built.

TODO not needed since add(JsonValue.TRUE|FALSE) can be used ??

Parameters:
name - name/key with which the specified value is to be associated
value - value to be associated with the specified name/key
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called

addNull

JsonObjectBuilder<T> addNull(String name)
Associates the specified value with the specified name/key in the JSON object that is being built.

TODO not needed since add(JsonValue.NULL) can be used ??

Parameters:
name - name/key with which the specified value is to be associated
Returns:
this object builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called

beginObject

JsonObjectBuilder<JsonObjectBuilder<T>> beginObject(String name)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
Returns:
a object member builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called

beginArray

JsonArrayBuilder<JsonObjectBuilder<T>> beginArray(String name)
Associates the specified value with the specified name/key in the JSON object that is being built.

Parameters:
name - name/key with which the specified value is to be associated
Returns:
a array member builder
Throws:
JsonException - if there is a mapping for the specified name/key in the JSON object
IllegalStateException - when invoked after the endObject method is called



Copyright © 2012 Oracle and/or its affiliates. All rights reserved.