You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/08/21 10:10:35 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/xni/parser XMLPullParserConfiguration.java XMLParserConfiguration.java

andyc       01/08/21 01:10:35

  Modified:    java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        StandardParserConfiguration.java
               java/src/org/apache/xerces/xni/parser Tag: xerces_j_2
                        XMLParserConfiguration.java
  Added:       java/src/org/apache/xerces/xni/parser Tag: xerces_j_2
                        XMLPullParserConfiguration.java
  Log:
  Added pull parser configuration interface to XNI and updated
  the standard parser configuration so that it can be used as
  a pull parser.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.17  +94 -9     xml-xerces/java/src/org/apache/xerces/parsers/Attic/StandardParserConfiguration.java
  
  Index: StandardParserConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/StandardParserConfiguration.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- StandardParserConfiguration.java	2001/08/16 07:38:33	1.1.2.16
  +++ StandardParserConfiguration.java	2001/08/21 08:10:35	1.1.2.17
  @@ -79,12 +79,15 @@
   import org.apache.xerces.xni.parser.XMLDocumentScanner;
   import org.apache.xerces.xni.parser.XMLDTDScanner;
   import org.apache.xerces.xni.parser.XMLInputSource;
  +import org.apache.xerces.xni.parser.XMLPullParserConfiguration;
   
  -//import org.xml.sax.Locator;
  -
   /**
    * This is the "standard" parser configuration. It extends the basic
  - * configuration with the standard set of parser components.
  + * configuration with the standard set of parser components. Since
  + * the Xerces2 reference implementation document and DTD scanner
  + * implementations are capable of acting as pull parsers, the
  + * standard configuration implements the 
  + * <code>XMLPullParserConfiguration</code> interface.
    * <p>
    * In addition to the features and properties recognized by the base
    * parser configuration, this class recognizes these additional 
  @@ -105,7 +108,7 @@
    *   <li>http://apache.org/xml/properties/internal/document-scanner</li>
    *   <li>http://apache.org/xml/properties/internal/dtd-scanner</li>
    *   <li>http://apache.org/xml/properties/internal/grammar-pool</li>
  - *   <li>http://apache.org/xml/properties/internal/validator</li>
  + *   <li>http://apache.org/xml/properties/internal/validator/dtd</li>
    *   <li>http://apache.org/xml/properties/internal/datatype-validator-factory</li>
    *  </ul>
    * </ul>
  @@ -113,10 +116,11 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: StandardParserConfiguration.java,v 1.1.2.16 2001/08/16 07:38:33 andyc Exp $
  + * @version $Id: StandardParserConfiguration.java,v 1.1.2.17 2001/08/21 08:10:35 andyc Exp $
    */
   public class StandardParserConfiguration
  -    extends BasicParserConfiguration {
  +    extends BasicParserConfiguration 
  +    implements XMLPullParserConfiguration {
   
       //
       // Constants
  @@ -391,6 +395,88 @@
       } // setLocale(Locale)
   
       //
  +    // XMLPullParserConfiguration methods
  +    //
  +
  +    // parsing
  +
  +    /**
  +     * Sets the input source for the document to parse.
  +     *
  +     * @param inputSource The document's input source.
  +     *
  +     * @exception XMLConfigurationException Thrown if there is a 
  +     *                        configuration error when initializing the
  +     *                        parser.
  +     * @exception IOException Thrown on I/O error.
  +     *
  +     * @see #parse(boolean)
  +     */
  +    public void setInputSource(XMLInputSource inputSource)
  +        throws XMLConfigurationException, IOException {
  +
  +        try {
  +            reset();
  +            fScanner.setInputSource(inputSource);
  +        } 
  +        catch (XNIException ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (IOException ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (Exception ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw new XNIException(ex);
  +        }
  +
  +    } // setInputSource(XMLInputSource)
  +
  +    /**
  +     * Parses the document in a pull parsing fashion.
  +     *
  +     * @param complete True if the pull parser should parse the
  +     *                 remaining document completely.
  +     *
  +     * @returns True if there is more document to parse.
  +     *
  +     * @exception XNIException Any XNI exception, possibly wrapping 
  +     *                         another exception.
  +     * @exception IOException  An IO exception from the parser, possibly
  +     *                         from a byte stream or character stream
  +     *                         supplied by the parser.
  +     *
  +     * @see #setInputSource
  +     */
  +    public boolean parse(boolean complete) throws XNIException, IOException {
  +        
  +        try {
  +            return fScanner.scanDocument(complete);
  +        } 
  +        catch (XNIException ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (IOException ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (Exception ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw new XNIException(ex);
  +        }
  +
  +    } // parse(boolean):boolean
  +
  +    //
       // XMLParserConfiguration methods
       //
   
  @@ -411,9 +497,8 @@
           fParseInProgress = true;
   
           try {
  -            reset();
  -            fScanner.setInputSource(source);
  -            fScanner.scanDocument(true);
  +            setInputSource(source);
  +            parse(true);
           } 
           catch (XNIException ex) {
               if (PRINT_EXCEPTION_STACK_TRACE)
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +2 -2      xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLParserConfiguration.java
  
  Index: XMLParserConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLParserConfiguration.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- XMLParserConfiguration.java	2001/07/24 08:10:35	1.1.2.5
  +++ XMLParserConfiguration.java	2001/08/21 08:10:35	1.1.2.6
  @@ -112,7 +112,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLParserConfiguration.java,v 1.1.2.5 2001/07/24 08:10:35 andyc Exp $
  + * @version $Id: XMLParserConfiguration.java,v 1.1.2.6 2001/08/21 08:10:35 andyc Exp $
    */
   public interface XMLParserConfiguration
       extends XMLComponentManager {
  @@ -267,4 +267,4 @@
        */
       public void setLocale(Locale locale) throws XNIException;
   
  -} // interface ParserConfiguration
  +} // interface XMLParserConfiguration
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +128 -0    xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLPullParserConfiguration.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org