[jdom-interest] ResultSetBuilder status?

Bradley S. Huffman hip at csa.cs.okstate.edu
Tue Jun 3 07:34:06 PDT 2003


"Burkhard Keller" writes:

> i have the same problem, today i checked out "jdom" and "jdom-contrib".
> when i try to build the contrib-package, i get the same compilation errors
> as Ethan Cerami...
> 
> ElementScanner version:
> ElementScanner.java,v 1.6 2003/05/19 20:31:46 jhunter
> 
> > It worked for me just now.  Are you sure you're using the very latest
> > CVS code for jdom-contrib?  ElementScanner should be version 1.6.

ElementScanner.java wouldn't compile for me. Below is a patch that removes
the inner class ElementBuilder since all of it's function has been incorporated
into SAXHandler. 

If you don't have a copy of patch handy, you should be able to quickly edit
jdom-contrib/src/java/org/jdom/contrib/input/scanner/ElementScanner.java and
change "factory" to "getFactory()" on line 711, and change "currentElement"
to "getCurrentElement()" on line 804.

Brad

*** ElementScanner.java	Tue Jun  3 09:29:56 2003
--- ElementScanner.new	Tue Jun  3 09:29:40 2003
***************
*** 184,190 ****
     /**
      * The <i>SAXHandler</i> instance to build the JDOM Elements.
      */
!    private              ElementBuilder  elementBuilder  = null;
  
     /**
      * The path of the being parsed element.
--- 184,190 ----
     /**
      * The <i>SAXHandler</i> instance to build the JDOM Elements.
      */
!    private              SAXHandler  saxHandler  = null;
  
     /**
      * The path of the being parsed element.
***************
*** 431,441 ****
      */
     public void parse(InputSource source)  throws IOException, SAXException {
        // Allocate the element builder (SAXHandler subclass).
!       this.elementBuilder = this.parserBuilder.getContentHandler();
  
        // Allocate (if not provided) and configure the parent parser.
        this.setParent(this.parserBuilder.getXMLReader(
!                                 this.getParent(), this.elementBuilder));
  
        // And delegate to superclass now that everything has been set-up.
        // Note: super.parse() forces the registration of this filter as
--- 431,441 ----
      */
     public void parse(InputSource source)  throws IOException, SAXException {
        // Allocate the element builder (SAXHandler subclass).
!       this.saxHandler = this.parserBuilder.getContentHandler();
  
        // Allocate (if not provided) and configure the parent parser.
        this.setParent(this.parserBuilder.getXMLReader(
!                                 this.getParent(), this.saxHandler));
  
        // And delegate to superclass now that everything has been set-up.
        // Note: super.parse() forces the registration of this filter as
***************
*** 460,466 ****
        this.activeRules.clear();
  
        // Propagate event.
!       this.elementBuilder.startDocument();
        super.startDocument();
     }
  
--- 460,466 ----
        this.activeRules.clear();
  
        // Propagate event.
!       this.saxHandler.startDocument();
        super.startDocument();
     }
  
***************
*** 473,479 ****
      */
     public void endDocument()            throws SAXException {
        // Propagate event.
!       this.elementBuilder.endDocument();
        super.endDocument();
     }
  
--- 473,479 ----
      */
     public void endDocument()            throws SAXException {
        // Propagate event.
!       this.saxHandler.endDocument();
        super.endDocument();
     }
  
***************
*** 490,496 ****
     public void startPrefixMapping(String prefix, String uri)
                                                          throws SAXException {
        // Propagate event.
!       this.elementBuilder.startPrefixMapping(prefix, uri);
        super.startPrefixMapping(prefix, uri);
     }
  
--- 490,496 ----
     public void startPrefixMapping(String prefix, String uri)
                                                          throws SAXException {
        // Propagate event.
!       this.saxHandler.startPrefixMapping(prefix, uri);
        super.startPrefixMapping(prefix, uri);
     }
  
***************
*** 505,511 ****
      */
     public void endPrefixMapping(String prefix)          throws SAXException {
        // Propagate event.
!       this.elementBuilder.endPrefixMapping(prefix);
        super.endPrefixMapping(prefix);
     }
  
--- 505,511 ----
      */
     public void endPrefixMapping(String prefix)          throws SAXException {
        // Propagate event.
!       this.saxHandler.endPrefixMapping(prefix);
        super.endPrefixMapping(prefix);
     }
  
***************
*** 546,552 ****
  
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.elementBuilder.startElement(nsUri, localName, qName, attrs);
        }
        super.startElement(nsUri, localName, qName, attrs);
     }
--- 546,552 ----
  
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.saxHandler.startElement(nsUri, localName, qName, attrs);
        }
        super.startElement(nsUri, localName, qName, attrs);
     }
