You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2007/06/11 18:33:03 UTC

svn commit: r546185 - in /xmlbeans/trunk: ./ src/store/org/apache/xmlbeans/impl/store/ src/typeimpl/org/apache/xmlbeans/impl/values/ src/xmlpublic/org/apache/xmlbeans/

Author: cezar
Date: Mon Jun 11 09:33:01 2007
New Revision: 546185

URL: http://svn.apache.org/viewvc?view=rev&rev=546185
Log:
Increased version to 2.3.1.
Fixed a couple of bugs related to long CDATA fields.
Fixed bug in OptimizeForSpeedSaver.
XmlObject.copy() is unsynchronized if store is not sync.
Added XmlObjectBase._Copy(XmlOptions) and Locale.COPY_USE_NEW_LOCALE to create a new Locale (sync domain) for copyes.

checkintest is passing


Modified:
    xmlbeans/trunk/build.xml
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Locale.java
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java

Modified: xmlbeans/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/build.xml?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/build.xml (original)
+++ xmlbeans/trunk/build.xml Mon Jun 11 09:33:01 2007
@@ -19,7 +19,7 @@
     <property name="javac.source" value="1.4"/>
     <property name="javac.target" value="1.4"/>
 
-    <property name="version.base" value="2.3.0"/>
+    <property name="version.base" value="2.3.1"/>
 
     <!-- manifest entries -->
     <property name="manifest.name" value="org/apache/xmlbeans/"/>

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Locale.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Locale.java?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Locale.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Locale.java Mon Jun 11 09:33:01 2007
@@ -194,6 +194,11 @@
     //
 
     public static final String USE_SAME_LOCALE = "USE_SAME_LOCALE";
+    /** 
+     * This option is checked in XmlObjectBase._copy(XmlOptions), the locale is used as the synchronization domain.
+     * useNewLocale = true: copy will use a new locale, false: copy will use the same locale as the source
+     */
+    public static final String COPY_USE_NEW_LOCALE             = "COPY_USE_NEW_LOCALE";
 
     static Locale getLocale(SchemaTypeLoader stl, XmlOptions options)
     {

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java Mon Jun 11 09:33:01 2007
@@ -904,6 +904,9 @@
             if (options != null && options.hasOption(XmlOptions.SAVE_CDATA_ENTITY_COUNT_THRESHOLD))
                 _cdataEntityCountThreshold = ((Integer)options.get(XmlOptions.SAVE_CDATA_ENTITY_COUNT_THRESHOLD)).intValue();
 
+            _in = _out = 0;
+            _free = 0;
+
             if (encoding != null && !noSaveDecl)
             {
                 XmlDocumentProperties props = Locale.getDocProps( c, false );
@@ -1141,11 +1144,17 @@
 
         private void emit ( char ch )
         {
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + "_in:" + _in + " _out:" + _out + " _free:" + _free;
+
             preEmit( 1 );
 
             _buf[ _in ] = ch;
 
             _in = (_in + 1) % _buf.length;
+
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + " _in:" + _in + " _out:" + _out + " _free:" + _free;
         }
 
         private void emit ( char ch1, char ch2 )
@@ -1162,6 +1171,9 @@
 
         private void emit ( String s )
         {
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + "_in:" + _in + " _out:" + _out + " _free:" + _free;
+
             int cch = s == null ? 0 : s.length();
 
             if (preEmit( cch ))
@@ -1180,6 +1192,9 @@
                 s.getChars( chunk, cch, _buf, 0 );
                 _in = (_in + cch) % _buf.length;
             }
+
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + "_in:" + _in + " _out:" + _out + " _free:" + _free;
         }
 
         private void emit ( SaveCur c )
@@ -1213,13 +1228,15 @@
         private boolean preEmit ( int cch )
         {
             assert cch >= 0;
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + "_in:" + _in + " _out:" + _out + " _free:" + _free;
 
             _lastEmitCch = cch;
 
             if (cch == 0)
                 return true;
 
-            if (_free < cch)
+            if (_free <= cch)
                 resize( cch, -1 );
 
             assert cch <= _free;
@@ -1242,12 +1259,17 @@
             _free -= cch;
 
             assert _free >= 0;
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in - cch;
 
             return false;
         }
 
         private void entitizeContent ( )
         {
+            assert _out == 0;
+            assert _free == _buf.length - _in;
+
             if (_lastEmitCch == 0)
                 return;
 
@@ -1344,6 +1366,9 @@
                         i = 0;
                 }
             }
