diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-08 08:18:07 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-08 08:18:07 +0000 |
commit | 49b878b1b0f2e52bbd5282c22ac32a68e1e8736c (patch) | |
tree | 1eb26926f9d703c61b329a0f07178090b57cd55d /sca-cpp/trunk/modules/java | |
parent | 5b33dc5c5a87fff146951ca0543bf558454c331d (diff) |
Change ATOM and RSS feed representations to use name value pairs instead of just strings, to allow support for all ATOM and RSS attributes and avoid confusion with non-feed string results.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1079292 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/java')
-rw-r--r-- | sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java | 30 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/java/test/ServerImpl.java | 16 |
2 files changed, 40 insertions, 6 deletions
diff --git a/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java b/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java index 6d559f370a..2366d79af6 100644 --- a/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java +++ b/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java @@ -117,6 +117,13 @@ public class IterableUtil { } /** + * Return the cdr of the cdr of the cdr of a list. + */ + public static <T> Iterable<T> cdddr(final Object l) { + return cdr(cdr(cdr(l))); + } + + /** * Return the car of the cdr of the cdr of a list. */ @SuppressWarnings("unchecked") @@ -125,6 +132,24 @@ public class IterableUtil { } /** + * Return the car of the cdr of the cdr of the cdr of a list. + */ + @SuppressWarnings("unchecked") + public static <T> T cadddr(final Object l) { + return (T)car(cdddr(l)); + } + + /** + * Appends a list and another list. + */ + @SuppressWarnings("unchecked") + public static <T> Iterable<T> append(final Object a, final Object b) { + if (isNil(a)) + return (Iterable<T>)b; + return cons(car(a), append(cdr(a), b)); + } + + /** * Return the first pair matching a key from a list of key value pairs. */ public static <T> Iterable<T> assoc(final Object k, final Object l) { @@ -352,6 +377,11 @@ public class IterableUtil { assert car(al) == Integer.valueOf(1); assert cadr(al) == Integer.valueOf(2); assert caddr(al) == Integer.valueOf(3); + + final Iterable<Object> a = list(0, 1, 2); + final Iterable<Object> b = list(3, 4); + final Iterable<Object> ab = append(a, b); + assert ab.toString().equals("[0, 1, 2, 3, 4]"); return true; } } diff --git a/sca-cpp/trunk/modules/java/test/ServerImpl.java b/sca-cpp/trunk/modules/java/test/ServerImpl.java index 9de68fdb75..ee25cf7bf8 100644 --- a/sca-cpp/trunk/modules/java/test/ServerImpl.java +++ b/sca-cpp/trunk/modules/java/test/ServerImpl.java @@ -29,12 +29,16 @@ public class ServerImpl { public Iterable<?> get(final Iterable<String> id) { if (isNil(id)) - return list("Sample Feed", "123456789", - list("Item", "111", list(list("'name", "Apple"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 2.99))), - list("Item", "222", list(list("'name", "Orange"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 3.55))), - list("Item", "333", list(list("'name", "Pear"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 1.55)))); - final Iterable<?> entry = list(list("'name", "Apple"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 2.99)); - return list("Item", car(id), entry); + return list(list("'feed", list("'title", "Sample Feed"), list("'id", "123456789"), list("'entry", list( + list(list("'title", "Item"), list("'id", "111"), + list("'content", list("'item", list("'name", "Apple"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 2.99)))), + list(list("'title", "Item"), list("'id", "222"), + list("'content", list("'item", list("'name", "Orange"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 3.55)))), + list(list("'title", "Item"), list("'id", "333"), + list("'content", list("'item", list("'name", "Pear"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 1.55)))))))); + + final Iterable<?> content = list("'content", list("'item", list("'name", "Apple"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 2.99))); + return list(list("'entry", list("'title", "Item"), list("'id", car(id)), content)); } public Iterable<String> post(final Iterable<String> collection, final Iterable<?> item) { |