info.sswap.http.representation.json
Class JsonPropertyFactory

java.lang.Object
  extended by info.sswap.http.representation.json.JsonPropertyFactory

public class JsonPropertyFactory
extends java.lang.Object

Builds a Property object (and its associated Value, if applicable) for an entity.

Author:
Blazej Bulka

Constructor Summary
JsonPropertyFactory()
           
 
Method Summary
private static ArrayValue buildArrayValue(org.json.JSONArray array, Prefixes prefixes)
           
private static LiteralValue buildLiteralValueFromJSONObject(org.json.JSONObject valueObject, Property property, Prefixes prefixes)
          Builds a property value object/reads information about the property (for complex property representations like "prefix:property" : { "value" : "42" } -- since only the complex representations can set datatype and cardinality restrictions).
static Property buildProperty(org.json.JSONObject enclosingObject, java.lang.String key, Prefixes prefixes)
          Builds a Property object (and its associated Value, if applicable).
private static Value buildValueFromComplexRepresentation(org.json.JSONObject valueObject, Property property, Prefixes prefixes)
          Builds a value based on the complex form of value representation (e.g., { "value" : 42, "cardinality" : [ 0, 1 ] } or a nested entity).
private static boolean containsOnlyValueDefKeywords(org.json.JSONObject valueObject)
          Checks whether a JSON object contains only the keywords that are used to define a value (e.g,.
private static LiteralValue createLiteralValue(java.lang.String explicitDatatype, java.lang.String value, Prefixes prefixes)
           
private static java.lang.String extractLiteralTypeFromValue(java.lang.String value, Prefixes prefixes)
           
private static java.lang.String extractLiteralValueWithoutType(java.lang.String value)
           
private static void processCardinality(org.json.JSONObject valueObject, Property property)
          Processes cardinality restriction definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonPropertyFactory

public JsonPropertyFactory()
Method Detail

buildProperty

public static Property buildProperty(org.json.JSONObject enclosingObject,
                                     java.lang.String key,
                                     Prefixes prefixes)
                              throws org.json.JSONException
Builds a Property object (and its associated Value, if applicable).

Parameters:
enclosingObject - the JSON object enclosing the property (i.e., the object where the key name is the URI/QName of the property).
key - the key in the enclosingObject
prefixes - the read namespace prefix definition (for QName expansion)
Returns:
the created property object
Throws:
org.json.JSONException - if a syntax error should occur

buildArrayValue

private static ArrayValue buildArrayValue(org.json.JSONArray array,
                                          Prefixes prefixes)
                                   throws org.json.JSONException
Throws:
org.json.JSONException

buildValueFromComplexRepresentation

private static Value buildValueFromComplexRepresentation(org.json.JSONObject valueObject,
                                                         Property property,
                                                         Prefixes prefixes)
                                                  throws org.json.JSONException
Builds a value based on the complex form of value representation (e.g., { "value" : 42, "cardinality" : [ 0, 1 ] } or a nested entity).

Parameters:
valueObject - the JSON object containing the complex value representation
property - the property pointing to this valueObject (may be null, if this value is within an array).
prefixes - the prefix definition
Returns:
the created value
Throws:
org.json.JSONException - if a syntax error should occur

buildLiteralValueFromJSONObject

private static LiteralValue buildLiteralValueFromJSONObject(org.json.JSONObject valueObject,
                                                            Property property,
                                                            Prefixes prefixes)
                                                     throws org.json.JSONException
Builds a property value object/reads information about the property (for complex property representations like "prefix:property" : { "value" : "42" } -- since only the complex representations can set datatype and cardinality restrictions).

Parameters:
valueObject - the JSON object that corresponds to the complex property representation (e.g., { "value" : "42" }
property - the Property being created
prefixes - the read namespace prefix definition (for QName expansion)
Returns:
the created Value (may be null)
Throws:
org.json.JSONException - if a syntax error should occur

processCardinality

private static void processCardinality(org.json.JSONObject valueObject,
                                       Property property)
                                throws org.json.JSONException
Processes cardinality restriction definition.

Parameters:
valueObject - the object containing the cardinality keywords (if any)
property - the property for which the cardinality restriction should apply
Throws:
org.json.JSONException - if a syntax error should occur

containsOnlyValueDefKeywords

private static boolean containsOnlyValueDefKeywords(org.json.JSONObject valueObject)
Checks whether a JSON object contains only the keywords that are used to define a value (e.g,. "value", "cardinality" etc.)

Parameters:
valueObject - the object to be checked
Returns:
true if the object contains only these keywords, false otherwise

createLiteralValue

private static LiteralValue createLiteralValue(java.lang.String explicitDatatype,
                                               java.lang.String value,
                                               Prefixes prefixes)

extractLiteralTypeFromValue

private static java.lang.String extractLiteralTypeFromValue(java.lang.String value,
                                                            Prefixes prefixes)

extractLiteralValueWithoutType

private static java.lang.String extractLiteralValueWithoutType(java.lang.String value)


Copyright (c) 2010, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.