sboag       00/10/06 00:52:24

  Modified:    java/src/org/apache/xalan/stree Child.java DocumentImpl.java
                        ElementImpl.java Parent.java
  Log:
  Synch with TransformerImpl, instead of individual nodes, so we can be 
notified with a parse fails;  Throw wrapped exception if we sense that a parse 
error has occured.
  
  Revision  Changes    Path
  1.6       +44 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Child.java        2000/08/11 02:57:18     1.5
  +++ Child.java        2000/10/06 07:52:23     1.6
  @@ -32,6 +32,40 @@
       return true;
     }
     
  +  protected Object getSynchObject()
  +  {
  +    DocumentImpl di = this.getDocumentImpl();
  +    if(null != di)
  +    {
  +      SourceTreeHandler sth = di.getSourceTreeHandler();
  +      if(null != sth)
  +      {
  +        sth = di.getSourceTreeHandler();
  +        org.apache.xalan.transformer.TransformerImpl ti 
  +          = sth.getTransformer();
  +        if(null != ti)
  +        {
  +          Exception e = ti.getExceptionThrown();
  +          if(null != e)
  +          {
  +            throw new org.apache.xalan.utils.WrappedRuntimeException(e);
  +          }
  +        }
  +      }
  +    }
  +    return this;
  +  }
  +  
  +  protected void throwIfParseError()
  +  {
  +    // That's OK, it's as good a time as any to check again
  +    Exception pe 
  +      = 
this.getDocumentImpl().getSourceTreeHandler().getTransformer().getExceptionThrown();
  +    if(null != pe)
  +      throw new org.apache.xalan.utils.WrappedRuntimeException(pe);
  +  }
  +
  +  
     /**
      * The position in the parent's list.
      */
  @@ -120,9 +154,11 @@
      */
     DocumentImpl getDocumentImpl()
     {
    Child n = this;
    while(n.getUid() > 1)
  +    {
         n = (Child)n.getParentNode();
  -    // if((n == null) || !(n instanceof DocumentImpl))
  -    //    return null;
  +      if(n == null)
  +        return null;
  +    }
       return (DocumentImpl)n;
     }
   
  @@ -165,7 +201,9 @@
         try{
        return m_parent.getChild(getChildPosition()-1);
         }
         catch(Exception e)
  -      {}
  +      {
  +        throw new org.apache.xalan.utils.WrappedRuntimeException(e);
  +      }
       }  
       return null;
     }
  
  @@ -182,7 +220,9 @@
           return m_parent.getChild(getChildPosition()+1);
         }
         catch(Exception e)
  -      {}
  +      {
  +        throw new org.apache.xalan.utils.WrappedRuntimeException(e);
  +      }
       }  
       return null;
     }
  
  
  
  1.6       +4 -4      