+
+            assert _out == 0;
+            assert _free == _buf.length - _in;
         }
 
         private void entitizeAttrValue ( )
@@ -1581,7 +1606,9 @@
         {
             assert _free >= 0;
             assert cch > 0;
-            assert cch > _free;
+            assert cch >= _free;
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + "_in:" + _in + " _out:" + _out + " _free:" + _free;
 
             int newLen = _buf == null ? _initialBufSize : _buf.length * 2;
             int used = getAvailable();
@@ -1613,7 +1640,7 @@
             }
             else
             {
-                _free += newBuf.length;
+                _free = newBuf.length;
                 assert _in == 0 && _out == 0;
                 assert i == -1;
             }
@@ -1621,6 +1648,8 @@
             _buf = newBuf;
 
             assert _free >= 0;
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _buf==null || _free == _buf.length - _in : "_buf:" + _buf + "_in:" + _in + " _out:" + _out + " _free:" + _free;
 
             return i;
         }
@@ -1697,9 +1726,12 @@
                 // I don't want to deal with the circular cases
 
                 assert _out == 0;
+                assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+                assert _free == _buf.length - _in;
 
                 try
                 {
+//System.out.println("-------------\nWriting in corverter: TextSaver.write():1703  " + charsAvailable + " chars\n" + new String(_buf, 0, charsAvailable));
                     writer.write( _buf, 0, charsAvailable );
                     writer.flush();
                 }
@@ -1714,6 +1746,8 @@
 
                 _in = 0;
             }
+            assert _in >= _out : "_in:" + _in + " < _out:" + _out;
+            assert _free == _buf.length - _in;
 
             return charsAvailable;
         }
@@ -1749,6 +1783,12 @@
         private int    _in;
         private int    _out;
         private char[] _buf;
+        /*
+        _buf is a circular buffer, useful data is before _in up to _out, there are 2 posible configurations:
+        1: _in<=_out  |data|_in  empty  _out|data|  ... this is the only case used here
+        2: _out<_in   |empty _out|data|_in  empty|
+        _free is used to keep around the remaining empty space in the bufer so assert _out==0 && _free == _buf.length - _in; 
+         */
     }
 
     static final class OptimizedForSpeedSaver
@@ -2088,8 +2128,8 @@
             int indexLimit = 0;
             while( index<cch )
             {
-                indexLimit = index + 512 > cch ? cch : 512;
-                CharUtil.getChars( _buf, 0, src, off+index, indexLimit );
+                indexLimit = index + 512 > cch ? cch : index + 512;
+                CharUtil.getChars( _buf, 0, src, off+index, indexLimit-index );
                 entitizeAndWriteText(indexLimit-index);
                 index = indexLimit;
             }
@@ -2379,8 +2419,8 @@
 
             bytesAvailable = _outStreamImpl.getAvailable();
 
-            if (bytesAvailable == 0)
-                return 0;
+//            if (bytesAvailable == 0)
+//                return 0;
 
             return bytesAvailable;
         }
@@ -2437,7 +2477,7 @@
                             _buf, 0, bbuf, off + chunk, len - chunk );
                     }
                 }
-
+//System.out.println("------------------------\nRead out of queue: Saver:2440 InputStreamSaver.read() bbuf   " + len + " bytes :\n" + new String(bbuf, off, len));
                 _out = (_out + len) % _buf.length;
                 _free += len;
 
