xml-xmlbeans-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daver...@apache.org
Subject cvs commit: xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store CursorData.java Cursor.java Root.java Saver.java
Date Tue, 30 Mar 2004 03:58:11 GMT
daveremy    2004/03/29 19:58:10

  Modified:    v1       Tag: xmlbeans-1-0-1_branch build.xml
               v1/src/typeimpl/org/apache/xmlbeans/impl/schema Tag:
                        xmlbeans-1-0-1_branch SchemaTypeLoaderImpl.java
               v1/src/xmlstore/org/apache/xmlbeans/impl/store Tag:
                        xmlbeans-1-0-1_branch Cursor.java Root.java
                        Saver.java
  Added:       v1/src/xmlstore/org/apache/xmlbeans/impl/store Tag:
                        xmlbeans-1-0-1_branch CursorData.java
  Log:
  merging old fixes from main trunk to xmlbeans-1-0-1_branch
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.10.2.2  +0 -1      xml-xmlbeans/v1/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/build.xml,v
  retrieving revision 1.10.2.1
  retrieving revision 1.10.2.2
  diff -u -r1.10.2.1 -r1.10.2.2
  --- build.xml	23 Jan 2004 23:15:59 -0000	1.10.2.1
  +++ build.xml	30 Mar 2004 03:58:10 -0000	1.10.2.2
  @@ -500,7 +500,6 @@
         <fileset dir="build/classes/xmlstore"/>
         <fileset dir="build/classes/xmlinputstream"/>
         <fileset dir="build/classes/repackage"/>
  -      <fileset dir="src/license"/>
       </jar>
     </target>
   
  
  
  
  No                   revision
  No                   revision
  1.2.2.1   +10 -6     xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
  
  Index: SchemaTypeLoaderImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SchemaTypeLoaderImpl.java	24 Sep 2003 23:31:07 -0000	1.2
  +++ SchemaTypeLoaderImpl.java	30 Mar 2004 03:58:10 -0000	1.2.2.1
  @@ -71,6 +71,7 @@
   import java.io.InputStream;
   import java.util.Map;
   import java.util.HashMap;
  +import java.util.WeakHashMap;
   import java.util.Collections;
   import java.util.ArrayList;
   import java.util.List;
  @@ -98,23 +99,26 @@
           return new SchemaTypeLoaderImpl(new SchemaTypeLoader[] { BuiltinSchemaTypeSystem.get()
} , null, Thread.currentThread().getContextClassLoader());
       }
   
  -    private static ThreadLocal _threadTypeSystem =
  +    private static ThreadLocal _threadTypeSystems =
           new ThreadLocal()
           {
  -            protected Object initialValue() { return buildContextTypeLoader(); }
  +            protected Object initialValue() { return new WeakHashMap(); }
           };
   
       public static SchemaTypeLoaderImpl getContextTypeLoader()
       {
  -        SchemaTypeLoaderImpl candidate = (SchemaTypeLoaderImpl)_threadTypeSystem.get();
  -        if (candidate._classLoader != Thread.currentThread().getContextClassLoader())
  +        WeakHashMap candidates = (WeakHashMap) _threadTypeSystems.get();
  +        ClassLoader threadContextClassLoader = Thread.currentThread().getContextClassLoader();
  +        SchemaTypeLoaderImpl candidate = (SchemaTypeLoaderImpl) candidates.get( threadContextClassLoader
);
  +
  +        if (candidate == null)
           {
               candidate = buildContextTypeLoader();
  -            _threadTypeSystem.set(candidate);
  +            candidates.put( threadContextClassLoader, candidate );
           }
           return candidate;
       }
  -
  +    
       public static SchemaTypeLoader build(SchemaTypeLoader[] searchPath, ResourceLoader
resourceLoader, ClassLoader classLoader)
       {
           if (searchPath == null)
  
  
  
  No                   revision
  No                   revision
  1.3.2.1   +55 -75    xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Cursor.java
  
  Index: Cursor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Cursor.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- Cursor.java	30 Sep 2003 23:18:15 -0000	1.3
  +++ Cursor.java	30 Mar 2004 03:58:10 -0000	1.3.2.1
  @@ -94,18 +94,8 @@
   
   public final class Cursor implements XmlCursor, ChangeListener
   {
  -    Cursor ( Root r, Splay s )        { assert s != null; _goober = new CursorGoober( r
); set( s ); }
  -    Cursor ( Root r, Splay s, int p ) { assert s != null; _goober = new CursorGoober( r
); set( s, p ); }
  -
  -    protected void finalize ( )
  -    {
  -        Splay s = getSplay();
  -        
  -        if (s != null)
  -        {
  -            dispose();
  -        }
  -    }
  +    Cursor ( Root r, Splay s )        { assert s != null; _data = CursorData.getOne( r
); set( s ); }
  +    Cursor ( Root r, Splay s, int p ) { assert s != null; _data = CursorData.getOne( r
); set( s, p ); }
   
       //
       //
  @@ -116,15 +106,15 @@
           return getRoot();
       }
   
  -    Root  getRoot ( ) { return _goober.getRoot(); }
  +    Root  getRoot ( ) { return _data._goober.getRoot(); }
   
  -    Splay getSplay ( ) { return _goober.getSplay(); }
  -    int   getPos   ( ) { return _goober.getPos(); }
  +    Splay getSplay ( ) { return _data._goober.getSplay(); }
  +    int   getPos   ( ) { return _data._goober.getPos(); }
       
  -    void set ( Splay s, int p ) { _goober.set( s, p ); }
  -    void set ( Splay s        ) { _goober.set( s, 0 ); }
  -    void set ( int p          ) { _goober.set( p ); }
  -    void set ( Goober g       ) { _goober.set( g ); }
  +    void set ( Splay s, int p ) { _data._goober.set( s, p ); }
  +    void set ( Splay s        ) { _data._goober.set( s, 0 ); }
  +    void set ( int p          ) { _data._goober.set( p ); }
  +    void set ( Goober g       ) { _data._goober.set( g ); }
   
       int getPostCch ( )
       {
  @@ -169,7 +159,7 @@
       
       boolean isDisposed ( )
       {
  -        return getSplay() == null;
  +        return _data == null;
       }
   
       //
  @@ -182,12 +172,8 @@
           {
               if (!isDisposed())
               {
  -                clearSelections();
  -    
  -                if (_stack != null)
  -                    _stack.dispose();
  -    
  -                set( (Splay) null );
  +                _data.release();
  +                _data = null;
               }
           }
       }
  @@ -279,7 +265,7 @@
           if (c == null)
               return false;
   
  -        set( c._goober );
  +        set( c._data._goober );
   
           return true;
       }
  @@ -925,7 +911,10 @@
   
       public void insertProcInst ( String target, String value )
       {
  -        validatePrefix( target ); // used becuase "<?xml...?> is disallowed
  +        validateLocalName( target ); // used becuase "<?xml...?> is disallowed
  +
  +        if (Splay.beginsWithXml( target ) && target.length() == 3)
  +            throw new IllegalArgumentException( "Target begins with 'xml'" );
       
           synchronized ( monitor() )
           {
  @@ -1152,7 +1141,7 @@
               if (a._key == null)
                   throw new IllegalArgumentException( "Annotation key is null" );
       
  -            a.set( _goober );
  +            a.set( _data._goober );
               annotation._currentMark = a;
           }
       }
  @@ -2800,10 +2789,10 @@
           {
               checkDisposed();
               
  -            if (_stack == null)
  -                _stack = new Selections();
  +            if (_data._stack == null)
  +                _data._stack = new Selections();
       
  -            _stack.add( getRoot(), getSplay(), getPos() );
  +            _data._stack.add( getRoot(), getSplay(), getPos() );
       
               getRoot().registerForChange( this );
           }
  @@ -2815,12 +2804,12 @@
           {
               checkDisposed();
               
  -            if (_stack == null || _stack.size() == 0)
  +            if (_data._stack == null || _data._stack.size() == 0)
                   return false;
       
  -            _stack.setCursor( this, _stack.size() - 1 );
  +            _data._stack.setCursor( this, _data._stack.size() - 1 );
       
  -            _stack.pop();
  +            _data._stack.pop();
       
               return true;
           }
  @@ -2832,7 +2821,7 @@
           {
               checkDisposed();
               
  -            return _selections == null ? 0 : _selections.size();
  +            return _data._selections == null ? 0 : _data._selections.size();
           }
       }
       
  @@ -2842,9 +2831,9 @@
           {
               checkDisposed();
       
  -            if (_selections != null && i >= 0 && _selections.setCursor(
this, i ))
  +            if (_data._selections != null && i >= 0 && _data._selections.setCursor(
this, i ))
               {
  -                _currentSelection = i;
  +                _data._currentSelection = i;
                   return true;
               }
       
  @@ -2857,7 +2846,7 @@
           synchronized ( monitor() )
           {
               push();
  -            int currentSelection = _currentSelection;
  +            int currentSelection = _data._currentSelection;
       
               try
               {
  @@ -2866,7 +2855,7 @@
               finally
               {
                   pop();
  -                _currentSelection = currentSelection;
  +                _data._currentSelection = currentSelection;
               }
           }
       }
  @@ -2877,18 +2866,18 @@
           {
               checkDisposed();
       
  -            if (_selections == null || _currentSelection < -1)
  +            if (_data._selections == null || _data._currentSelection < -1)
                   return false;
       
  -            int nextSelection = _currentSelection + 1;
  +            int nextSelection = _data._currentSelection + 1;
       
  -            if (!_selections.setCursor( this, nextSelection ))
  +            if (!_data._selections.setCursor( this, nextSelection ))
               {
  -                _currentSelection = -2;
  +                _data._currentSelection = -2;
                   return false;
               }
       
  -            _currentSelection = nextSelection;
  +            _data._currentSelection = nextSelection;
       
               return true;
           }
  @@ -2899,11 +2888,7 @@
           synchronized ( monitor() )
           {
               checkDisposed();
  -            
  -            if (_selections != null)
  -                _selections.dispose();
  -            
  -            _currentSelection = -2;
  +            _data.clearSelections();
           }
       }
   
  @@ -2913,13 +2898,13 @@
           {
               checkDisposed();
               
  -            if (_selections == null)
  -                _selections = Path.newSelections();
  +            if (_data._selections == null)
  +                _data._selections = Path.newSelections();
       
               // Force any selection engine to search all...
  -            _selections.size();
  +            _data._selections.size();
       
  -            _selections.add( getRoot(), getSplay(), getPos() );
  +            _data._selections.add( getRoot(), getSplay(), getPos() );
       
               getRoot().registerForChange( this );
           }
  @@ -2927,14 +2912,14 @@
       
       public void changeNotification ( )
       {
  -        if (_selections != null)
  +        if (_data._selections != null)
           {
  -            _selections.size();  // Force a full selection
  -            _selections.cursify( getRoot() );
  +            _data._selections.size();  // Force a full selection
  +            _data._selections.cursify( getRoot() );
           }
   
  -        if (_stack != null)
  -            _stack.cursify( getRoot() );
  +        if (_data._stack != null)
  +            _data._stack.cursify( getRoot() );
       }
       
       public void selectPath ( String path, XmlOptions options )
  @@ -2943,23 +2928,23 @@
           {
               checkDisposed();
       
  -            if (_selections == null)
  -                _selections = Path.newSelections();
  +            if (_data._selections == null)
  +                _data._selections = Path.newSelections();
               else
  -                _selections.dispose();
  +                _data._selections.dispose();
       
  -            _selections.init( 
  +            _data._selections.init( 
                   Path.select( getRoot(), getSplay(), getPos(), path, options ) );
       
               push();
       
  -            if (_selections.setCursor( this, 0 ))
  +            if (_data._selections.setCursor( this, 0 ))
               {
                   getRoot().registerForChange( this );
  -                _currentSelection = -1;
  +                _data._currentSelection = -1;
               }
               else
  -                _currentSelection = -2;
  +                _data._currentSelection = -2;
       
               pop();
           }
  @@ -3188,12 +3173,12 @@
       
       private boolean validate ( )
       {
  -        assert _goober.getRoot().validate();
  +        assert _data._goober.getRoot().validate();
           return true;
       }
   
  -    public void dump ( ) { _goober.getRoot().dump(); }
  -    public void dump ( boolean verbose ) { _goober.getRoot().dump( verbose ); }
  +    public void dump ( ) { _data._goober.getRoot().dump(); }
  +    public void dump ( boolean verbose ) { _data._goober.getRoot().dump( verbose ); }
   
       interface PathEngine
       {
  @@ -3361,10 +3346,5 @@
       //
       //
   
  -    final CursorGoober _goober;
  -
  -    private Selections _stack;
  -    
  -    private Selections _selections;
  -    private int        _currentSelection;
  +    CursorData _data;
   }
  
  
  
  1.6.2.1   +14 -2     xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Root.java
  
  Index: Root.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Root.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- Root.java	18 Nov 2003 19:19:04 -0000	1.6
  +++ Root.java	30 Mar 2004 03:58:10 -0000	1.6.2.1
  @@ -1397,7 +1397,7 @@
               // loading.  When finished loading, bump it.
   
               _root.invalidateVersion();
  -
  +            
               assert _root.isLeftOnly();
           }
   
  @@ -1485,7 +1485,19 @@
                   _docElemDiscarded = true;
   
                   if (_replaceDocElem == null)
  +                {
  +                    // Remove all content up to now because the
  +                    // document element is to be removed, and I dont
  +                    // want that content to mix with the real content.
  +                    
  +                    _root.ensureEmpty();
  +                    _lastNonAttr = _root._doc;
  +                    _lastSplay = _root._doc;
  +                    _lastPos = 0;
  +                    _frontier = _root._doc;
  +                    
                       return;
  +                }
   
                   name = _replaceDocElem;
               }
  @@ -2288,7 +2300,7 @@
               if (src instanceof Cursor)
               {
                   ps.println(
  -                    "  from cursor " + ((CursorGoober)((Cursor) src)._goober).getDebugId()
);
  +                    "  from cursor " + ((CursorGoober)((Cursor) src)._data._goober).getDebugId()
);
               }
               else if (src instanceof Splay)
                   ps.println( "  from splay " + ((Splay) src).getDebugId() );
  
  
  
  1.4.2.2   +19 -3     xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Saver.java
  
  Index: Saver.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Saver.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- Saver.java	23 Jan 2004 22:39:15 -0000	1.4.2.1
  +++ Saver.java	30 Mar 2004 03:58:10 -0000	1.4.2.2
  @@ -84,6 +84,8 @@
   import java.util.ConcurrentModificationException;
   import javax.xml.namespace.QName;
   import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.ParserConfigurationException;
   import org.w3c.dom.Document;
   import org.w3c.dom.DocumentFragment;
   import org.w3c.dom.Element;
  @@ -4457,6 +4459,22 @@
       //
       //
   
  +    private static ThreadLocal _threadDocumentBuilderFactory =
  +        new ThreadLocal()
  +        {
  +            protected Object initialValue()
  +            {
  +                try
  +                {
  +                    return DocumentBuilderFactory.newInstance().newDocumentBuilder();
  +                }
  +                catch ( ParserConfigurationException e )
  +                {
  +                    throw new RuntimeException( e.getMessage(), e );
  +                }
  +            }
  +        };
  +    
       static final class DomSaver extends Saver
       {
           DomSaver ( Root r, Splay s, int p, boolean createDoc, XmlOptions options )
  @@ -4471,9 +4489,7 @@
               // TODO - add an options which specifies a Document with which
               // to create the fragment
   
  -            _doc =
  -                DocumentBuilderFactory.newInstance().
  -                    newDocumentBuilder().newDocument();
  +            _doc = ((DocumentBuilder) _threadDocumentBuilderFactory.get()).newDocument();
   
               Node result;
   
  
  
  
  No                   revision
  
  Index: Saver.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Saver.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- Saver.java	23 Jan 2004 22:39:15 -0000	1.4.2.1
  +++ Saver.java	30 Mar 2004 03:58:10 -0000	1.4.2.2
  @@ -84,6 +84,8 @@
   import java.util.ConcurrentModificationException;
   import javax.xml.namespace.QName;
   import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.ParserConfigurationException;
   import org.w3c.dom.Document;
   import org.w3c.dom.DocumentFragment;
   import org.w3c.dom.Element;
  @@ -4457,6 +4459,22 @@
       //
       //
   
  +    private static ThreadLocal _threadDocumentBuilderFactory =
  +        new ThreadLocal()
  +        {
  +            protected Object initialValue()
  +            {
  +                try
  +                {
  +                    return DocumentBuilderFactory.newInstance().newDocumentBuilder();
  +                }
  +                catch ( ParserConfigurationException e )
  +                {
  +                    throw new RuntimeException( e.getMessage(), e );
  +                }
  +            }
  +        };
  +    
       static final class DomSaver extends Saver
       {
           DomSaver ( Root r, Splay s, int p, boolean createDoc, XmlOptions options )
  @@ -4471,9 +4489,7 @@
               // TODO - add an options which specifies a Document with which
               // to create the fragment
   
  -            _doc =
  -                DocumentBuilderFactory.newInstance().
  -                    newDocumentBuilder().newDocument();
  +            _doc = ((DocumentBuilder) _threadDocumentBuilderFactory.get()).newDocument();
   
               Node result;
   
  
  
  
  No                   revision
  
  Index: Saver.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Saver.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- Saver.java	23 Jan 2004 22:39:15 -0000	1.4.2.1
  +++ Saver.java	30 Mar 2004 03:58:10 -0000	1.4.2.2
  @@ -84,6 +84,8 @@
   import java.util.ConcurrentModificationException;
   import javax.xml.namespace.QName;
   import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.ParserConfigurationException;
   import org.w3c.dom.Document;
   import org.w3c.dom.DocumentFragment;
   import org.w3c.dom.Element;
  @@ -4457,6 +4459,22 @@
       //
       //
   
  +    private static ThreadLocal _threadDocumentBuilderFactory =
  +        new ThreadLocal()
  +        {
  +            protected Object initialValue()
  +            {
  +                try
  +                {
  +                    return DocumentBuilderFactory.newInstance().newDocumentBuilder();
  +                }
  +                catch ( ParserConfigurationException e )
  +                {
  +                    throw new RuntimeException( e.getMessage(), e );
  +                }
  +            }
  +        };
  +    
       static final class DomSaver extends Saver
       {
           DomSaver ( Root r, Splay s, int p, boolean createDoc, XmlOptions options )
  @@ -4471,9 +4489,7 @@
               // TODO - add an options which specifies a Document with which
               // to create the fragment
   
  -            _doc =
  -                DocumentBuilderFactory.newInstance().
  -                    newDocumentBuilder().newDocument();
  +            _doc = ((DocumentBuilder) _threadDocumentBuilderFactory.get()).newDocument();
   
               Node result;
   
  
  
  
  1.1.2.1   +0 -0      xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/CursorData.java
  
  Index: CursorData.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/CursorData.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message