bloritsch    01/10/25 13:34:44

  Modified:    src/org/apache/cocoon/xml/dom Tag: cocoon_20_branch
                        DOMBuilder.java
  Log:
  Optimize critical path  And fix indentation
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.1.1.2.6 +204 -203  xml-cocoon2/src/org/apache/cocoon/xml/dom/DOMBuilder.java
  
  Index: DOMBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/xml/dom/DOMBuilder.java,v
  retrieving revision 1.1.1.1.2.5
  retrieving revision 1.1.1.1.2.6
  diff -u -r1.1.1.1.2.5 -r1.1.1.1.2.6
  --- DOMBuilder.java   2001/10/11 08:56:18     1.1.1.1.2.5
  +++ DOMBuilder.java   2001/10/25 20:34:43     1.1.1.1.2.6
  @@ -25,54 +25,54 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.1.1.2.5 $ $Date: 2001/10/11 08:56:18 $
  + * @version CVS $Revision: 1.1.1.1.2.6 $ $Date: 2001/10/25 20:34:43 $
    */
   public class DOMBuilder implements XMLConsumer, Loggable {
       protected Logger log;
       /** The document was not started */
  -    private static final int S_AVAIL=0;
  +    private static final int S_AVAIL = 0;
       /** State between startDTD() and endDTD() */
  -    private static final int S_DTD=1;
  +    private static final int S_DTD = 1;
       /** State between startDocument() and endDocument() */
  -    private static final int S_DOC=2;
  +    private static final int S_DOC = 2;
       /** State between the first startElement() and the last endElement() */
  -    private static final int S_BODY=3;
  +    private static final int S_BODY = 3;
       /** State between the first startElement() and the last endElement() */
  -    private static final int S_CDATA=4;
  +    private static final int S_CDATA = 4;
       /** The state names (used by Location to output better error messages */
  -    private static final String stateName[]={
  +    private static final String stateName[] = {
           "Available", "DTD Processing", "Document", "Body", "CDATA Section"
       };
   
       /** The current state */
  -    private int state=S_AVAIL;
  +    private int state = S_AVAIL;
       /** The locator */
  -    private Locator locator=null;
  +    private Locator locator = null;
       /** The listener */
  -    protected Listener listener=null;
  +    protected Listener listener = null;
       /** The namespaces table */
  -    private NamespacesTable namespaces=null;
  +    private NamespacesTable namespaces = null;
       /** The current document */
  -    private Document document=null;
  +    private Document document = null;
       /** The current node */
  -    private Node current=null;
  +    private Node current = null;
       /** The document name (tag name of the root element) */
  -    private String name=null;
  +    private String name = null;
       /** The vector of namespaces declarations to include in the next element */
  -    private Vector undecl=new Vector();
  +    private Vector undecl = new Vector();
   
       /** The document factory */
  -    protected DOMFactory factory=null;
  +    protected DOMFactory factory = null;
   
       /**
        * Construct a new instance of this TreeGenerator.
        */
       protected DOMBuilder() {
  -        this(null,null);
  +        this( null, null );
       }
   
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  +    public void setLogger( Logger logger ) {
  +        if ( this.log == null ) {
               this.log = logger;
           }
       }
  @@ -80,17 +80,17 @@
       /**
        * Construct a new instance of this TreeGenerator.
        */
  -    public DOMBuilder(DOMFactory factory) {
  -        this(factory,null);
  +    public DOMBuilder( DOMFactory factory ) {
  +        this( factory, null );
       }
   
       /**
        * Construct a new instance of this TreeGenerator.
        */
  -    public DOMBuilder(DOMFactory factory, Listener listener) {
  +    public DOMBuilder( DOMFactory factory, Listener listener ) {
           super();
  -        this.factory=factory;
  -        this.listener=listener;
  +        this.factory = factory;
  +        this.listener = listener;
       }
   
       /**
  @@ -100,11 +100,11 @@
        * which does not happen here.
        */
   
  -    public DOMBuilder(Node parentNode) {
  +    public DOMBuilder( Node parentNode ) {
           // Set the document as the owner of this node
           this.document = parentNode.getOwnerDocument();
           // Create a namespace table
  -        this.namespaces=new NamespacesTable();
  +        this.namespaces = new NamespacesTable();
           // Set the current node
           this.current = parentNode;
           // Go directly to BODY state
  @@ -114,7 +114,7 @@
       /**     * Return the newly built Document.
        */
       public Document getDocument() {
  -        return(this.document);
  +        return ( this.document );
       }
   
       /**
  @@ -122,8 +122,8 @@
        *
        * @param loc The SAX Locator.
        */
  -    public void setDocumentLocator (Locator loc) {
  -        this.locator=loc;
  +    public void setDocumentLocator( Locator loc ) {
  +        this.locator = loc;
       }
   
       /**
  @@ -132,16 +132,16 @@
        * @exception SAXException If this method was not called appropriately.
        */
       public void startDocument()
  -    throws SAXException {
  -        if(state!=S_AVAIL) throw new SAXException("Invalid state"+location());
  +            throws SAXException {
  +        if ( state != S_AVAIL ) throw new SAXException( "Invalid state" + 
location() );
           // Create the namespaces table
  -        this.namespaces=new NamespacesTable();
  +        this.namespaces = new NamespacesTable();
           // Create a new Document empty document object
  -        this.document=this.factory.newDocument();
  +        this.document = this.factory.newDocument();
           // Set the current node
  -        this.current=this.document;
  +        this.current = this.document;
           // Do a state change
  -        state=S_DOC;
  +        state = S_DOC;
       }
   
       /**
  @@ -149,19 +149,19 @@
        *
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void endDocument ()
  -    throws SAXException {
  -        if(state!=S_DOC) throw new SAXException("Invalid state"+location());
  +    public void endDocument()
  +            throws SAXException {
  +        if ( state != S_DOC ) throw new SAXException( "Invalid state" + location() 
);
           // Check if the current element is the document
  -        if(this.document!=this.current)
  -            throw new SAXException("Invalid current node"+location());
  +        if ( this.document != this.current )
  +            throw new SAXException( "Invalid current node" + location() );
           // Reset the current node and the document name
  -        this.current=null;
  -        this.name=null;
  +        this.current = null;
  +        this.name = null;
           // Do a state change and reset the DTD flag
  -        state=S_AVAIL;
  +        state = S_AVAIL;
           // Notify the listener
  -        this.notify(this.document);
  +        this.notify( this.document );
       }
   
       /**
  @@ -174,28 +174,28 @@
        *                 subset, or null if none was declared.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  +    public void startDTD( String name, String publicId, String systemId )
  +            throws SAXException {
           // This method can be called only at DOCUMENT level
  -        if(state!=S_DOC) throw new SAXException("Invalid state"+location());
  +        if ( state != S_DOC ) throw new SAXException( "Invalid state" + location() 
);
           // Check wether this method was already invoked
  -        if(this.name!=null)
  -            throw new SAXException("Duplicate DTD definition"+location());
  +        if ( this.name != null )
  +            throw new SAXException( "Duplicate DTD definition" + location() );
           // Remember the specified document name
  -        this.name=name;
  +        this.name = name;
           // Recreate the document element
  -        Document doc=this.factory.newDocument(name,publicId,systemId);
  +        Document doc = this.factory.newDocument( name, publicId, systemId );
           // Copy the old document root PIs
  -        NodeList list=this.document.getChildNodes();
  -        for (int x=0; x<list.getLength(); x++) {
  -            if (list.item(x).getNodeType()!=Node.DOCUMENT_TYPE_NODE)
  -                doc.appendChild(doc.importNode(list.item(x),true));
  +        NodeList list = this.document.getChildNodes();
  +        for ( int x = 0; x < list.getLength(); x++ ) {
  +            if ( list.item( x ).getNodeType() != Node.DOCUMENT_TYPE_NODE )
  +                doc.appendChild( doc.importNode( list.item( x ), true ) );
           }
           // Declare the new document as the new real document
  -        this.document=doc;
  -        this.current=this.document;
  +        this.document = doc;
  +        this.current = this.document;
           // Do a state change
  -        state=S_DTD;
  +        state = S_DTD;
       }
   
       /**
  @@ -207,11 +207,11 @@
        * @exception SAXException If this method was not called appropriately.
        */
       public void endDTD()
  -    throws SAXException {
  +            throws SAXException {
           // This method can be called only at DTD level
  -        if(state!=S_DTD) throw new SAXException("Invalid state"+location());
  +        if ( state != S_DTD ) throw new SAXException( "Invalid state" + location() 
);
           // Do a state change
  -        state=S_DOC;
  +        state = S_DOC;
       }
   
       /**
  @@ -229,21 +229,21 @@
        *              attributes, it shall be an empty Attributes object.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void startElement(String uri, String loc, String raw, Attributes a)
  -    throws SAXException {
  -        NamespacesTable.Name n=this.namespaces.resolve(uri,raw,null,loc);
  +    public void startElement( String uri, String loc, String raw, Attributes a )
  +            throws SAXException {
  +        NamespacesTable.Name n = this.namespaces.resolve( uri, raw, null, loc );
           // Check if this is we are defining the document root element
  -        if(state==S_DOC) {
  +        if ( state == S_DOC ) {
               // Check if the DTD was specified
  -            if (this.name!=null) {
  +            if ( this.name != null ) {
                   // Check that this root element is equal to the one specified
                   // in the DTD
  -                if (!this.name.equals(n.getQName()))
  -                    throw new SAXException("The name specified in the DTD '"+
  -                                          this.name+"' differs from the root "+
  -                                          "element name '"+n.getQName()+
  -                                          "'"+location());
  -            // Recreate the document since no DTD was specified
  +                if ( !this.name.equals( n.getQName() ) )
  +                    throw new SAXException( "The name specified in the DTD '" +
  +                                            this.name + "' differs from the root " +
  +                                            "element name '" + n.getQName() +
  +                                            "'" + location() );
  +                // Recreate the document since no DTD was specified
               } else {
                   /* DISABLED pending us tracking down what's causing document
                    * hierachy errors when we do this. This may well break people's
  @@ -260,43 +260,43 @@
                   // Declare the new document as the new real document
                   this.document=doc;
                   */
  -                this.current=this.document;
  +                this.current = this.document;
               }
               // Change the state before continuing
  -            state=S_BODY;
  +            state = S_BODY;
           }
           // Now that we initialized the root element we can perform the standard
           // element check
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +        if ( state != S_BODY ) throw new SAXException( "Invalid state" + location() 
);
           // Create the Element node
  -        Element e=this.document.createElementNS(("".equals(n.getUri()) ? null : 
n.getUri()),n.getQName());
  +        Element e = this.document.createElementNS( ( "".equals( n.getUri() ) ? null 
: n.getUri() ), n.getQName() );
           // Process all attributes, leave out namespace attributes
  -        for(int x=0;x<a.getLength();x++) {
  -            String auri=a.getURI(x);
  -            String aloc=a.getLocalName(x);
  -            String araw=a.getQName(x);
  -            String aval=a.getValue(x);
  -            if (araw.startsWith("xmlns:")==false && araw.equals("xmlns")==false) {
  -                NamespacesTable.Name k=this.namespaces.resolve(auri,araw,null,aloc);
  +        for ( int x = 0; x < a.getLength(); x++ ) {
  +            String auri = a.getURI( x );
  +            String aloc = a.getLocalName( x );
  +            String araw = a.getQName( x );
  +            String aval = a.getValue( x );
  +            if ( araw.startsWith( "xmlns:" ) == false && araw.equals( "xmlns" ) == 
false ) {
  +                NamespacesTable.Name k = this.namespaces.resolve( auri, araw, null, 
aloc );
                   // Set the attribute into the element
  -                auri=k.getPrefix().length()==0 ? null : k.getUri();
  -                e.setAttributeNS(auri,k.getQName(),aval);
  +                auri = k.getPrefix().length() == 0 ? null : k.getUri();
  +                e.setAttributeNS( auri, k.getQName(), aval );
               }
           }
           // Append the xmlns... attributes
  -        if (this.undecl.size()>0) {
  -            for (int x=0; x<this.undecl.size(); x++) {
  -                NamespacesTable.Declaration dec=null;
  -                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
  -                String aname="xmlns";
  -                if (dec.getPrefix().length()>0) aname="xmlns:"+dec.getPrefix();
  -                e.setAttributeNS("http://www.w3.org/2000/xmlns/";, 
aname,dec.getUri());
  +        if ( this.undecl.size() > 0 ) {
  +            for ( int x = 0; x < this.undecl.size(); x++ ) {
  +                NamespacesTable.Declaration dec = null;
  +                dec = (NamespacesTable.Declaration) this.undecl.elementAt( x );
  +                String aname = "xmlns";
  +                if ( dec.getPrefix().length() > 0 ) aname = "xmlns:" + 
dec.getPrefix();
  +                e.setAttributeNS( "http://www.w3.org/2000/xmlns/";, aname, 
dec.getUri() );
               }
               this.undecl.clear();
           }
           // Append this element to the parent and declare it current
  -        this.current.appendChild(e);
  -        this.current=e;
  +        this.current.appendChild( e );
  +        this.current = e;
       }
   
       /**
  @@ -312,26 +312,26 @@
        *                string if raw names are not available.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void endElement (String uri, String loc, String raw)
  -    throws SAXException {
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +    public void endElement( String uri, String loc, String raw )
  +            throws SAXException {
  +        if ( state != S_BODY ) throw new SAXException( "Invalid state" + location() 
);
   
           // Check if the current node is an element
  -        if (this.current.getNodeType()!=Node.ELEMENT_NODE)
  -            throw new SAXException("Current node is not an element"+location());
  +        if ( this.current.getNodeType() != Node.ELEMENT_NODE )
  +            throw new SAXException( "Current node is not an element" + location() );
   
           // Check if the current element has the same tag name of this event
  -        NamespacesTable.Name n=this.namespaces.resolve(uri,raw,null,loc);
  -        String oldname=((Element)this.current).getTagName();
  -        if (!oldname.equals(n.getQName()))
  -            throw new SAXException("Element end tag name '"+n.getQName()+
  -                                   "' differs from start tag name '"+
  -                                   oldname+"'"+location());
  +        NamespacesTable.Name n = this.namespaces.resolve( uri, raw, null, loc );
  +        String oldname = ( (Element) this.current ).getTagName();
  +        if ( !oldname.equals( n.getQName() ) )
  +            throw new SAXException( "Element end tag name '" + n.getQName() +
  +                                    "' differs from start tag name '" +
  +                                    oldname + "'" + location() );
           // Restore the old node as current
  -        this.current=this.current.getParentNode();
  -        if (this.current==null) throw new SAXException("No parent"+location());
  +        this.current = this.current.getParentNode();
  +        if ( this.current == null ) throw new SAXException( "No parent" + 
location() );
           // Update the state if the current node is the document
  -        if (this.current==this.document) state=S_DOC;
  +        if ( this.current == this.document ) state = S_DOC;
       }
   
       /**
  @@ -341,13 +341,13 @@
        * @param uri The Namespace URI the prefix is mapped to.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  +    public void startPrefixMapping( String prefix, String uri )
  +            throws SAXException {
           // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  +        if ( ( state < S_DOC ) || ( state > S_BODY ) )
  +            throw new SAXException( "Invalid state" + location() );
           // Insert this namespace in tables avoiding duplicates
  -        this.undecl.addElement(this.namespaces.addDeclaration(prefix,uri));
  +        this.undecl.addElement( this.namespaces.addDeclaration( prefix, uri ) );
       }
   
       /**
  @@ -355,15 +355,15 @@
        *
        * @param prefix The Namespace prefix that was being mapped.
        */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  +    public void endPrefixMapping( String prefix )
  +            throws SAXException {
           // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  +        if ( ( state < S_DOC ) || ( state > S_BODY ) )
  +            throw new SAXException( "Invalid state" + location() );
           // Check if the namespace we're asked to remove was declared
  -        if (this.namespaces.removeDeclaration(prefix)==null)
  -            throw new SAXException("Prefix \""+prefix+"\" never declared"+
  -                                   location());
  +        if ( this.namespaces.removeDeclaration( prefix ) == null )
  +            throw new SAXException( "Prefix \"" + prefix + "\" never declared" +
  +                                    location() );
       }
   
       /**
  @@ -372,15 +372,15 @@
        * @exception SAXException If this method was not called appropriately.
        */
       public void startCDATA()
  -    throws SAXException {
  +            throws SAXException {
           // This method can only called at BODY level
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  -        CDATASection cdata=this.document.createCDATASection("");
  +        if ( state != S_BODY ) throw new SAXException( "Invalid state" + location() 
);
  +        CDATASection cdata = this.document.createCDATASection( "" );
           // Set the CDATASection as the current element
  -        this.current.appendChild(cdata);
  -        this.current=cdata;
  +        this.current.appendChild( cdata );
  +        this.current = cdata;
           // Do a state change
  -        state=S_CDATA;
  +        state = S_CDATA;
       }
   
       /**
  @@ -389,16 +389,16 @@
        * @exception SAXException If this method was not called appropriately.
        */
       public void endCDATA()
  -    throws SAXException {
  +            throws SAXException {
           // This method can only called at BODY level
  -        if(state!=S_CDATA) throw new SAXException("Invalid state"+location());
  +        if ( state != S_CDATA ) throw new SAXException( "Invalid state" + 
location() );
           // Set the parent of the CDATASection as the current element
           // We don't need to check the node type because in CDATA state the
           // current element can be ONLY a CDATASection node
  -        this.current=this.current.getParentNode();
  -        if (this.current==null) throw new SAXException("No parent"+location());
  +        this.current = this.current.getParentNode();
  +        if ( this.current == null ) throw new SAXException( "No parent" + 
location() );
           // Do a state change, and revert to the BODY state
  -        state=S_BODY;
  +        state = S_BODY;
       }
   
       /**
  @@ -409,15 +409,15 @@
        * @param len The number of characters to read from the array.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void startEntity(java.lang.String name)
  -    throws SAXException {
  +    public void startEntity( java.lang.String name )
  +            throws SAXException {
           // This method can only called at BODY level
  -        if((state!=S_BODY)&&(state!=S_DTD))
  -            throw new SAXException("Invalid state"+location());
  +        if ( ( state != S_BODY ) && ( state != S_DTD ) )
  +            throw new SAXException( "Invalid state" + location() );
           // Update the current element with the entity reference node
  -        EntityReference eref=this.document.createEntityReference(name);
  -        this.current.appendChild(eref);
  -        this.current=eref;
  +        EntityReference eref = this.document.createEntityReference( name );
  +        this.current.appendChild( eref );
  +        this.current = eref;
       }
   
       /**
  @@ -428,24 +428,24 @@
        * @param len The number of characters to read from the array.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void endEntity(java.lang.String name)
  -    throws SAXException {
  +    public void endEntity( java.lang.String name )
  +            throws SAXException {
           // This method can only called at BODY level
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +        if ( state != S_BODY ) throw new SAXException( "Invalid state" + location() 
);
   
           // Check if the current node is an entity reference
  -        if (this.current.getNodeType()!=Node.ENTITY_REFERENCE_NODE)
  -            throw new SAXException("Current node is not an entity reference"+
  -                                   location());
  +        if ( this.current.getNodeType() != Node.ENTITY_REFERENCE_NODE )
  +            throw new SAXException( "Current node is not an entity reference" +
  +                                    location() );
           // Check if the current element has the same tag name of this event
  -        String oldname=((EntityReference)this.current).getNodeName();
  -        if (!oldname.equals(name))
  -            throw new SAXException("Entity reference closing name '"+name+"' "+
  -                                   "differs from start name '"+oldname+"'"+
  -                                   location());
  +        String oldname = ( (EntityReference) this.current ).getNodeName();
  +        if ( !oldname.equals( name ) )
  +            throw new SAXException( "Entity reference closing name '" + name + "' " 
+
  +                                    "differs from start name '" + oldname + "'" +
  +                                    location() );
           // Restore the old node as current
  -        this.current=this.current.getParentNode();
  -        if (this.current==null) throw new SAXException("No parent"+location());
  +        this.current = this.current.getParentNode();
  +        if ( this.current == null ) throw new SAXException( "No parent" + 
location() );
       }
   
       /**
  @@ -456,17 +456,17 @@
        * @param len The number of characters to read from the array.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void characters (char chars[], int start, int len)
  -    throws SAXException {
  +    public void characters( char chars[], int start, int len )
  +            throws SAXException {
           // This method can only called at BODY or CDATA levels
  -        if(state<S_BODY) throw new SAXException("Invalid state "+location());
  +        if ( state < S_BODY ) throw new SAXException( "Invalid state " + location() 
);
           // Check if we are in the CDATA state
  -        String data=new String(chars,start,len);
  -        if(state==S_CDATA) {
  -            ((CDATASection)this.current).appendData(data);
  +        String data = new String( chars, start, len );
  +        if ( state == S_CDATA ) {
  +            ( (CDATASection) this.current ).appendData( data );
           } else {
  -            Text text=this.document.createTextNode(data);
  -            this.current.appendChild(text);
  +            Text text = this.document.createTextNode( data );
  +            this.current.appendChild( text );
           }
       }
   
  @@ -478,20 +478,20 @@
        * @param len The number of characters to read from the array.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void ignorableWhitespace (char chars[], int start, int len)
  -    throws SAXException {
  +    public void ignorableWhitespace( char chars[], int start, int len )
  +            throws SAXException {
           // This is because some parsers may report ignorable whitespace outside
           // the scope of the root element
  -        if(state==S_DOC) return;
  +        if ( state == S_DOC ) return;
           // This method can only called at BODY or CDATA levels
  -        if(state<S_BODY) throw new SAXException("Invalid state"+location());
  +        if ( state < S_BODY ) throw new SAXException( "Invalid state" + location() 
);
           // Check if we are in the CDATA state
  -        if(state==S_CDATA)
  -            throw new SAXException("CDATA sections cannot contain ignorable "+
  -                                   "whitespace"+location());
  +        if ( state == S_CDATA )
  +            throw new SAXException( "CDATA sections cannot contain ignorable " +
  +                                    "whitespace" + location() );
           // Create and append a text node
  -        Text text=this.document.createTextNode(new String(chars,start,len));
  -        this.current.appendChild(text);
  +        Text text = this.document.createTextNode( new String( chars, start, len ) );
  +        this.current.appendChild( text );
       }
   
       /**
  @@ -501,17 +501,17 @@
        * @param data The processing instruction data.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void processingInstruction (String target, String data)
  -    throws SAXException {
  +    public void processingInstruction( String target, String data )
  +            throws SAXException {
           // This is because Xerces reports processing instructions inside DTDs
  -        if(state==S_DTD) return;
  +        if ( state == S_DTD ) return;
           // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  +        if ( ( state < S_DOC ) || ( state > S_BODY ) )
  +            throw new SAXException( "Invalid state" + location() );
           // Create and append a processing instruction node
           ProcessingInstruction pi;
  -        pi=this.document.createProcessingInstruction(target,data);
  -        this.current.appendChild(pi);
  +        pi = this.document.createProcessingInstruction( target, data );
  +        this.current.appendChild( pi );
       }
   
       /**
  @@ -522,16 +522,16 @@
        * @param len The number of characters to read from the array.
        * @exception SAXException If this method was not called appropriately.
        */
  -    public void comment(char chars[], int start, int len)
  -    throws SAXException {
  +    public void comment( char chars[], int start, int len )
  +            throws SAXException {
           // This is because Xerces reports comments inside DTDs
  -        if(state==S_DTD) return;
  +        if ( state == S_DTD ) return;
           // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  +        if ( ( state < S_DOC ) || ( state > S_BODY ) )
  +            throw new SAXException( "Invalid state" + location() );
           // Create and append a comment node
  -        Comment com=this.document.createComment(new String(chars,start,len));
  -        this.current.appendChild(com);
  +        Comment com = this.document.createComment( new String( chars, start, len ) 
);
  +        this.current.appendChild( com );
       }
   
       /**
  @@ -540,36 +540,37 @@
        * @param name The name of the skipped entity. If it is a parameter entity,
        *             the name will begin with '%'.
        */
  -    public void skippedEntity(java.lang.String name)
  -    throws SAXException {
  +    public void skippedEntity( java.lang.String name )
  +            throws SAXException {
           // This method can only called at BODY level
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +        if ( state != S_BODY ) throw new SAXException( "Invalid state" + location() 
);
           // Create and append a comment node
  -        EntityReference eref=this.document.createEntityReference(name);
  -        this.current.appendChild(eref);
  +        EntityReference eref = this.document.createEntityReference( name );
  +        this.current.appendChild( eref );
       }
   
       /**
        * Receive notification of a successfully completed DOM tree generation.
        */
  -    protected void notify(Document doc)
  -    throws SAXException {
  -        if (this.listener!=null) this.listener.notify(this.document);
  +    protected void notify( Document doc )
  +            throws SAXException {
  +        if ( this.listener != null ) this.listener.notify( this.document );
       }
   
       /** Create a location string */
       private String location() {
  -        if (this.locator==null) return("");
  -        String pub=this.locator.getPublicId();
  -        String sys=this.locator.getSystemId();
  -        pub=((pub==null) ? "" : ("Public ID=\""+pub+"\" "));
  -        sys=((sys==null) ? "" : ("System ID=\""+sys+"\" "));
  -        int l=this.locator.getLineNumber();
  -        int c=this.locator.getColumnNumber();
  -        String lin=((l<0) ? "" : ("line="+l+""));
  -        String col=((c<0) ? "" : (" col="+c+""));
  -        return new String(" ("+sys+pub+lin+col+" State: "+
  -                          stateName[this.state]+")");
  +        if ( this.locator == null ) return ( "" );
  +        String pub = this.locator.getPublicId();
  +        String sys = this.locator.getSystemId();
  +        pub = ( ( pub == null ) ? "" : new StringBuffer( "Public ID=\"" ).append( 
pub ).append( "\" " ).toString() );
  +        sys = ( ( sys == null ) ? "" : new StringBuffer( "System ID=\"" ).append( 
sys ).append( "\" " ).toString() );
  +        int l = this.locator.getLineNumber();
  +        int c = this.locator.getColumnNumber();
  +        String lin = ( ( l < 0 ) ? "" : new StringBuffer( "line=" ).append( l 
).append( "" ).toString() );
  +        String col = ( ( c < 0 ) ? "" : new StringBuffer( " col=" ).append( c 
).append( "" ).toString() );
  +        return new StringBuffer( " (" ).append( sys ).append( pub )
  +                .append( lin ).append( col ).append( " State: " )
  +                .append( stateName[this.state] + ")" ).toString();
       }
   
       /**
  @@ -581,7 +582,7 @@
           /**
            * Receive notification of a successfully completed DOM tree generation.
            */
  -        void notify(Document doc)
  -        throws SAXException;
  +        void notify( Document doc )
  +                throws SAXException;
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to