jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r571399 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: data/ value/
Date Fri, 31 Aug 2007 08:24:00 GMT
Author: thomasm
Date: Fri Aug 31 01:23:59 2007
New Revision: 571399

URL: http://svn.apache.org/viewvc?rev=571399&view=rev
Log:
JCR-926: follow Jackrabbit code style

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataIdentifier.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataIdentifier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataIdentifier.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataIdentifier.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/DataIdentifier.java
Fri Aug 31 01:23:59 2007
@@ -58,8 +58,8 @@
     public DataIdentifier(byte[] identifier) {
         char[] buffer = new char[identifier.length * 2];
         for (int i = 0; i < identifier.length; i++) {
-            buffer[2*i] = HEX[(identifier[i] >> 4) & 0x0f]; 
-            buffer[2*i + 1] = HEX[identifier[i] & 0x0f]; 
+            buffer[2 * i] = HEX[(identifier[i] >> 4) & 0x0f];
+            buffer[2 * i + 1] = HEX[identifier[i] & 0x0f]; 
         }
         this.identifier = new String(buffer);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
Fri Aug 31 01:23:59 2007
@@ -83,8 +83,8 @@
      */
     public DataRecord getRecord(DataIdentifier identifier) {
         File file = getFile(identifier);
-        if(minModifiedDate != 0 && file.exists() && file.canWrite()) {
-            if(file.lastModified() < minModifiedDate) {
+        if (minModifiedDate != 0 && file.exists() && file.canWrite()) {
+            if (file.lastModified() < minModifiedDate) {
                 file.setLastModified(System.currentTimeMillis());
             }
         }
@@ -134,7 +134,7 @@
                 temporary.renameTo(file);
             } else {
                 long now = System.currentTimeMillis();
-                if(file.lastModified() < now) {
+                if (file.lastModified() < now) {
                     file.setLastModified(now);
                 }
             }
@@ -205,14 +205,14 @@
 
     private int deleteOlderRecursive(File file, long min) {
         int count = 0;
-        if(file.isFile() && file.exists() && file.canWrite()) {
-            if(file.lastModified() < min) {
+        if (file.isFile() && file.exists() && file.canWrite()) {
+            if (file.lastModified() < min) {
                 file.delete();
                 count++;
             }
-        } else if(file.isDirectory()) {
+        } else if (file.isDirectory()) {
             File[] list = file.listFiles();
-            for(int i=0; i<list.length; i++) {
+            for (int i = 0; i < list.length; i++) {
                 count += deleteOlderRecursive(list[i], min);
             }
         }
@@ -221,9 +221,9 @@
     
     private void listRecursive(List list, File file) {
         File[] l = file.listFiles();
-        for(int i=0; l != null && i<l.length; i++) {
+        for (int i = 0; l != null && i < l.length; i++) {
             File f = l[i];
-            if(f.isDirectory()) {
+            if (f.isDirectory()) {
                 listRecursive(list, f);
             } else {
                 list.add(f);
@@ -238,10 +238,10 @@
         ArrayList files = new ArrayList();
         listRecursive(files, directory);
         ArrayList identifiers = new ArrayList();
-        for(int i=0; i<files.size(); i++) {
+        for (int i = 0; i < files.size(); i++) {
             File f = (File) files.get(i);
             String name = f.getName();
-            if(!name.startsWith(TMP)) {
+            if (!name.startsWith(TMP)) {
                 DataIdentifier id = new DataIdentifier(name);
                 identifiers.add(id);
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
Fri Aug 31 01:23:59 2007
@@ -239,7 +239,7 @@
         }
 
         public void onEvent(EventIterator events) {
-            if(testDelay > 0) {
+            if (testDelay > 0) {
                 try {
                     Thread.sleep(testDelay);
                 } catch (InterruptedException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
Fri Aug 31 01:23:59 2007
@@ -39,7 +39,7 @@
      * 
      * @return An InputStream representation of this value.
      */
-    abstract public InputStream getStream() throws IllegalStateException, RepositoryException;
+    public abstract InputStream getStream() throws RepositoryException;
 
     /**
      * Returns the length of this <code>BLOBFileValue</code>.
@@ -48,7 +48,7 @@
      *         or -1L if the length can't be determined.
      * @throws IOException 
      */
-    abstract public long getLength();
+    public abstract long getLength();
 
     /**
      * Frees temporarily allocated resources such as temporary file, buffer, etc.
@@ -58,7 +58,7 @@
      * @see #delete()
      * @see #delete(boolean)
      */
-    abstract public void discard();
+    public abstract void discard();
 
     /**
      * Deletes the persistent resource backing this <code>BLOBFileValue</code>.
@@ -66,17 +66,17 @@
      * @param pruneEmptyParentDirs if <code>true</code>, empty parent directories
      *                             will automatically be deleted
      */
-    abstract public void delete(boolean pruneEmptyParentDirs);
+    public abstract void delete(boolean pruneEmptyParentDirs);
 
     /**
      * {@inheritDoc}
      */
-    abstract public boolean equals(Object obj);
+    public abstract boolean equals(Object obj);
     
     /**
      * {@inheritDoc}
      */
-    abstract public String toString();
+    public abstract String toString();
     
     /*
      * Spools the contents of this <code>BLOBFileValue</code> to the given
@@ -104,14 +104,8 @@
     }
 
     /**
-     * Returns zero to satisfy the Object equals/hashCode contract.
-     * This class is not meant to be used as a hash key.
-     *
-     * @return always zero
-     * @see Object#hashCode()
+     * {@inheritDoc}
      */
-    public int hashCode() {
-        return 0;
-    }
+    public abstract int hashCode();
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
Fri Aug 31 01:23:59 2007
@@ -65,12 +65,23 @@
     }
 
     public boolean equals(Object obj) {
-        if(!(obj instanceof BLOBInDataStore) || obj == null) {
+        if (!(obj instanceof BLOBInDataStore) || obj == null) {
             return false;
         }
         BLOBInDataStore other = (BLOBInDataStore) obj;
         return store == other.store && identifier.equals(other.identifier);
     }
+    
+    /**
+     * Returns zero to satisfy the Object equals/hashCode contract.
+     * This class is mutable and not meant to be used as a hash key.
+     *
+     * @return always zero
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        return 0;
+    }
 
     public long getLength() {
         try {
@@ -81,7 +92,7 @@
         }
     }
 
-    public InputStream getStream() throws IllegalStateException, RepositoryException {
+    public InputStream getStream() throws RepositoryException {
         try {
             return getDataRecord().getStream();
         } catch (IOException e) {
@@ -121,7 +132,7 @@
     }    
     
     private DataRecord getDataRecord() throws IOException {
-        if(dataRecord == null) {
+        if (dataRecord == null) {
             dataRecord = store.getRecord(identifier);
         }
         return dataRecord;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
Fri Aug 31 01:23:59 2007
@@ -73,7 +73,7 @@
      * @param data the byte array
      */    
     static BLOBInMemory getInstance(byte[] data) {
-        if(data.length == 0) {
+        if (data.length == 0) {
             return EMPTY;
         } else {
             return new BLOBInMemory(data);
@@ -175,5 +175,16 @@
         }
         return false;
     }
+    
+    /**
+     * Returns zero to satisfy the Object equals/hashCode contract.
+     * This class is mutable and not meant to be used as a hash key.
+     *
+     * @return always zero
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        return 0;
+    }    
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
Fri Aug 31 01:23:59 2007
@@ -56,16 +56,16 @@
             file = fileFactory.createTransientFile("bin", null, null);
             out = new FileOutputStream(file);
             byte[] buffer = new byte[4 * 1024];
-            while(true) {
+            while (true) {
                 int len = in.read(buffer);
-                if(len < 0) {
+                if (len < 0) {
                     break;
                 }
                 out.write(buffer, 0, len);
                 length += len;                
             }
         } finally {
-            if(out != null) {
+            if (out != null) {
                 out.close();
             }
             in.close();
@@ -138,5 +138,16 @@
         }
         return false;
     }
+    
+    /**
+     * Returns zero to satisfy the Object equals/hashCode contract.
+     * This class is mutable and not meant to be used as a hash key.
+     *
+     * @return always zero
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        return 0;
+    }    
     
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=571399&r1=571398&r2=571399&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
Fri Aug 31 01:23:59 2007
@@ -85,7 +85,7 @@
     /**
      * Byte arrays smaller or equal this size are always kept in memory
      */
-    private final static int MIN_BLOB_FILE_SIZE = Integer.parseInt(System.getProperty("org.jackrabbit.minBlobFileSize",
"100"));
+    private static final int MIN_BLOB_FILE_SIZE = Integer.parseInt(System.getProperty("org.jackrabbit.minBlobFileSize",
"100"));
 
     private final Object val;
     private final int type;
@@ -121,8 +121,8 @@
         switch (value.getType()) {
             case PropertyType.BINARY:
                 try {
-                    if(USE_DATA_STORE) {
-                        if(store == null) {
+                    if (USE_DATA_STORE) {
+                        if (store == null) {
                             return new InternalValue(BLOBInTempFile.getInstance(value.getStream()));
                         } else {
                             return new InternalValue(getBLOBFileValue(store, value.getStream()));
@@ -220,7 +220,7 @@
      * @return the created value
      */
     public static InternalValue create(byte[] value) {
-        if(USE_DATA_STORE) {        
+        if (USE_DATA_STORE) {        
             return new InternalValue(BLOBInMemory.getInstance(value));
         }
         return new InternalValue(new BLOBValue(value));
@@ -234,7 +234,7 @@
      * @return the internal value
      */
     public static InternalValue createTemporary(InputStream value) throws IOException {
-        if(USE_DATA_STORE) {        
+        if (USE_DATA_STORE) {        
             return new InternalValue(BLOBInTempFile.getInstance(value));
         }
         return new InternalValue(new BLOBValue(value, true));
@@ -249,7 +249,7 @@
      * @return the internal value
      */
     public static InternalValue createTemporary(InputStream value, DataStore store) throws
IOException {
-        if(USE_DATA_STORE) {
+        if (USE_DATA_STORE) {
             return new InternalValue(getBLOBFileValue(store, value));
         }
         return new InternalValue(new BLOBValue(value, true));
@@ -446,7 +446,7 @@
      * @throws RepositoryException
      */
     public InternalValue createCopy() throws RepositoryException {
-        if(USE_DATA_STORE) {
+        if (USE_DATA_STORE) {
             return this;
         }
         if (type == PropertyType.BINARY) {
@@ -597,15 +597,15 @@
     private static BLOBFileValue getBLOBFileValue(DataStore store, InputStream in) throws
IOException {
         byte[] buffer = new byte[MIN_BLOB_FILE_SIZE];
         int pos = 0, len = MIN_BLOB_FILE_SIZE;
-        while(pos < MIN_BLOB_FILE_SIZE) {
+        while (pos < MIN_BLOB_FILE_SIZE) {
             int l = in.read(buffer, pos, len);
-            if(l < 0) {
+            if (l < 0) {
                 break;
             }
             pos += l;
             len -= l;
         }
-        if(pos < MIN_BLOB_FILE_SIZE) {
+        if (pos < MIN_BLOB_FILE_SIZE) {
             // shrink the buffer
             byte[] data = new byte[pos];
             System.arraycopy(buffer, 0, data, 0, pos);
@@ -618,9 +618,9 @@
     }
 
     private static BLOBFileValue getBLOBFileValue(DataStore store, String id) {
-        if(BLOBInMemory.isInstance(id)) {
+        if (BLOBInMemory.isInstance(id)) {
             return BLOBInMemory.getInstance(id);
-        } else if(BLOBInDataStore.isInstance(id)) {
+        } else if (BLOBInDataStore.isInstance(id)) {
             return BLOBInDataStore.getInstance(store, id);
         } else {
             throw new IllegalArgumentException("illegal binary id: " + id);



Mime
View raw message