aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/server/protocol/ProtocolUtils.java
diff options
context:
space:
mode:
authorMatt Windsor <mattwindsor@btinternet.com>2011-03-20 17:09:11 +0000
committerMatt Windsor <mattwindsor@btinternet.com>2011-03-20 17:09:11 +0000
commit0645ec66e1618ce4b52e56212c79196dd7c5c608 (patch)
tree95b103c7577b4039eabe18cfda7ee8e7ca80e61b /src/uk/org/ury/server/protocol/ProtocolUtils.java
parentcee53b021632c95f1b4882664a31ca639a9b0700 (diff)
Begin migration to HttpCore request handler pattern. Delete protocol duplicates left over from last commit.
Diffstat (limited to 'src/uk/org/ury/server/protocol/ProtocolUtils.java')
-rw-r--r--src/uk/org/ury/server/protocol/ProtocolUtils.java67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/uk/org/ury/server/protocol/ProtocolUtils.java b/src/uk/org/ury/server/protocol/ProtocolUtils.java
deleted file mode 100644
index e45bb22..0000000
--- a/src/uk/org/ury/server/protocol/ProtocolUtils.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *
- */
-package uk.org.ury.server.protocol;
-
-import java.util.Map;
-
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-
-
-/**
- * Utilities for converting between strings encoded in the response
- * protocol and collections of items.
- *
- * @author Matt Windsor
- *
- */
-
-public class ProtocolUtils
-{
- /**
- * Encode a key-value map into a protocol string.
- *
- * The map can contain strings, lists and other maps. Other
- * types may be accepted by the underlying encoding engine,
- * but the above types are the only ones explicitly accepted.
- *
- * @param items The key-value map of items, which should contain
- * strings, lists and maps. The keys of any map
- * should be protocol directives.
- *
- * @return A string containing the encoded representation of
- * the map.
- */
-
- public static String
- encode (Map<String, Object> items)
- {
- return JSONValue.toJSONString (items);
- }
-
-
- /**
- * Decode a protocol string into a key-value map.
- *
- * @param string The string to decode.
- *
- * @return A key-value map mapping directives to strings,
- * lists and maps.
- *
- * @throws DecodeFailureException if the decoding engine
- * returns something other than a map.
- */
-
- public static Map<?, ?>
- decode (String string) throws DecodeFailureException
- {
- Object result = JSONValue.parse (string);
-
- if (result instanceof JSONObject)
- return (JSONObject) result;
- else
- throw new DecodeFailureException ("Result not a map.");
- }
-
-}