Package com.clumd.projects.javajson.core
Class BasicJsonBuilder
java.lang.Object
com.clumd.projects.javajson.core.BasicJsonBuilder
- All Implemented Interfaces:
JsonBuilder,JsonGenerator
public final class BasicJsonBuilder extends Object implements JsonBuilder, JsonGenerator
-
Constructor Summary
Constructors Constructor Description BasicJsonBuilder() -
Method Summary
Modifier and Type Method Description JsonBuilderaddBoolean(String path, boolean value)Add a boolean to this JSON object.JsonBuilderaddBuilderBlock(String path, Json value)Use an existing, compiled piece of JSON, converted to a JsonBuilder, then assigned to the value at the path.JsonBuilderaddBuilderBlock(String path, JsonBuilder value)Add another JsonBuilder (representing an object) with partially filled values to this JSON object.JsonBuilderaddDouble(String path, double value)Add a double to this JSON object.JsonBuilderaddLong(String path, long value)Add a long to this JSON object.JsonBuilderaddString(String path, String value)Add a string to this JSON object.Jsonbuild()Used to finalise the current builder into a fully compiled Java-JSON object.BasicJsonBuilderbuilder()Used to create an empty JSON shell.JsonBuilderconvertFromJSON(Json json)Break a full JSON object down into a builder representation of itself to be added to.JsonconvertToJSON()Convert the current Java Class into a Java-JSON JSON representation of itself.static BasicJsonBuildergetBuilder()StringtoString()
-
Constructor Details
-
BasicJsonBuilder
public BasicJsonBuilder()
-
-
Method Details
-
getBuilder
-
builder
Description copied from interface:JsonBuilderUsed to create an empty JSON shell.- Specified by:
builderin interfaceJsonBuilder- Returns:
- An empty JSON builder, which will default to an object.
-
build
Description copied from interface:JsonBuilderUsed to finalise the current builder into a fully compiled Java-JSON object.- Specified by:
buildin interfaceJsonBuilder- Returns:
- The compiled JSON object with all values set through this builder.
- Throws:
BuildException
-
convertToJSON
Description copied from interface:JsonGeneratorConvert the current Java Class into a Java-JSON JSON representation of itself.- Specified by:
convertToJSONin interfaceJsonGenerator- Returns:
- The Java-JSON representation of this class as a JSON object.
- Throws:
BuildException
-
addBoolean
Description copied from interface:JsonBuilderAdd a boolean to this JSON object.- Specified by:
addBooleanin interfaceJsonBuilder- Parameters:
path- The JSON path/key to place the object at.value- The boolean value to set at the given key.- Returns:
- The current JSON object, with the new value assigned.
- Throws:
BuildException- Thrown if the key was malformed or conflicts with values already present along it's path
-
addLong
Description copied from interface:JsonBuilderAdd a long to this JSON object.- Specified by:
addLongin interfaceJsonBuilder- Parameters:
path- The JSON path/key to place the object at.value- The long value to set at the given key.- Returns:
- The current JSON object, with the new value assigned.
- Throws:
BuildException- Thrown if the key was malformed or conflicts with values already present along it's path
-
addDouble
Description copied from interface:JsonBuilderAdd a double to this JSON object.- Specified by:
addDoublein interfaceJsonBuilder- Parameters:
path- The JSON path/key to place the object at.value- The double value to set at the given key.- Returns:
- The current JSON object, with the new value assigned.
- Throws:
BuildException- Thrown if the key was malformed or conflicts with values already present along it's path
-
addString
Description copied from interface:JsonBuilderAdd a string to this JSON object.- Specified by:
addStringin interfaceJsonBuilder- Parameters:
path- The JSON path/key to place the object at.value- The string value to set at the given key.- Returns:
- The current JSON object, with the new value assigned.
- Throws:
BuildException- Thrown if the key was malformed or conflicts with values already present along it's path
-
addBuilderBlock
Description copied from interface:JsonBuilderAdd another JsonBuilder (representing an object) with partially filled values to this JSON object.- Specified by:
addBuilderBlockin interfaceJsonBuilder- Parameters:
path- The JSON path/key to place the object at.value- The JsonBuilder value to set at the given key.- Returns:
- The current JSON object, with the new value assigned.
- Throws:
BuildException- Thrown if the key was malformed or conflicts with values already present along it's path
-
addBuilderBlock
Description copied from interface:JsonBuilderUse an existing, compiled piece of JSON, converted to a JsonBuilder, then assigned to the value at the path.- Specified by:
addBuilderBlockin interfaceJsonBuilder- Parameters:
path- The JSON path/key to place the object at.value- The JSON value to set at the given key.- Returns:
- The current JSON object, with the new value assigned.
- Throws:
BuildException- Thrown if the key was malformed or conflicts with values already present along it's path
-
convertFromJSON
Description copied from interface:JsonBuilderBreak a full JSON object down into a builder representation of itself to be added to.- Specified by:
convertFromJSONin interfaceJsonBuilder- Parameters:
json- The JSON object to break into a builder representation.- Returns:
- The given JSON object, as a JsonBuilder.
-
toString
-