info.sswap.http.representation.json
Class JsonMappingFactory

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

public class JsonMappingFactory
extends java.lang.Object

A factory for parsing Json encoding of the subject-object mapping.

Author:
Blazej Bulka

Constructor Summary
JsonMappingFactory()
           
 
Method Summary
static Mapping buildMapping(org.json.JSONObject jsonObject, Prefixes prefixes)
          Builds a mapping from the Json representation.
static java.util.Collection<Mapping> buildMappings(org.json.JSONArray jsonArray, Prefixes prefixes)
          Builds a mapping from the Json representation.
private static java.util.Collection<java.lang.String> processArray(org.json.JSONArray array, Prefixes prefixes)
          Converts a JSON array of QNames into a corresponding collection of URIs (encoded as strings)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonMappingFactory

public JsonMappingFactory()
Method Detail

buildMappings

public static java.util.Collection<Mapping> buildMappings(org.json.JSONArray jsonArray,
                                                          Prefixes prefixes)
                                                   throws org.json.JSONException
Builds a mapping from the Json representation. The JSON representation is expected to have the following structure: [ { "prefix:SubjectClass1" : [ "prefix:Object1Class", "prefix:Object2Class" ], "prefix:SubjectClass2" : "prefix:Object3Class" }, ... ]

Parameters:
jsonArray - the json array with the mappings
prefixes - the definition of namespace prefixes (for QName expansion)
Returns:
the representation of the subject-object in the form of a map; keys are subject URIs and the values are the collection of object URis
Throws:
org.json.JSONException

buildMapping

public static Mapping buildMapping(org.json.JSONObject jsonObject,
                                   Prefixes prefixes)
                            throws org.json.JSONException
Builds a mapping from the Json representation. The JSON representation is expected to have the following structure: { "prefix:SubjectClass1" : [ "prefix:Object1Class", "prefix:Object2Class" ], "prefix:SubjectClass2" : "prefix:Object3Class" }

Parameters:
jsonObject - the json object with the mapping
prefixes - the definition of namespace prefixes (for QName expansion)
Returns:
the representation of the subject-object in the form of a map; keys are subject URIs and the values are the collection of object URis
Throws:
org.json.JSONException

processArray

private static java.util.Collection<java.lang.String> processArray(org.json.JSONArray array,
                                                                   Prefixes prefixes)
                                                            throws org.json.JSONException
Converts a JSON array of QNames into a corresponding collection of URIs (encoded as strings)

Parameters:
array - the JSON array
prefixes - the prefix information for QName expansion
Returns:
a collection of strings
Throws:
org.json.JSONException - if any of the elements of the array is not a plain json string


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