maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r412289 - /maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java
Date Wed, 07 Jun 2006 04:38:04 GMT
Author: brett
Date: Tue Jun  6 21:38:04 2006
New Revision: 412289

URL: http://svn.apache.org/viewvc?rev=412289&view=rev
Log:
clean up, use IOUtil

Modified:
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java?rev=412289&r1=412288&r2=412289&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java
(original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java
Tue Jun  6 21:38:04 2006
@@ -27,6 +27,7 @@
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.repository.digest.Digester;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -184,26 +185,7 @@
         {
             for ( int i = 0; i < files.length; i++ )
             {
-                ZipEntry e = new ZipEntry( files[i].getName() );
-                zos.putNextEntry( e );
-
-                FileInputStream is = new FileInputStream( files[i] );
-                byte[] buf = new byte[4096];
-                int n;
-                try
-                {
-                    while ( ( n = is.read( buf ) ) > 0 )
-                    {
-                        zos.write( buf, 0, n );
-                    }
-                }
-                finally
-                {
-                    is.close();
-                }
-                zos.flush();
-
-                zos.closeEntry();
+                writeFile( zos, files[i] );
             }
         }
         finally
@@ -214,6 +196,26 @@
         return outputFile;
     }
 
+    private static void writeFile( ZipOutputStream zos, File file )
+        throws IOException
+    {
+        ZipEntry e = new ZipEntry( file.getName() );
+        zos.putNextEntry( e );
+
+        FileInputStream is = new FileInputStream( file );
+        try
+        {
+            IOUtil.copy( is, zos );
+        }
+        finally
+        {
+            is.close();
+        }
+        zos.flush();
+
+        zos.closeEntry();
+    }
+
     /**
      * @see AbstractRepositoryIndex#deleteIfIndexed(Object)
      */
@@ -257,7 +259,7 @@
     /**
      * Class used to analyze the lucene index
      */
-    private class EclipseIndexAnalyzer
+    private static class EclipseIndexAnalyzer
         extends Analyzer
     {
         private Analyzer defaultAnalyzer;
@@ -267,7 +269,7 @@
          *
          * @param defaultAnalyzer the analyzer to use as default for the general fields of
the artifact indeces
          */
-        public EclipseIndexAnalyzer( Analyzer defaultAnalyzer )
+        EclipseIndexAnalyzer( Analyzer defaultAnalyzer )
         {
             this.defaultAnalyzer = defaultAnalyzer;
         }
@@ -294,33 +296,33 @@
 
             return tokenStream;
         }
+    }
 
+    /**
+     * Class used to tokenize the eclipse index
+     */
+    private static class EclipseIndexTokenizer
+        extends CharTokenizer
+    {
         /**
-         * Class used to tokenize the eclipse index
+         * Constructor with the required reader to the index stream
+         *
+         * @param reader the Reader object of the index stream
          */
-        private class EclipseIndexTokenizer
-            extends CharTokenizer
+        EclipseIndexTokenizer( Reader reader )
         {
-            /**
-             * Constructor with the required reader to the index stream
-             *
-             * @param reader the Reader object of the index stream
-             */
-            EclipseIndexTokenizer( Reader reader )
-            {
-                super( reader );
-            }
-
-            /**
-             * method that lucene calls to check tokenization of a stream character
-             *
-             * @param character char currently being processed
-             * @return true if the char is a token, false if the char is a stop char
-             */
-            protected boolean isTokenChar( char character )
-            {
-                return true;
-            }
+            super( reader );
+        }
+
+        /**
+         * method that lucene calls to check tokenization of a stream character
+         *
+         * @param character char currently being processed
+         * @return true if the char is a token, false if the char is a stop char
+         */
+        protected boolean isTokenChar( char character )
+        {
+            return true;
         }
     }
 }



Mime
View raw message