public final class EntityJSONParser extends java.lang.Object implements Serializer<Entity>
Serializer.SerializeException
Constructor and Description |
---|
EntityJSONParser(Domain domain) |
Modifier and Type | Method and Description |
---|---|
java.util.List<Entity> |
deserialize(java.lang.String jsonString)
Deserializes the given JSON string into a list of Entity instances
|
java.util.List<Entity> |
deserializeEntities(java.lang.String jsonString)
Deserializes the given JSON string into a list of Entity instances
|
java.util.List<Entity.Key> |
deserializeKeys(java.lang.String jsonString)
Deserializes the given JSON string into a list of Entity.Key instances
|
int |
getIndentation() |
boolean |
isIncludeForeignKeyValues() |
boolean |
isIncludeNullValues() |
boolean |
isIncludeReadOnlyValues() |
Entity |
parseEntity(java.lang.String entityObject)
Parses an Entity instance from the given JSON object string
|
Entity.Key |
parseKey(org.json.JSONObject keyObject)
Parses an Entity.Key instance from the given JSON object
|
Entity.Key |
parseKey(java.lang.String keyObject)
Parses an Entity.Key instance from the given JSON object string
|
java.lang.Object |
parseValue(Property property,
org.json.JSONObject propertyValues)
Fetches the value of the given property from the given JSONObject
|
java.lang.String |
serialize(java.util.List<Entity> entities)
Serializes the given Entity instances into a JSON string array
|
java.lang.String |
serializeEntity(Entity entity)
Serializes the given entity
|
java.lang.String |
serializeKey(Entity.Key key)
Serializes the given key
|
java.lang.String |
serializeKeys(java.util.Collection<Entity.Key> keys)
Serializes the given Entity.Key instances into a JSON string array
|
java.lang.Object |
serializeValue(java.lang.Object value,
Property property)
Serializes the given property value
|
EntityJSONParser |
setIncludeForeignKeyValues(boolean includeForeignKeyValues) |
EntityJSONParser |
setIncludeNullValues(boolean includeNullValues) |
EntityJSONParser |
setIncludeReadOnlyValues(boolean includeReadOnlyValues) |
EntityJSONParser |
setIndentation(int indentation)
Sets the indendation used when exporting to JSON format, -1 means non-human readable, whereas >= 0
means human readable with the given indentation.
|
public EntityJSONParser(Domain domain)
domain
- the underlying domain modelpublic boolean isIncludeForeignKeyValues()
public EntityJSONParser setIncludeForeignKeyValues(boolean includeForeignKeyValues)
includeForeignKeyValues
- if true then the foreign key graph is included in serialized entitiesEntityJSONParser
instancepublic boolean isIncludeNullValues()
public EntityJSONParser setIncludeNullValues(boolean includeNullValues)
includeNullValues
- true if null values should be included in exported entitiesEntityJSONParser
instancepublic boolean isIncludeReadOnlyValues()
public EntityJSONParser setIncludeReadOnlyValues(boolean includeReadOnlyValues)
includeReadOnlyValues
- true if read only values should be included in exported entitiesEntityJSONParser
instancepublic int getIndentation()
public EntityJSONParser setIndentation(int indentation)
indentation
- if >= 0 then the serialized form will be human readable with the given indentationEntityJSONParser
instancepublic java.lang.String serialize(java.util.List<Entity> entities) throws Serializer.SerializeException
serialize
in interface Serializer<Entity>
entities
- the entitiesSerializeException
- in case of an exceptionSerializer.SerializeException
public java.util.List<Entity> deserialize(java.lang.String jsonString) throws Serializer.SerializeException
deserialize
in interface Serializer<Entity>
jsonString
- the JSON string to parseSerializeException
- in case of an exceptionSerializer.SerializeException
public java.lang.String serializeKeys(java.util.Collection<Entity.Key> keys)
keys
- the keyspublic java.lang.String serializeEntity(Entity entity)
entity
- the Entity to serializepublic java.lang.String serializeKey(Entity.Key key)
key
- the keypublic java.lang.Object serializeValue(java.lang.Object value, Property property)
value
- the valueproperty
- the propertypublic java.util.List<Entity> deserializeEntities(java.lang.String jsonString)
jsonString
- the JSON string to parsepublic java.util.List<Entity.Key> deserializeKeys(java.lang.String jsonString)
jsonString
- the JSON string to parsepublic Entity parseEntity(java.lang.String entityObject)
entityObject
- the JSON object string representing the entitypublic Entity.Key parseKey(java.lang.String keyObject)
keyObject
- the JSON object string representing the entitypublic Entity.Key parseKey(org.json.JSONObject keyObject)
keyObject
- the JSON object representing the entity keyjava.lang.IllegalArgumentException
- in case of an undefined entitypublic java.lang.Object parseValue(Property property, org.json.JSONObject propertyValues)
property
- the propertypropertyValues
- the JSONObject containing the value