***************
*** 571,582 ****
     public void endElement(String nsUri, String localName, String qName)
                                                          throws SAXException {
        // Grab the being-built element.
!       Element elt = this.elementBuilder.getCurrentElement();
  
        // Complete element building before making use of it.
        // (This sets the current element to the parent of elt.)
        if (this.activeRules.size() != 0) {
!          this.elementBuilder.endElement(nsUri, localName, qName);
        }
  
        // Get the matching rules for this element (if any).
--- 571,582 ----
     public void endElement(String nsUri, String localName, String qName)
                                                          throws SAXException {
        // Grab the being-built element.
!       Element elt = this.saxHandler.getCurrentElement();
  
        // Complete element building before making use of it.
        // (This sets the current element to the parent of elt.)
        if (this.activeRules.size() != 0) {
!          this.saxHandler.endElement(nsUri, localName, qName);
        }
  
        // Get the matching rules for this element (if any).
***************
*** 621,627 ****
                                                          throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.elementBuilder.characters(ch, start, length);
        }
        super.characters(ch, start, length);
     }
--- 621,627 ----
                                                          throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.saxHandler.characters(ch, start, length);
        }
        super.characters(ch, start, length);
     }
***************
*** 641,647 ****
                                                          throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.elementBuilder.ignorableWhitespace(ch, start, length);
        }
        super.ignorableWhitespace(ch, start, length);
     }
--- 641,647 ----
                                                          throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.saxHandler.ignorableWhitespace(ch, start, length);
        }
        super.ignorableWhitespace(ch, start, length);
     }
***************
*** 661,667 ****
                                                          throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.elementBuilder.processingInstruction(target, data);
        }
        super.processingInstruction(target, data);
     }
--- 661,667 ----
                                                          throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.saxHandler.processingInstruction(target, data);
        }
        super.processingInstruction(target, data);
     }
***************
*** 678,684 ****
     public void skippedEntity(String name)               throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.elementBuilder.skippedEntity(name);
        }
        super.skippedEntity(name);
     }
--- 678,684 ----
     public void skippedEntity(String name)               throws SAXException {
        // Propagate event.
        if (this.activeRules.size() != 0) {
!          this.saxHandler.skippedEntity(name);
        }
        super.skippedEntity(name);
     }
***************
*** 708,714 ****
        //----------------------------------------------------------------------
  
        protected SAXHandler createContentHandler() {
!          return (new ElementBuilder(new EmptyDocumentFactory(factory)));
        }
  
        //----------------------------------------------------------------------
--- 708,714 ----
        //----------------------------------------------------------------------
  
        protected SAXHandler createContentHandler() {
!          return (new SAXHandler(new EmptyDocumentFactory(getFactory())));
        }
  
        //----------------------------------------------------------------------
***************
*** 748,764 ****
        }
  
        /**
!        * Allocates and configures a new ElementBuilder object.
         *
!        * @return the configured ElementBuilder.
         *
         * @throws SAXException   any SAX exception, possibly wrapping
         *                        another exception.
         */
!       public ElementBuilder getContentHandler()         throws SAXException {
           try {
!             ElementBuilder handler =
!                                 (ElementBuilder)(this.createContentHandler());
              this.configureContentHandler(handler);
  
              return (handler);
--- 748,763 ----
        }
  
        /**
!        * Allocates and configures a new SAXHandler object.
         *
!        * @return the configured SAXHandler.
         *
         * @throws SAXException   any SAX exception, possibly wrapping
         *                        another exception.
         */
!       public SAXHandler getContentHandler()         throws SAXException {
           try {
!             SAXHandler handler = this.createContentHandler();
              this.configureContentHandler(handler);
  
              return (handler);
***************
*** 768,809 ****
           }
        }
     }
- 
-    //-------------------------------------------------------------------------
-    // ElementBuilder nested class
-    //-------------------------------------------------------------------------
- 
-    /**
-     * ElementBuilder extends SAXHandler to support external access
-     * to the being-built element.
-     */
-    private static class ElementBuilder extends SAXHandler {
- 
-       /**
-        * Creates a new ElementBuilder using the specified factory to
-        * to create JDOM objects.
-        *
-        * @param  factory   the factory to use to create JDOM objects
-        *                   or <code>null</code> to use the default
-        *                   JDOM factory.
-        */
-       public ElementBuilder(JDOMFactory factory) {
-          super(factory);
-       }
- 
-       //----------------------------------------------------------------------
-       // Specific implementation
-       //----------------------------------------------------------------------
- 
-       /**
-        * Returns the Element being built.
-        *
-        * @return the Element being built.
-        */
-       public Element getCurrentElement() throws SAXException {
-          return this.currentElement;
-       }
-    }
  
     //-------------------------------------------------------------------------
     // EmptyDocumentFactory nested class
--- 767,772 ----



More information about the jdom-interest mailing list