xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r428159 - in /xmlbeans/trunk/src: store/org/apache/xmlbeans/impl/store/Saver.java typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java
Date Wed, 02 Aug 2006 21:37:01 GMT
Author: radup
Date: Wed Aug  2 14:37:01 2006
New Revision: 428159

URL: http://svn.apache.org/viewvc?rev=428159&view=rev
Log:
Fix for JIRA issue XMLBEANS-209.

Modified:
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java

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?rev=428159&r1=428158&r2=428159&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java Wed Aug  2 14:37:01
2006
@@ -1500,6 +1500,8 @@
             assert _free >= dCch;
             assert getAvailable() > 0;
 
+            int charsToCopy = dCch + 1;
+
             if (_out > _in && i >= _out)
             {
                 System.arraycopy( _buf, _out, _buf, _out - dCch, i - _out );
@@ -1515,23 +1517,33 @@
                     System.arraycopy( _buf, i, _buf, i + dCch, _in - i );
                     _in += dCch;
                 }
-                else
+                else if ( dCch <= availableEndChunk + _in - i - 1 )
                 {
-                    int numToCopyToStart = _in - i - availableEndChunk;
+                    int numToCopyToStart = dCch - availableEndChunk;
                     System.arraycopy( _buf, _in-numToCopyToStart, _buf, 0, numToCopyToStart
);
-                    System.arraycopy( _buf, i, _buf, i+dCch, availableEndChunk );
+                    System.arraycopy( _buf, i+1, _buf, i+1+dCch, _in-i-1-numToCopyToStart);
 
                     _in = numToCopyToStart;
                 }
+                else
+                {
+                    int numToCopyToStart = _in - i - 1;
+                    charsToCopy = availableEndChunk + _in - i;
+
+                    System.arraycopy( _buf, _in-numToCopyToStart, _buf, dCch-charsToCopy+1,
numToCopyToStart );
+                    replacement.getChars( charsToCopy, dCch + 1, _buf, 0);
+
+                    _in = numToCopyToStart + dCch - charsToCopy + 1;
+                }
             }
 
-            replacement.getChars( 0, dCch + 1, _buf, i );
+            replacement.getChars( 0, charsToCopy, _buf, i );
 
             _free -= dCch;
 
             assert _free >= 0;
 
-            return i + dCch + 1;
+            return (i + dCch + 1) % _buf.length;
         }
         //
         //

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java?rev=428159&r1=428158&r2=428159&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
Wed Aug  2 14:37:01 2006
@@ -298,7 +298,7 @@
             }
 
             // deal with imports and includes
-            StscImporter.SchemaToProcess[] schemasAndChameleons = StscImporter.resolveImportsAndIncludes(startWith);
+            StscImporter.SchemaToProcess[] schemasAndChameleons = StscImporter.resolveImportsAndIncludes(startWith,
incremental);
 
             // call the translator so that it may also perform magic
             StscTranslator.addAllDefinitions(schemasAndChameleons);

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java?rev=428159&r1=428158&r2=428159&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java Wed Aug
 2 14:37:01 2006
@@ -34,6 +34,7 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.MalformedURLException;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.Reader;
 import java.io.InputStream;
@@ -59,10 +60,10 @@
 
 public class StscImporter
 {
-    public static SchemaToProcess[] resolveImportsAndIncludes(Schema[] startWith)
+    public static SchemaToProcess[] resolveImportsAndIncludes(Schema[] startWith, boolean
forceSrcSave)
     {
         DownloadTable engine = new DownloadTable(startWith);
-        return engine.resolveImportsAndIncludes();
+        return engine.resolveImportsAndIncludes(forceSrcSave);
     }
 
     public static class SchemaToProcess
@@ -596,7 +597,7 @@
                     if (urlToLoad == null)
                         throw new IOException("EntityResolver unable to resolve " + absoluteURL
+ " (for namespace " + namespace + ")");
 
-                    copySchemaSource(absoluteURL, state);
+                    copySchemaSource(absoluteURL, state, false);
                     XmlOptions options = new XmlOptions();
                     options.setLoadLineNumbers();
                     options.setLoadMessageDigest();
@@ -608,7 +609,7 @@
 
             // no resolver - just use the URL directly, no substitution
             state.addSourceUri(absoluteURL, null);
-            copySchemaSource(absoluteURL, state);
+            copySchemaSource(absoluteURL, state, false);
 
             XmlOptions options = new XmlOptions();
             options.setLoadLineNumbers();
@@ -740,7 +741,7 @@
             }
         }
 
-        public SchemaToProcess[] resolveImportsAndIncludes()
+        public SchemaToProcess[] resolveImportsAndIncludes(boolean forceSave)
         {
             StscState state = StscState.get();
             List result = new ArrayList();
@@ -763,7 +764,7 @@
                     String uri = stp.getSourceName();
                     state.addSourceUri(uri, null);
                     result.add(stp);
-                    copySchemaSource(uri, state);
+                    copySchemaSource(uri, state, forceSave);
 
                     {
                         // handle imports
@@ -936,7 +937,7 @@
             }
         }
 
-        private static void copySchemaSource(String urlLoc, StscState state)
+        private static void copySchemaSource(String urlLoc, StscState state, boolean forceCopy)
         {
             //Copy the schema file if it wasn't already copied
             if (state.getSchemasDir()!=null)
@@ -944,7 +945,7 @@
                 String schemalocation = state.sourceNameForUri(urlLoc);
 
                 File targetFile = new File(state.getSchemasDir(), schemalocation);
-                if (!targetFile.exists())
+                if (forceCopy || !targetFile.exists())
                 {
                     try
                     {
@@ -954,10 +955,22 @@
                         InputStream in = null;
                         URL url = new URL(urlLoc);
                         // Copy the file from filepath to schema[METADATA_PACKAGE_GEN]/src/<schemaFile>
-                        in = url.openStream();
-
-                        FileOutputStream out = new FileOutputStream(targetFile);
-                        IOUtil.copyCompletely(in, out);
+                        try
+                        {
+                            in = url.openStream();
+                        }
+                        catch (FileNotFoundException fnfe)
+                        {
+                            if (forceCopy && targetFile.exists())
+                                targetFile.delete();
+                            else
+                                throw fnfe;
+                        }
+                        if (in != null)
+                        {
+                            FileOutputStream out = new FileOutputStream(targetFile);
+                            IOUtil.copyCompletely(in, out);
+                        }
                     }
                     catch (IOException e)
                     {



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


Mime
View raw message