xml-xalan/java/src/org/apache/xalan/stree/DocumentImpl.java
  
  Index: DocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocumentImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DocumentImpl.java 2000/09/13 20:59:39     1.5
  +++ DocumentImpl.java 2000/10/06 07:52:23     1.6
  @@ -267,18 +267,18 @@
       // Make sure we're done parsing.
       if (elem == null && !isComplete())
       {    
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
           try
           {
             // Don't really know why we should need the while loop,
             // but we seem to come out of wait() too soon! 
             while (!isComplete())
  -            wait();
  +            getSynchObject().wait();
           }
           catch (InterruptedException e)
  -        {          
  -          // That's OK, it's as good a time as any to check again
  +        {   
  +          throwIfParseError();
           }        
         }
         elem = (Element)m_idAttributes.get(elementId); 
  
  
  
  1.13      +6 -6      
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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElementImpl.java  2000/09/29 15:49:57     1.12
  +++ ElementImpl.java  2000/10/06 07:52:23     1.13
  @@ -105,16 +105,16 @@
     {
       if (!isComplete())
       {
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
           try
           {
             //System.out.println("Waiting... getelCount " );
  -          wait();
  +          getSynchObject().wait();
           }
           catch (InterruptedException e)
           {
  -          // That's OK, it's as good a time as any to check again
  +          throwIfParseError();
           }
           //System.out.println("/// gotelcount " );
           
  @@ -280,16 +280,16 @@
       {
         // Force it to wait until at least an element child 
         // has been added or end element.
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
           try
           {
             //System.out.println("Waiting... getelCount " );
  -          wait();
  +          getSynchObject().wait();
           }
           catch (InterruptedException e)
           {
  -          // That's OK, it's as good a time as any to check again
  +          throwIfParseError();
           }
           //System.out.println("/// gotelcount " );
           
  
  
  
  1.8       +49 -18    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Parent.java       2000/10/02 20:49:26     1.7
  +++ Parent.java       2000/10/06 07:52:23     1.8
  @@ -33,16 +33,16 @@
     {    
       if (!isComplete())
       {
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
           try
           {
             //System.out.println("Waiting... getCount "+ this.getNodeName() );
  -          wait();
  +          getSynchObject().wait();
           }
           catch (InterruptedException e)
           {
  -          // That's OK, it's as good a time as any to check again
  +          throwIfParseError();
           }
           //System.out.println("... getcount " );
           
  @@ -61,16 +61,20 @@
     public boolean      hasChildNodes()
  {
       if (null == m_children && !isComplete())
       {
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
           try
           {
             //System.out.println("Waiting... getCount " + this.getNodeName() );
  -          wait();
  +          getSynchObject().wait();
           }
           catch (InterruptedException e)
           {
             // That's OK, it's as good a time as any to check again
  +          Exception pe 
  +            = 
this.getDocumentImpl().getSourceTreeHandler().getTransformer().getExceptionThrown();
  +          if(null != pe)
  +            throw new org.apache.xalan.utils.WrappedRuntimeException(pe);
           }
           //System.out.println("... getcount " );        
         }
  @@ -104,17 +108,17 @@
              m_children[i] : null;
       if (child == null && !isComplete())
       {
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
           try
           {
             // System.out.println("Waiting... getChild " + i + " " + 
getNodeName());
             
  -          wait();
  +          getSynchObject().wait();
           }
           catch (InterruptedException e)
           {
  -          // That's OK, it's as good a time as any to check again
  +          throwIfParseError();
           }
           // System.out.println("... gotChild " + i);
           child = ((null != m_children) && (i >= 0) && i < m_children.length) ?
  @@ -146,7 +150,7 @@
       }
       catch(Exception e)
       {
  -      return null;
  +      throw new org.apache.xalan.utils.WrappedRuntimeException(e);
       }  
     }
     
  @@ -240,9 +244,9 @@
       if (newChild.getNodeType() != Node.ATTRIBUTE_NODE)
       {  
         // Notify anyone waiting for a child...
  -      synchronized (this)
  +      synchronized (getSynchObject())
         {
  -        notifyAll();
  +        getSynchObject().notifyAll();
         }
       }
       
  @@ -261,23 +265,50 @@
      */
     public boolean isComplete()
     {
  +    if(!m_isComplete)
  +    {
  +      DocumentImpl di = this.getDocumentImpl();
  +      if(null != di)
  +      {
  +        SourceTreeHandler sth = di.getSourceTreeHandler();
  +        if(null != sth)
  +        {
  +          sth = di.getSourceTreeHandler();
  +          org.apache.xalan.transformer.TransformerImpl ti 
  +            = sth.getTransformer();
  +          if(null != ti)
  +          {
  +            Exception e = ti.getExceptionThrown();
  +            if(null != e)
  +            {
  +              m_isComplete = true; // to be safe
  +              throw new org.apache.xalan.utils.WrappedRuntimeException(e);
  +            }
  +          }
  +        }
  +      }
  +    }
       return m_isComplete;
     }
  -
  +  
     /**
      * Set that this node's child list is complete, i.e. 
      * an endElement event has occured.
      */
     public void setComplete(boolean isComplete)
     {
  -    m_isComplete = isComplete;
  -    if (isComplete())
  +    if(m_isComplete != isComplete)
       {
  -      // Notify anyone waiting for a child...
  -      synchronized (this)
  +      m_isComplete = isComplete;
  +      if (m_isComplete)
         {
  -        //System.out.println("notify set complete" + this.getNodeName());
  -        notifyAll();
  +        Object synchObj = getSynchObject();
  +        // Notify anyone waiting for a child...
  +        synchronized (synchObj)
  +        {
  +          //System.out.println("notify set complete" + this.getNodeName());
  +          synchObj.notifyAll();
  +        }
         }
       }
     }
  
  
  

Reply via email to