json-simple/trunk/src/main/java/org/json/simple/parser/ContentHandler.java

Code
Comments
Other
Rev Date Author Line
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 6  * 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 8  * @see org.xml.sax.ContentHandler
50 26 Feb 19 nicklas 9  * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean)
50 26 Feb 19 nicklas 10  * 
50 26 Feb 19 nicklas 11  * @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 15    * Receive notification of the beginning of JSON processing.
50 26 Feb 19 nicklas 16    * The parser will invoke this method only once.
50 26 Feb 19 nicklas 17      * 
50 26 Feb 19 nicklas 18    * @throws ParseException 
50 26 Feb 19 nicklas 19    *       - 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 24    * Receive notification of the end of JSON processing.
50 26 Feb 19 nicklas 25    * 
50 26 Feb 19 nicklas 26    * @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 31    * Receive notification of the beginning of a JSON object.
50 26 Feb 19 nicklas 32    * 
50 26 Feb 19 nicklas 33    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 34    * @throws ParseException
50 26 Feb 19 nicklas 35      *          - JSONParser will stop and throw the same exception to the caller when receiving this exception.
50 26 Feb 19 nicklas 36      * @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 41    * Receive notification of the end of a JSON object.
50 26 Feb 19 nicklas 42    * 
50 26 Feb 19 nicklas 43    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 44    * @throws ParseException
50 26 Feb 19 nicklas 45      * 
50 26 Feb 19 nicklas 46      * @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 51    * Receive notification of the beginning of a JSON object entry.
50 26 Feb 19 nicklas 52    * 
50 26 Feb 19 nicklas 53    * @param key - Key of a JSON object entry. 
50 26 Feb 19 nicklas 54    * 
50 26 Feb 19 nicklas 55    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 56    * @throws ParseException
50 26 Feb 19 nicklas 57      * 
50 26 Feb 19 nicklas 58      * @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 63    * Receive notification of the end of the value of previous object entry.
50 26 Feb 19 nicklas 64    * 
50 26 Feb 19 nicklas 65    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 66    * @throws ParseException
50 26 Feb 19 nicklas 67      * 
50 26 Feb 19 nicklas 68      * @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 73    * Receive notification of the beginning of a JSON array.
50 26 Feb 19 nicklas 74    * 
50 26 Feb 19 nicklas 75    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 76    * @throws ParseException
50 26 Feb 19 nicklas 77      * 
50 26 Feb 19 nicklas 78      * @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 83    * Receive notification of the end of a JSON array.
50 26 Feb 19 nicklas 84    * 
50 26 Feb 19 nicklas 85    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 86    * @throws ParseException
50 26 Feb 19 nicklas 87      * 
50 26 Feb 19 nicklas 88      * @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 93    * Receive notification of the JSON primitive values:
50 26 Feb 19 nicklas 94    *   java.lang.String,
50 26 Feb 19 nicklas 95    *   java.lang.Number,
50 26 Feb 19 nicklas 96    *   java.lang.Boolean
50 26 Feb 19 nicklas 97    *   null
50 26 Feb 19 nicklas 98    * 
50 26 Feb 19 nicklas 99    * @param value - Instance of the following:
50 26 Feb 19 nicklas 100    *       java.lang.String,
50 26 Feb 19 nicklas 101    *       java.lang.Number,
50 26 Feb 19 nicklas 102    *       java.lang.Boolean
50 26 Feb 19 nicklas 103    *       null
50 26 Feb 19 nicklas 104    * 
50 26 Feb 19 nicklas 105    * @return false if the handler wants to stop parsing after return.
50 26 Feb 19 nicklas 106    * @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 }