Files
json-simple/src/org/json/simple/parser/ContentHandler.java
2009-01-23 06:28:59 +00:00

100 lines
2.8 KiB
Java

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
*
* @author FangYidong<fangyidong@yahoo.com.cn>
*/
public interface ContentHandler {
/**
* Receive notification of the beginning of JSON processing.
*
* User can throw a ParseException with errorType ParseException.INFO_USER_STOP to let the parser stop.
*
* @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.
*
* @return false if the handler wants to stop parsing after return.
* @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
*/
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
*/
boolean endObject() throws ParseException, IOException;
/**
* Receive notification of the beginning of a JSON object key value pair.
*
* @param key - Key of a JSON object key value pair.
*
* @return false if the handler wants to stop parsing after return.
* @throws ParseException
*/
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
*/
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
*/
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
*/
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;
}