[caboto commit] r543 - ASSIGNED - # 236: Repeating properties per annotation

1 view
Skip to first unread message

codesite...@google.com

unread,
Jul 10, 2009, 8:50:18 AM7/10/09
to cabot...@googlegroups.com
Author: jasper....@gmail.com
Date: Fri Jul 10 05:49:44 2009
New Revision: 543

Modified:

branches/multi_valued/caboto/src/main/java/org/caboto/CabotoJsonSupport.java

Log:
ASSIGNED - # 236: Repeating properties per annotation
https://webfutures.ilrt.bris.ac.uk/stars/ticket/236

Modified:
branches/multi_valued/caboto/src/main/java/org/caboto/CabotoJsonSupport.java
==============================================================================
---
branches/multi_valued/caboto/src/main/java/org/caboto/CabotoJsonSupport.java
(original)
+++
branches/multi_valued/caboto/src/main/java/org/caboto/CabotoJsonSupport.java
Fri Jul 10 05:49:44 2009
@@ -33,9 +33,6 @@
*/
package org.caboto;

-import java.util.ArrayList;
-import java.util.Collection;
-
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
@@ -78,6 +75,10 @@
}

public JSONObject generateJsonObject(Resource resource) throws
JSONException {
+ return generateJsonObject(resource, false);
+ }
+
+ public JSONObject generateJsonObject(Resource resource, boolean
multiValued) throws JSONException {

JSONObject jsonObject = new JSONObject();
jsonObject.put("id", resource.getURI());
@@ -106,14 +107,18 @@
}

} else {
- jsonObject.put(key, generateJsonObject((Resource)
stmt.getObject()));
+ jsonObject.put(key, generateJsonObject((Resource)
stmt.getObject(), true));
}

} else if (stmt.getObject().isLiteral()) {
- if(!jsonObject.has(key)) {
- jsonObject.put(key, new JSONArray());
+ if(multiValued) {
+ if(!jsonObject.has(key)) {
+ jsonObject.put(key, new JSONArray());
+ }
+ jsonObject.getJSONArray(key).put(((Literal)
stmt.getObject()).getLexicalForm());
+ } else {
+ jsonObject.put(key, ((Literal)
stmt.getObject()).getLexicalForm());
}
- jsonObject.getJSONArray(key).put(((Literal)
stmt.getObject()).getLexicalForm());
}

}

Reply all
Reply to author
Forward
0 new messages