Package mjson
Class Json.DefaultFactory
- java.lang.Object
-
- mjson.Json.DefaultFactory
-
- All Implemented Interfaces:
Json.Factory
- Enclosing class:
- Json
public static class Json.DefaultFactory extends Object implements Json.Factory
-
-
Constructor Summary
Constructors Constructor Description DefaultFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Jsonarray()Construct and return a JSON object.Jsonbool(boolean x)Construct and return a JSON boolean.Jsonmake(Object anything)Construct and return a JSON object.Jsonnil()Construct and return an object representing JSONnull.Jsonnumber(Number x)Construct and return a JSON number.Jsonobject()Construct and return a JSON object.Jsonstring(String x)Construct and return a JSON string.
-
-
-
Method Detail
-
nil
public Json nil()
Description copied from interface:Json.FactoryConstruct and return an object representing JSONnull. Implementations are free to cache a return the same instance. The resulting value must returntruefromisNull()andnullfromgetValue().- Specified by:
nilin interfaceJson.Factory- Returns:
- The representation of a JSON
nullvalue.
-
bool
public Json bool(boolean x)
Description copied from interface:Json.FactoryConstruct and return a JSON boolean. The resulting value must returntruefromisBoolean()and the passed in parameter fromgetValue().- Specified by:
boolin interfaceJson.Factory- Parameters:
x- The boolean value.- Returns:
- A JSON with
isBoolean() == true. Implementations are free to cache and return the same instance for true and false.
-
string
public Json string(String x)
Description copied from interface:Json.FactoryConstruct and return a JSON string. The resulting value must returntruefromisString()and the passed in parameter fromgetValue().- Specified by:
stringin interfaceJson.Factory- Parameters:
x- The string to wrap as a JSON value.- Returns:
- A JSON element with the given string as a value.
-
number
public Json number(Number x)
Description copied from interface:Json.FactoryConstruct and return a JSON number. The resulting value must returntruefromisNumber()and the passed in parameter fromgetValue().- Specified by:
numberin interfaceJson.Factory- Parameters:
x- The numeric value.- Returns:
- Json instance representing that value.
-
array
public Json array()
Description copied from interface:Json.FactoryConstruct and return a JSON object. The resulting value must returntruefromisArray()and an implementation ofjava.util.ListfromgetValue().- Specified by:
arrayin interfaceJson.Factory- Returns:
- An empty JSON array.
-
object
public Json object()
Description copied from interface:Json.FactoryConstruct and return a JSON object. The resulting value must returntruefromisObject()and an implementation ofjava.util.MapfromgetValue().- Specified by:
objectin interfaceJson.Factory- Returns:
- An empty JSON object.
-
make
public Json make(Object anything)
Description copied from interface:Json.FactoryConstruct and return a JSON object. The resulting value can be of any JSON type. The method is responsible for examining the type of its argument and performing an appropriate mapping to aJsoninstance.- Specified by:
makein interfaceJson.Factory- Parameters:
anything- An arbitray Java object from which to construct aJsonelement.- Returns:
- The newly constructed
Jsoninstance.
-
-