public class JsonSource extends AbstractJsonSource
In the context of JSON Discoverer, it is used to model a single JSON-based Web service.
JSON documents are represented as JsonData
elements.
The set of JSON documents can be retrieved by calling the method getJsonData()
.
As JsonData
elements can include input elements (to represent which JSON data
has triggered such JSON document), a JsonSource
can include JsonData
elements with
or without input. To know whether the JsonData
elements included in the JsonSource
have input elements, you have to call the method withInput
.
Note that all the JsonData
elements included in a JsonSource
have to include (or
not include) inputs.
Modifier and Type | Field and Description |
---|---|
protected java.util.List<JsonData> |
jsonData
List of JSON documents
|
boolean |
withInput
Sets if the set of JSON documents are the result of computing an input
JSON document (to support JSON-based Web APIs)
|
Constructor and Description |
---|
JsonSource(java.lang.String name)
Builds a new JsonSource with a name.
|
Modifier and Type | Method and Description |
---|---|
void |
addJsonData(java.io.Reader input,
java.io.Reader output)
Adds a new JSON document as well as the input JSON document (optional) to get such a document.
|
private JsonData |
buildJsonData(java.io.Reader input,
java.io.Reader output)
Builds a
JsonData element out of a JSON document representing the input and another
JSON document representing the output. |
protected java.util.List<JsonData> |
getJsonData()
Gets the set of
JsonData elements linked to this source. |
java.util.List<com.google.gson.JsonObject> |
getSourceDigested()
Generates a list of JSON objects according to the
JsonData of this source. |
boolean |
includesInput()
Indicates if the JsonSource includes input elements.
|
getMetamodel, getName, setMetamodel, setName
protected java.util.List<JsonData> jsonData
public boolean withInput
public JsonSource(java.lang.String name)
addJsonData(Reader, Reader)
.name
- The name of the JsonSourceprotected java.util.List<JsonData> getJsonData()
JsonData
elements linked to this source.
Warning: the returned list is mutableJsonData
public boolean includesInput()
Note that all of them have to include (or not include) input elements
private JsonData buildJsonData(java.io.Reader input, java.io.Reader output)
JsonData
element out of a JSON document representing the input and another
JSON document representing the output.
The input/output must be provided as a valid JSON objects.
input
- The Reader
from which obtain JSON document used as input (optional)output
- The Reader
from which obtain the JSON documentJsonData
with the JSON document and the inputjava.lang.IllegalArgumentException
- If any reader is nullpublic void addJsonData(java.io.Reader input, java.io.Reader output)
The input/output must be provided as a valid JSON objects.
Warning: Once the source has been created with input (or without), subsequent calls must also include (or not) inputs
input
- The Reader
from which obtain the JSON document used as input (optional)output
- The Reader
from which obtain the JSON documentjava.lang.IllegalArgumentException
- If input is nulljava.lang.IllegalStateException
- If the JSON source was initially created to not hold input datapublic java.util.List<com.google.gson.JsonObject> getSourceDigested()
JsonData
of this source.
JsonData
. For instance:- [input JSON element 1] +-- Output +-- [output JSON element 1] - [input JSON element 2] +-- Output +-- [output JSON element 2] -...
JsonData
. For instance- [output JSON element 1] - [output JSON element 2] - [output JSON element 3] -...
JsonObject
s