avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml XercesParser.java
Date Sun, 07 Jul 2002 07:19:01 GMT
donaldp     2002/07/07 00:19:01

  Modified:    xmlbundle/src/java/org/apache/avalon/excalibur/xml
                        XercesParser.java
  Log:
  Minor style updates, Made member variable private.
  
  Updated Parser access as lookup() never returns null.
  
  Revision  Changes    Path
  1.2       +49 -44    jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/XercesParser.java
  
  Index: XercesParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/XercesParser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XercesParser.java	22 Apr 2002 10:06:04 -0000	1.1
  +++ XercesParser.java	7 Jul 2002 07:19:00 -0000	1.2
  @@ -31,86 +31,85 @@
       extends AbstractLogEnabled
       implements Parser, ErrorHandler, SingleThreaded
   {
  -
       /** the SAX Parser */
  -    final SAXParser parser;
  +    private final SAXParser m_parser;
   
       public XercesParser()
           throws SAXException
       {
  -        this.parser = new SAXParser();
  +        m_parser = new SAXParser();
   
  -        this.parser.setFeature( "http://xml.org/sax/features/validation", false );
  -        this.parser.setFeature( "http://xml.org/sax/features/namespaces", true );
  -        this.parser.setFeature( "http://xml.org/sax/features/namespace-prefixes",
  -                                true );
  +        m_parser.setFeature( "http://xml.org/sax/features/validation", false );
  +        m_parser.setFeature( "http://xml.org/sax/features/namespaces", true );
  +        m_parser.setFeature( "http://xml.org/sax/features/namespace-prefixes",
  +                             true );
       }
   
  -    public void parse( InputSource in, ContentHandler consumer )
  +    public void parse( final InputSource in,
  +                       final ContentHandler consumer )
           throws SAXException, IOException
       {
           if( consumer instanceof LexicalHandler )
           {
  -            this.parse( in, consumer, (LexicalHandler)consumer );
  +            parse( in, consumer, (LexicalHandler)consumer );
           }
           else
           {
  -            this.parse( in, consumer, null );
  +            parse( in, consumer, null );
           }
       }
   
       /**
  -     * Parse the <code>InputSource</code> and send
  +     * Parse the {@link InputSource} and send
        * SAX events to the content handler and
        * the lexical handler.
        */
  -    public void parse( InputSource in,
  -                       ContentHandler contentHandler,
  -                       LexicalHandler lexicalHandler )
  +    public void parse( final InputSource in,
  +                       final ContentHandler contentHandler,
  +                       final LexicalHandler lexicalHandler )
           throws SAXException, IOException
       {
           if( null != lexicalHandler )
           {
  -            this.parser.setProperty( "http://xml.org/sax/properties/lexical-handler",
  -                                     lexicalHandler );
  +            m_parser.setProperty( "http://xml.org/sax/properties/lexical-handler",
  +                                  lexicalHandler );
           }
  -        this.parser.setErrorHandler( this );
  -        this.parser.setContentHandler( contentHandler );
  -        this.parser.parse( in );
  +        m_parser.setErrorHandler( this );
  +        m_parser.setContentHandler( contentHandler );
  +        m_parser.parse( in );
       }
   
       /**
  -     * Parses a new Document object from the given InputSource.
  +     * Parses a new Document object from the given {@link InputSource}.
        */
  -    public Document parseDocument( InputSource input )
  +    public Document parseDocument( final InputSource input )
           throws SAXException, IOException
       {
  -        DOMParser parser = null;
  -
           try
           {
  -            parser = new DOMParser();
  -
  +            final DOMParser parser = new DOMParser();
               parser.setFeature( "http://xml.org/sax/features/validation", false );
               parser.setFeature( "http://xml.org/sax/features/namespaces", true );
               parser.setFeature( "http://xml.org/sax/features/namespace-prefixes",
                                  true );
   
               parser.parse( input );
  +
  +            return parser.getDocument();
           }
  -        catch( Exception pce )
  +        catch( final Exception e )
           {
  -            getLogger().error( "Could not build DocumentBuilder", pce );
  +            final String message = "Could not build DocumentBuilder";
  +            getLogger().error( message, e );
               return null;
           }
  -
  -        return parser.getDocument();
       }
   
       /**
  -     * Return a new <code>Document</code>.
  +     * Return a new {@link Document}.
        */
  -    public Document createDocument() throws SAXException
  +    public Document createDocument()
  +        throws SAXException
       {
           return new DocumentImpl();
       }
  @@ -118,33 +117,39 @@
       /**
        * Receive notification of a recoverable error.
        */
  -    public void error( SAXParseException e )
  +    public void error( final SAXParseException spe )
           throws SAXException
       {
  -        throw new SAXException( "Error parsing " + e.getSystemId() + " (line " +
  -                                e.getLineNumber() + " col. " + e.getColumnNumber() +
  -                                "): " + e.getMessage(), e );
  +        final String message =
  +            "Error parsing " + spe.getSystemId() + " (line " +
  +            spe.getLineNumber() + " col. " + spe.getColumnNumber() +
  +            "): " + spe.getMessage();
  +        throw new SAXException( message, spe );
       }
   
       /**
        * Receive notification of a fatal error.
        */
  -    public void fatalError( SAXParseException e )
  +    public void fatalError( final SAXParseException spe )
           throws SAXException
       {
  -        throw new SAXException( "Fatal error parsing " + e.getSystemId() + " (line " +
  -                                e.getLineNumber() + " col. " + e.getColumnNumber() +
  -                                "): " + e.getMessage(), e );
  +        final String message =
  +            "Fatal error parsing " + spe.getSystemId() + " (line " +
  +            spe.getLineNumber() + " col. " + spe.getColumnNumber() +
  +            "): " + spe.getMessage();
  +        throw new SAXException( message, spe );
       }
   
       /**
        * Receive notification of a warning.
        */
  -    public void warning( SAXParseException e )
  +    public void warning( final SAXParseException spe )
           throws SAXException
       {
  -        throw new SAXException( "Warning parsing " + e.getSystemId() + " (line " +
  -                                e.getLineNumber() + " col. " + e.getColumnNumber() +
  -                                "): " + e.getMessage(), e );
  +        final String message =
  +            "Warning parsing " + spe.getSystemId() + " (line " +
  +            spe.getLineNumber() + " col. " + spe.getColumnNumber() +
  +            "): " + spe.getMessage();
  +        throw new SAXException( message, spe );
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message