50 |
26 Feb 19 |
nicklas |
1 |
package org.json.simple.parser; |
50 |
26 Feb 19 |
nicklas |
2 |
|
50 |
26 Feb 19 |
nicklas |
3 |
import java.io.IOException; |
50 |
26 Feb 19 |
nicklas |
4 |
|
50 |
26 Feb 19 |
nicklas |
5 |
/** |
50 |
26 Feb 19 |
nicklas |
* A simplified and stoppable SAX-like content handler for stream processing of JSON text. |
50 |
26 Feb 19 |
nicklas |
7 |
* |
50 |
26 Feb 19 |
nicklas |
* @see org.xml.sax.ContentHandler |
50 |
26 Feb 19 |
nicklas |
* @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean) |
50 |
26 Feb 19 |
nicklas |
10 |
* |
50 |
26 Feb 19 |
nicklas |
* @author FangYidong<fangyidong@yahoo.com.cn> |
50 |
26 Feb 19 |
nicklas |
12 |
*/ |
50 |
26 Feb 19 |
nicklas |
13 |
public interface ContentHandler { |
50 |
26 Feb 19 |
nicklas |
14 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the beginning of JSON processing. |
50 |
26 Feb 19 |
nicklas |
* The parser will invoke this method only once. |
50 |
26 Feb 19 |
nicklas |
17 |
* |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
* - JSONParser will stop and throw the same exception to the caller when receiving this exception. |
50 |
26 Feb 19 |
nicklas |
20 |
*/ |
50 |
26 Feb 19 |
nicklas |
21 |
void startJSON() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
22 |
|
50 |
26 Feb 19 |
nicklas |
23 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the end of JSON processing. |
50 |
26 Feb 19 |
nicklas |
25 |
* |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
27 |
*/ |
50 |
26 Feb 19 |
nicklas |
28 |
void endJSON() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
29 |
|
50 |
26 Feb 19 |
nicklas |
30 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the beginning of a JSON object. |
50 |
26 Feb 19 |
nicklas |
32 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
* - JSONParser will stop and throw the same exception to the caller when receiving this exception. |
50 |
26 Feb 19 |
nicklas |
* @see #endJSON |
50 |
26 Feb 19 |
nicklas |
37 |
*/ |
50 |
26 Feb 19 |
nicklas |
38 |
boolean startObject() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
39 |
|
50 |
26 Feb 19 |
nicklas |
40 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the end of a JSON object. |
50 |
26 Feb 19 |
nicklas |
42 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
45 |
* |
50 |
26 Feb 19 |
nicklas |
* @see #startObject |
50 |
26 Feb 19 |
nicklas |
47 |
*/ |
50 |
26 Feb 19 |
nicklas |
48 |
boolean endObject() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
49 |
|
50 |
26 Feb 19 |
nicklas |
50 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the beginning of a JSON object entry. |
50 |
26 Feb 19 |
nicklas |
52 |
* |
50 |
26 Feb 19 |
nicklas |
* @param key - Key of a JSON object entry. |
50 |
26 Feb 19 |
nicklas |
54 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
57 |
* |
50 |
26 Feb 19 |
nicklas |
* @see #endObjectEntry |
50 |
26 Feb 19 |
nicklas |
59 |
*/ |
50 |
26 Feb 19 |
nicklas |
60 |
boolean startObjectEntry(String key) throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
61 |
|
50 |
26 Feb 19 |
nicklas |
62 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the end of the value of previous object entry. |
50 |
26 Feb 19 |
nicklas |
64 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
67 |
* |
50 |
26 Feb 19 |
nicklas |
* @see #startObjectEntry |
50 |
26 Feb 19 |
nicklas |
69 |
*/ |
50 |
26 Feb 19 |
nicklas |
70 |
boolean endObjectEntry() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
71 |
|
50 |
26 Feb 19 |
nicklas |
72 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the beginning of a JSON array. |
50 |
26 Feb 19 |
nicklas |
74 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
77 |
* |
50 |
26 Feb 19 |
nicklas |
* @see #endArray |
50 |
26 Feb 19 |
nicklas |
79 |
*/ |
50 |
26 Feb 19 |
nicklas |
80 |
boolean startArray() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
81 |
|
50 |
26 Feb 19 |
nicklas |
82 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the end of a JSON array. |
50 |
26 Feb 19 |
nicklas |
84 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
87 |
* |
50 |
26 Feb 19 |
nicklas |
* @see #startArray |
50 |
26 Feb 19 |
nicklas |
89 |
*/ |
50 |
26 Feb 19 |
nicklas |
90 |
boolean endArray() throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
91 |
|
50 |
26 Feb 19 |
nicklas |
92 |
/** |
50 |
26 Feb 19 |
nicklas |
* Receive notification of the JSON primitive values: |
50 |
26 Feb 19 |
nicklas |
* java.lang.String, |
50 |
26 Feb 19 |
nicklas |
* java.lang.Number, |
50 |
26 Feb 19 |
nicklas |
* java.lang.Boolean |
50 |
26 Feb 19 |
nicklas |
* null |
50 |
26 Feb 19 |
nicklas |
98 |
* |
50 |
26 Feb 19 |
nicklas |
* @param value - Instance of the following: |
50 |
26 Feb 19 |
nicklas |
* java.lang.String, |
50 |
26 Feb 19 |
nicklas |
* java.lang.Number, |
50 |
26 Feb 19 |
nicklas |
* java.lang.Boolean |
50 |
26 Feb 19 |
nicklas |
* null |
50 |
26 Feb 19 |
nicklas |
104 |
* |
50 |
26 Feb 19 |
nicklas |
* @return false if the handler wants to stop parsing after return. |
50 |
26 Feb 19 |
nicklas |
* @throws ParseException |
50 |
26 Feb 19 |
nicklas |
107 |
*/ |
50 |
26 Feb 19 |
nicklas |
108 |
boolean primitive(Object value) throws ParseException, IOException; |
50 |
26 Feb 19 |
nicklas |
109 |
|
50 |
26 Feb 19 |
nicklas |
110 |
} |