@@ -2465,7 +2505,7 @@
             public void write ( byte[] buf, int off, int cbyte )
             {
                 assert cbyte >= 0;
-
+//System.out.println("---------\nAfter converter, write in queue: OutputStreamImpl.write():Saver:2469  " + cbyte + " bytes \n" + new String(buf, off, cbyte));
                 if (cbyte == 0)
                     return;
 
@@ -2532,7 +2572,7 @@
                 }
                 else
                 {
-                    _free += newBuf.length;
+                    _free = newBuf.length;
                     assert _in == 0 && _out == 0;
                 }
 

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java Mon Jun 11 09:33:01 2007
@@ -2357,7 +2357,7 @@
         return getUser();
     }
 
-    public TypeStoreUser copy(SchemaTypeLoader stl,SchemaType type,XmlOptions options)
+    public TypeStoreUser copy(SchemaTypeLoader stl, SchemaType type, XmlOptions options)
     {
         //do not use a user's Factory method for copying.
         //XmlFactoryHook hook = XmlFactoryHook.ThreadContext.getHook();
@@ -2367,6 +2367,10 @@
 
         if (sType == null)
             sType = type == null ? XmlObject.type : type;
+
+        Locale locale = this.locale();
+        if ( Boolean.TRUE.equals(options.get(Locale.COPY_USE_NEW_LOCALE)) )
+            locale = Locale.getLocale(stl, options);
 
         if (sType.isDocumentType() || (sType.isNoType() && (this instanceof Xobj.DocumentXobj)))
             destination = Cur.createDomDocumentRootXobj(this.locale(), false);

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java Mon Jun 11 09:33:01 2007
@@ -53,7 +53,6 @@
 import org.apache.xmlbeans.impl.schema.SchemaTypeImpl;
 import org.apache.xmlbeans.impl.schema.SchemaTypeVisitorImpl;
 import org.apache.xmlbeans.impl.validator.Validator;
-import org.apache.xmlbeans.impl.values.XmlValueNotNillableException;
 import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.SchemaAttributeModel;
@@ -76,7 +75,6 @@
 import org.apache.xmlbeans.XmlBeans;
 import org.apache.xmlbeans.XmlError;
 import org.apache.xmlbeans.SchemaLocalAttribute;
-import org.apache.xmlbeans.FilterXmlObject;
 import org.apache.xmlbeans.DelegateXmlObject;
 import org.apache.xmlbeans.SchemaTypeLoader;
 
@@ -113,19 +111,39 @@
 
     public final XmlObject copy()
     {
-        synchronized (monitor())
-        {
-            // immutable objects don't get copied. They're immutable
-            if (isImmutable())
-                return this;
+        if (preCheck())
+            return _copy();
+        else
+            synchronized (monitor())
+            {
+                return _copy();
+            }
+    }
+
+    private boolean preCheck()
+    {
+        if (has_store())
+            return get_store().get_locale().noSync();
+        return false;
+    }
+
+    public final XmlObject _copy()
+    {
+        return _copy(null);
+    }
+
+    public final XmlObject _copy(XmlOptions xmlOptions)
+    {
+        // immutable objects don't get copied. They're immutable
+        if (isImmutable())
+            return this;
 
-            check_orphaned();
+        check_orphaned();
 
-            SchemaTypeLoader stl = get_store().get_schematypeloader();
-            XmlObject result = (XmlObject)get_store().copy(stl,schemaType(), null);
+        SchemaTypeLoader stl = get_store().get_schematypeloader();
+        XmlObject result = (XmlObject)get_store().copy(stl, schemaType(), xmlOptions);
 
-            return result;
-        }
+        return result;
     }
 
     public XmlDocumentProperties documentProperties()

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Mon Jun 11 09:33:01 2007
@@ -35,7 +35,7 @@
 public final class XmlBeans
 {
     private static String XMLBEANS_TITLE = "org.apache.xmlbeans";
-    private static String XMLBEANS_VERSION = "2.3.0";
+    private static String XMLBEANS_VERSION = "2.3.1";
     private static String XMLBEANS_VENDOR = "Apache Software Foundation";
 
     static

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java?view=diff&rev=546185&r1=546184&r2=546185
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java Mon Jun 11 09:33:01 2007
@@ -767,6 +767,7 @@
     public static final String GENERATE_JAVA_14 = "1.4";
     public static final String GENERATE_JAVA_15 = "1.5";
 
+
     //
     // Complete set of XmlOption's
     //



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