aboutsummaryrefslogtreecommitdiff
path: root/src/org/json/simple/parser/ContentHandler.java
blob: 5ed233db744eb2ef679dfcea7aedd0d71256a11b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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(rejava.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(final 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(final Object value) throws ParseException, IOException;

}