You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/01/07 04:59:24 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/stree AttrImpl.java CDATASectionImpl.java Child.java CommentImpl.java DocImpl.java ElementImpl.java Parent.java ProcessingInstructionImpl.java SaxEventDispatch.java TextImpl.java

sboag       01/01/06 19:59:24

  Modified:    java/src/org/apache/xalan/stree AttrImpl.java
                        CDATASectionImpl.java Child.java CommentImpl.java
                        DocImpl.java ElementImpl.java Parent.java
                        ProcessingInstructionImpl.java
                        SaxEventDispatch.java TextImpl.java
  Log:
  Do synchronization on the m_chars field in TextImpl, to address
  data read/write race that JProbe Threadalizer reported.  This may
  or may not fix the problem that Joe K's been reporting, with dropped
  text on the IBM JDK with numb37, numbering65, numb69,
  and numbering80.  The Theadalizer reports other race
  conditions, but I believe I have accounted for them all.
  
  The m_chars buffer initial size and growth size has
  been reduced from 64K to 8K.  We should consider
  doing blocks down the line to avoid having to do
  array copies and allocations everytime we want to
  grow the array.  I would consider this too destabilizing
  for the upcoming release.
  
  Also, changed SaxEventDispatch#dispatchSAXEvent to
  #dispatchCharactersEvent, and implemented it at
  the level of child, so that all known direct character events
  from the source tree can be dispatched directly from
  the nodes.  This saves a fair amount in string construction,
  and is also a big savings in not having to copy child text into
  a buffer in order to aggregate it for the string value
  of an element.
  
  Revision  Changes    Path
  1.8       +16 -0     xml-xalan/java/src/org/apache/xalan/stree/AttrImpl.java
  
  Index: AttrImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/AttrImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AttrImpl.java	2000/12/15 09:05:19	1.7
  +++ AttrImpl.java	2001/01/07 03:59:23	1.8
  @@ -64,6 +64,8 @@
   
   import org.w3c.dom.DOMException;
   
  +import org.xml.sax.ContentHandler;
  +
   /**
    * <meta name="usage" content="internal"/>
    * Class to hold information about an attribute node.
  @@ -294,5 +296,19 @@
     {
       // return m_parent.m_first;
       return null;
  +  }
  +  
  +  /**
  +   * Handle a Characters event 
  +   *
  +   *
  +   * @param ch Content handler to handle SAX events
  +   *
  +   * @throws SAXException if the content handler characters event throws a SAXException.
  +   */
  +  public void dispatchCharactersEvent(ContentHandler ch) 
  +    throws org.xml.sax.SAXException
  +  {
  +    ch.characters(m_value.toCharArray(), 0, m_value.length());
     }
   }
  
  
  
  1.9       +0 -23     xml-xalan/java/src/org/apache/xalan/stree/CDATASectionImpl.java
  
  Index: CDATASectionImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/CDATASectionImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CDATASectionImpl.java	2001/01/02 03:36:43	1.8
  +++ CDATASectionImpl.java	2001/01/07 03:59:23	1.9
  @@ -61,7 +61,6 @@
   
   import org.xml.sax.ContentHandler;
   import javax.xml.transform.TransformerException;
  -import org.xml.sax.ext.LexicalHandler;
   
   import org.apache.xml.utils.FastStringBuffer;
   
  @@ -132,26 +131,4 @@
       return "#cdata-section";
     }
   
  -  /**
  -   * Handle a CDATASection SAX event
  -   *
  -   *
  -   * @param ch Content Handler
  -   *
  -   * @throws org.xml.sax.SAXException
  -   */
  -  public void dispatchSaxEvent(ContentHandler ch) throws org.xml.sax.SAXException
  -  {
  -
  -    LexicalHandler lh = ((LexicalHandler) ch);
  -
  -    lh.startCDATA();
  -
  -    if (-1 == m_start)
  -      ch.characters(m_data.toCharArray(), 0, m_data.length());
  -    else
  -      ch.characters(m_doc.m_chars.m_map, m_start, m_length);
  -
  -    lh.endCDATA();
  -  }
   }
  
  
  
  1.16      +22 -4     xml-xalan/java/src/org/apache/xalan/stree/Child.java
  
  Index: Child.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Child.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Child.java	2001/01/04 08:06:22	1.15
  +++ Child.java	2001/01/07 03:59:23	1.16
  @@ -64,15 +64,15 @@
   import org.w3c.dom.DOMException;
   import org.w3c.dom.NamedNodeMap;
   
  -// Yuck.  Have to do it right not, for synch issues.  
  -// There will be a better way...
  +import org.xml.sax.ContentHandler;
  +
   import org.apache.xalan.transformer.TransformerImpl;
   
   /**
    * <meta name="usage" content="internal"/>
    * Class representing a child node
    */
  -public class Child extends UnImplNode implements DOMOrder
  +public class Child extends UnImplNode implements DOMOrder, SaxEventDispatch
   {
   
     /** Document Object          */
  @@ -366,7 +366,11 @@
      */
     public boolean isSupported(String feature, String version)
     {
  -    return false;
  +    if (feature == SaxEventDispatch.SUPPORTSINTERFACE ||
  +        feature == org.apache.xpath.patterns.NodeTest.SUPPORTS_PRE_STRIPPING)
  +      return true;
  +    else
  +      return false;
     }
   
     /**
  @@ -445,4 +449,18 @@
     {
       return false;
     }
  +  
  +  /**
  +   * Handle a Characters event 
  +   *
  +   *
  +   * @param ch Content handler to handle SAX events
  +   *
  +   * @throws SAXException if the content handler characters event throws a SAXException.
  +   */
  +  public void dispatchCharactersEvent(ContentHandler ch) 
  +    throws org.xml.sax.SAXException
  +  {
  +  }
  +
   }
  
  
  
  1.9       +0 -16     xml-xalan/java/src/org/apache/xalan/stree/CommentImpl.java
  
  Index: CommentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/CommentImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CommentImpl.java	2001/01/02 03:36:43	1.8
  +++ CommentImpl.java	2001/01/07 03:59:23	1.9
  @@ -133,20 +133,4 @@
       return "#comment";
     }
   
  -  /**
  -   * Handle a Comment Sax Event 
  -   *
  -   *
  -   * @param ch Character array with comment data
  -   *
  -   * @throws org.xml.sax.SAXException
  -   */
  -  public void dispatchSaxEvent(ContentHandler ch) throws org.xml.sax.SAXException
  -  {
  -
  -    if (-1 == m_start)
  -      ((LexicalHandler) ch).comment(m_data.toCharArray(), 0, m_data.length());
  -    else
  -      ((LexicalHandler) ch).comment(m_doc.m_chars.m_map, m_start, m_length);
  -  }
   }
  
  
  
  1.2       +1 -1      xml-xalan/java/src/org/apache/xalan/stree/DocImpl.java
  
  Index: DocImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DocImpl.java	2000/12/15 03:59:06	1.1
  +++ DocImpl.java	2001/01/07 03:59:23	1.2
  @@ -77,7 +77,7 @@
     /** This holds all the characters used, copied from the 
      * characters events.  This allows us to not have to allocate 
      * a million little arrays.  */
  -  FastStringBuffer m_chars = new FastStringBuffer(1024 * 64);
  +  FastStringBuffer m_chars = new FastStringBuffer(1024 * 8);
     
     /** Contains exception thrown from transformation thread, 
      * if one occured. */
  
  
  
  1.24      +3 -0      xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java
  
  Index: ElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ElementImpl.java	2001/01/04 08:06:22	1.23
  +++ ElementImpl.java	2001/01/07 03:59:23	1.24
  @@ -66,6 +66,8 @@
   import org.w3c.dom.Attr;
   import org.w3c.dom.DOMException;
   
  +import org.xml.sax.ContentHandler;
  +
   /**
    * <meta name="usage" content="internal"/>
    * This class represents an element in an HTML or XML document.
  @@ -948,4 +950,5 @@
   
       return removeItem(index);
     }
  +  
   }
  
  
  
  1.18      +25 -0     xml-xalan/java/src/org/apache/xalan/stree/Parent.java
  
  Index: Parent.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Parent.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Parent.java	2001/01/02 03:36:43	1.17
  +++ Parent.java	2001/01/07 03:59:23	1.18
  @@ -66,6 +66,8 @@
   
   import javax.xml.transform.TransformerException;
   
  +import org.xml.sax.ContentHandler;
  +
   /**
    * <meta name="usage" content="internal"/>
    * Class representing a parent node. A parent is also a child unless
  @@ -435,4 +437,27 @@
   
       super.throwParseError(e);
     }
  +  
  +  /**
  +   * Handle a Characters event 
  +   *
  +   *
  +   * @param ch Content handler to handle SAX events
  +   *
  +   * @throws SAXException if the content handler characters event throws a SAXException.
  +   */
  +  public void dispatchCharactersEvent(ContentHandler ch) 
  +    throws org.xml.sax.SAXException
  +  {
  +
  +    for (Node child = getFirstChild(); child != null;
  +                   child = child.getNextSibling())
  +    {
  +      int t = child.getNodeType();
  +      if(Node.COMMENT_NODE != t && Node.PROCESSING_INSTRUCTION_NODE != t)
  +        ((SaxEventDispatch)child).dispatchCharactersEvent(ch);
  +    }
  +
  +  }
  +
   }
  
  
  
  1.7       +17 -0     xml-xalan/java/src/org/apache/xalan/stree/ProcessingInstructionImpl.java
  
  Index: ProcessingInstructionImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ProcessingInstructionImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProcessingInstructionImpl.java	2001/01/02 03:36:43	1.6
  +++ ProcessingInstructionImpl.java	2001/01/07 03:59:23	1.7
  @@ -59,6 +59,8 @@
   import org.w3c.dom.Node;
   import org.w3c.dom.ProcessingInstruction;
   
  +import org.xml.sax.ContentHandler;
  +
   /**
    * <meta name="usage" content="internal"/>
    * Class to hold information about ProcessingInstruction node
  @@ -167,4 +169,19 @@
     {
       return m_data;
     }
  +  
  +  /**
  +   * Handle a Characters event 
  +   *
  +   *
  +   * @param ch Content handler to handle SAX events
  +   *
  +   * @throws SAXException if the content handler characters event throws a SAXException.
  +   */
  +  public void dispatchCharactersEvent(ContentHandler ch) 
  +    throws org.xml.sax.SAXException
  +  {
  +    ch.characters(m_data.toCharArray(), 0, m_data.length());
  +  }
  +
   }
  
  
  
  1.4       +1 -1      xml-xalan/java/src/org/apache/xalan/stree/SaxEventDispatch.java
  
  Index: SaxEventDispatch.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SaxEventDispatch.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SaxEventDispatch.java	2001/01/02 03:36:43	1.3
  +++ SaxEventDispatch.java	2001/01/07 03:59:23	1.4
  @@ -87,6 +87,6 @@
      *
      * @throws org.xml.sax.SAXException
      */
  -  public void dispatchSaxEvent(ContentHandler ch) 
  +  public void dispatchCharactersEvent(ContentHandler ch) 
           throws org.xml.sax.SAXException;
   }
  
  
  
  1.12      +31 -35    xml-xalan/java/src/org/apache/xalan/stree/TextImpl.java
  
  Index: TextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/TextImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TextImpl.java	2001/01/04 08:06:22	1.11
  +++ TextImpl.java	2001/01/07 03:59:23	1.12
  @@ -68,7 +68,7 @@
    * <meta name="usage" content="internal"/>
    * Class to hold information about a Text node.
    */
  -public class TextImpl extends Child implements Text, SaxEventDispatch
  +public class TextImpl extends Child implements Text
   {
   
     /** Text from this Text node          */
  @@ -128,10 +128,12 @@
       // m_data = new String(ch, start, start+length);
       FastStringBuffer fsb = doc.m_chars;
   
  -    m_start = fsb.m_firstFree;
  -    m_length = length;
  -
  -    fsb.append(ch, start, length);
  +    synchronized(fsb)
  +    {
  +      m_start = fsb.m_firstFree;
  +      m_length = length;
  +      fsb.append(ch, start, length);
  +    }
     }
   
     /**
  @@ -142,14 +144,19 @@
      *
      * @throws SAXException if the content handler characters event throws a SAXException.
      */
  -  public void dispatchSaxEvent(ContentHandler ch) 
  +  public void dispatchCharactersEvent(ContentHandler ch) 
       throws org.xml.sax.SAXException
     {
   
       if (-1 == m_start)
         ch.characters(m_data.toCharArray(), 0, m_data.length());
       else
  -      ch.characters(m_doc.m_chars.m_map, m_start, m_length);
  +    {
  +      synchronized(m_doc.m_chars)
  +      {   
  +        ch.characters(m_doc.m_chars.m_map, m_start, m_length);
  +      }
  +    }
     }
   
     /**
  @@ -201,7 +208,12 @@
     {
   
       if (null == m_data)
  -      m_data = new String(m_doc.m_chars.m_map, m_start, m_length);
  +    {
  +      synchronized(m_doc.m_chars)
  +      {   
  +        m_data = new String(m_doc.m_chars.m_map, m_start, m_length);
  +      }
  +    }
   
       return m_data;
     }
  @@ -227,34 +239,15 @@
     {
   
       if (null == m_data)
  -      m_data = new String(m_doc.m_chars.m_map, m_start, m_length);
  +    {
  +      synchronized(m_doc.m_chars)
  +      {   
  +        m_data = new String(m_doc.m_chars.m_map, m_start, m_length);
  +      }
  +    }
   
       return m_data;
     }
  -
  -  /**
  -   * Find out if a given feature is supported 
  -   *
  -   *
  -   * @param feature Feature to check
  -   * @param version Version to check
  -   *
  -   * @return true if feature is SaxEventDispatch.SUPPORTSINTERFACE 
  -   */
  -  public boolean isSupported(String feature, String version)
  -  {
  -
  -    if (feature == SaxEventDispatch.SUPPORTSINTERFACE ||
  -        feature == org.apache.xpath.patterns.NodeTest.SUPPORTS_PRE_STRIPPING)
  -      return true;
  -    else
  -      return false;
  -
  -    // else if(feature.equals(SaxEventDispatch.SUPPORTSINTERFACE))
  -    //  return true;
  -    // else
  -    //  return super.isSupported(feature, version);
  -  }
     
     /**
      * Append this text to the text of this node.
  @@ -269,8 +262,11 @@
     {   
       if (null == m_data)
       {
  -      FastStringBuffer fsb = m_doc.m_chars;   
  -      fsb.append(ch, start, length);      
  +      FastStringBuffer fsb = m_doc.m_chars;
  +      synchronized(fsb)
  +      {   
  +        fsb.append(ch, start, length);
  +      }      
       }
       else
         m_data.concat(ch.toString());