1 package org.json.simple.parser;
3 import java.io.IOException;
6 * A simplified and stoppable SAX-like content handler for stream processing of
9 * @see org.xml.sax.ContentHandler
10 * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler,
13 * @author FangYidong<fangyidong@yahoo.com.cn>
15 public interface ContentHandler
18 * Receive notification of the beginning of JSON processing. The parser will
19 * invoke this method only once.
21 * @throws ParseException
22 * - JSONParser will stop and throw the same exception to the caller
23 * when receiving this exception.
25 void startJSON() throws ParseException, IOException;
28 * Receive notification of the end of JSON processing.
30 * @throws ParseException
32 void endJSON() throws ParseException, IOException;
35 * Receive notification of the beginning of a JSON object.
37 * @return false if the handler wants to stop parsing after return.
38 * @throws ParseException
39 * - JSONParser will stop and throw the same exception to the caller
40 * when receiving this exception.
43 boolean startObject() throws ParseException, IOException;
46 * Receive notification of the end of a JSON object.
48 * @return false if the handler wants to stop parsing after return.
49 * @throws ParseException
53 boolean endObject() throws ParseException, IOException;
56 * Receive notification of the beginning of a JSON object entry.
59 * - Key of a JSON object entry.
61 * @return false if the handler wants to stop parsing after return.
62 * @throws ParseException
64 * @see #endObjectEntry
66 boolean startObjectEntry(String key) throws ParseException, IOException;
69 * Receive notification of the end of the value of previous object entry.
71 * @return false if the handler wants to stop parsing after return.
72 * @throws ParseException
74 * @see #startObjectEntry
76 boolean endObjectEntry() throws ParseException, IOException;
79 * Receive notification of the beginning of a JSON array.
81 * @return false if the handler wants to stop parsing after return.
82 * @throws ParseException
86 boolean startArray() throws ParseException, IOException;
89 * Receive notification of the end of a JSON array.
91 * @return false if the handler wants to stop parsing after return.
92 * @throws ParseException
96 boolean endArray() throws ParseException, IOException;
99 * Receive notification of the JSON primitive values: java.lang.String,
100 * java.lang.Number, java.lang.Boolean null
103 * - Instance of the following: java.lang.String, java.lang.Number,
104 * java.lang.Boolean null
106 * @return false if the handler wants to stop parsing after return.
107 * @throws ParseException
109 boolean primitive(Object value) throws ParseException, IOException;