diff options
author | Taylor Kelly <tkelly910@gmail.com> | 2011-01-03 12:16:00 +0800 |
---|---|---|
committer | Dinner Bone <dinnerbone@dinnerbone.com> | 2011-01-03 23:15:15 +0800 |
commit | 3d0de63fc441a2f880c69752481bc19c98e68074 (patch) | |
tree | e24dfdb048647ecfda6581fa8de6141bb9628521 /src/main/java/org/json/simple/parser/ContentHandler.java | |
parent | 76e4185b212041924884dca8a53c610cb0244fc4 (diff) | |
download | bukkit-3d0de63fc441a2f880c69752481bc19c98e68074.tar bukkit-3d0de63fc441a2f880c69752481bc19c98e68074.tar.gz bukkit-3d0de63fc441a2f880c69752481bc19c98e68074.tar.lz bukkit-3d0de63fc441a2f880c69752481bc19c98e68074.tar.xz bukkit-3d0de63fc441a2f880c69752481bc19c98e68074.zip |
json stuff
Diffstat (limited to 'src/main/java/org/json/simple/parser/ContentHandler.java')
-rw-r--r-- | src/main/java/org/json/simple/parser/ContentHandler.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/main/java/org/json/simple/parser/ContentHandler.java b/src/main/java/org/json/simple/parser/ContentHandler.java new file mode 100644 index 00000000..ae8d0655 --- /dev/null +++ b/src/main/java/org/json/simple/parser/ContentHandler.java @@ -0,0 +1,110 @@ +package org.json.simple.parser;
+
+import java.io.IOException;
+
+/**
+ * A simplified and stoppable SAX-like content handler for stream processing of JSON text.
+ *
+ * @see org.xml.sax.ContentHandler
+ * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean)
+ *
+ * @author FangYidong<fangyidong@yahoo.com.cn>
+ */
+public interface ContentHandler {
+ /**
+ * Receive notification of the beginning of JSON processing.
+ * The parser will invoke this method only once.
+ *
+ * @throws ParseException
+ * - JSONParser will stop and throw the same exception to the caller when receiving this exception.
+ */
+ void startJSON() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the end of JSON processing.
+ *
+ * @throws ParseException
+ */
+ void endJSON() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the beginning of a JSON object.
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ * - JSONParser will stop and throw the same exception to the caller when receiving this exception.
+ * @see #endJSON
+ */
+ boolean startObject() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the end of a JSON object.
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ *
+ * @see #startObject
+ */
+ boolean endObject() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the beginning of a JSON object entry.
+ *
+ * @param key - Key of a JSON object entry.
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ *
+ * @see #endObjectEntry
+ */
+ boolean startObjectEntry(String key) throws ParseException, IOException;
+
+ /**
+ * Receive notification of the end of the value of previous object entry.
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ *
+ * @see #startObjectEntry
+ */
+ boolean endObjectEntry() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the beginning of a JSON array.
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ *
+ * @see #endArray
+ */
+ boolean startArray() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the end of a JSON array.
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ *
+ * @see #startArray
+ */
+ boolean endArray() throws ParseException, IOException;
+
+ /**
+ * Receive notification of the JSON primitive values:
+ * java.lang.String,
+ * java.lang.Number,
+ * java.lang.Boolean
+ * null
+ *
+ * @param value - Instance of the following:
+ * java.lang.String,
+ * java.lang.Number,
+ * java.lang.Boolean
+ * null
+ *
+ * @return false if the handler wants to stop parsing after return.
+ * @throws ParseException
+ */
+ boolean primitive(Object value) throws ParseException, IOException;
+
+}
|