You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2014/04/01 14:45:57 UTC
svn commit: r1583650 - in
/db/derby/code/trunk/java/engine/org/apache/derby/impl/io: CPFile.java
InputStreamFile.java JarDBFile.java URLFile.java
Author: kahatlen
Date: Tue Apr 1 12:45:57 2014
New Revision: 1583650
URL: http://svn.apache.org/r1583650
Log:
DERBY-6535: Remove storageFactory field from subclasses of InputStreamFile
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/io/InputStreamFile.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarDBFile.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLFile.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java?rev=1583650&r1=1583649&r2=1583650&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java Tue Apr 1 12:45:57 2014
@@ -34,33 +34,27 @@ import java.security.PrivilegedAction;
* This class provides a class path based implementation of the StorageFile interface. It is used by the
* database engine to access persistent data and transaction logs under the classpath subsubprotocol.
*/
-class CPFile extends InputStreamFile
+class CPFile extends InputStreamFile<CPStorageFactory>
{
- private final CPStorageFactory storageFactory;
-
CPFile( CPStorageFactory storageFactory, String path)
{
super( storageFactory, path);
- this.storageFactory = storageFactory;
}
CPFile( CPStorageFactory storageFactory, String parent, String name)
{
super( storageFactory, parent, name);
- this.storageFactory = storageFactory;
}
CPFile( CPFile dir, String name)
{
super( dir,name);
- this.storageFactory = dir.storageFactory;
}
private CPFile( CPStorageFactory storageFactory, String child, int pathLen)
{
super( storageFactory, child, pathLen);
- this.storageFactory = storageFactory;
}
/**
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/InputStreamFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/InputStreamFile.java?rev=1583650&r1=1583649&r2=1583650&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/InputStreamFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/InputStreamFile.java Tue Apr 1 12:45:57 2014
@@ -37,15 +37,17 @@ import org.apache.derby.iapi.error.Stand
/**
* This class provides the base for read-only stream implementations of the StorageFile interface. It is used with the
* classpath, jar, http, and https subsubprotocols
+ * @param <F> the storage factory class used by the subsubprotocol
*/
-abstract class InputStreamFile implements StorageFile
+abstract class InputStreamFile<F extends BaseStorageFactory>
+ implements StorageFile
{
final String path;
final int nameStart; // getName() = path.substring( nameStart)
- final BaseStorageFactory storageFactory;
+ final F storageFactory;
- InputStreamFile( BaseStorageFactory storageFactory, String path)
+ InputStreamFile(F storageFactory, String path)
{
this.storageFactory = storageFactory;
if( path == null || path.length() == 0)
@@ -55,7 +57,8 @@ abstract class InputStreamFile implement
}
else
{
- StringBuffer sb = new StringBuffer( storageFactory.separatedDataDirectory);
+ StringBuilder sb =
+ new StringBuilder(storageFactory.separatedDataDirectory);
if( File.separatorChar != '/')
sb.append( path.replace( File.separatorChar, '/'));
else
@@ -65,10 +68,11 @@ abstract class InputStreamFile implement
}
}
- InputStreamFile( BaseStorageFactory storageFactory, String parent, String name)
+ InputStreamFile(F storageFactory, String parent, String name)
{
this.storageFactory = storageFactory;
- StringBuffer sb = new StringBuffer( storageFactory.separatedDataDirectory);
+ StringBuilder sb =
+ new StringBuilder(storageFactory.separatedDataDirectory);
if( File.separatorChar != '/')
{
sb.append( parent.replace( File.separatorChar, '/'));
@@ -85,10 +89,10 @@ abstract class InputStreamFile implement
nameStart = this.path.lastIndexOf( '/') + 1;
}
- InputStreamFile( InputStreamFile dir, String name)
+ InputStreamFile(InputStreamFile<F> dir, String name)
{
this.storageFactory = dir.storageFactory;
- StringBuffer sb = new StringBuffer( dir.path);
+ StringBuilder sb = new StringBuilder(dir.path);
sb.append( '/');
if( File.separatorChar != '/')
sb.append( name.replace( File.separatorChar, '/'));
@@ -98,13 +102,14 @@ abstract class InputStreamFile implement
nameStart = this.path.lastIndexOf( '/') + 1;
}
- InputStreamFile( BaseStorageFactory storageFactory, String child, int pathLen)
+ InputStreamFile(F storageFactory, String child, int pathLen)
{
this.storageFactory = storageFactory;
path = child.substring( 0, pathLen);
nameStart = this.path.lastIndexOf( '/') + 1;
}
+ @Override
public boolean equals( Object other)
{
if( other == null || ! getClass().equals( other.getClass()))
@@ -113,6 +118,7 @@ abstract class InputStreamFile implement
return path.equals( otherFile.path);
}
+ @Override
public int hashCode()
{
return path.hashCode();
@@ -394,6 +400,7 @@ abstract class InputStreamFile implement
*
* @return the file name
*/
+ @Override
public String toString()
{
return path;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarDBFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarDBFile.java?rev=1583650&r1=1583649&r2=1583650&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarDBFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarDBFile.java Tue Apr 1 12:45:57 2014
@@ -31,33 +31,27 @@ import java.util.zip.ZipEntry;
* This class provides a jar file based implementation of the StorageFile interface. It is used by the
* database engine to access persistent data and transaction logs under the jar subsubprotocol.
*/
-class JarDBFile extends InputStreamFile
+class JarDBFile extends InputStreamFile<JarStorageFactory>
{
- private final JarStorageFactory storageFactory;
-
JarDBFile( JarStorageFactory storageFactory, String path)
{
super( storageFactory, path);
- this.storageFactory = storageFactory;
}
JarDBFile( JarStorageFactory storageFactory, String parent, String name)
{
super( storageFactory, parent, name);
- this.storageFactory = storageFactory;
}
JarDBFile( JarDBFile dir, String name)
{
super( dir,name);
- this.storageFactory = dir.storageFactory;
}
private JarDBFile( JarStorageFactory storageFactory, String child, int pathLen)
{
super( storageFactory, child, pathLen);
- this.storageFactory = storageFactory;
}
/**
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLFile.java?rev=1583650&r1=1583649&r2=1583650&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLFile.java Tue Apr 1 12:45:57 2014
@@ -22,48 +22,38 @@
package org.apache.derby.impl.io;
import org.apache.derby.io.StorageFile;
-import org.apache.derby.io.StorageRandomAccessFile;
-
-import org.apache.derby.shared.common.sanity.SanityManager;
import java.io.InputStream;
-import java.io.OutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.net.URL;
/**
- * This class provides a class path based implementation of the StorageFile interface. It is used by the
- * database engine to access persistent data and transaction logs under the classpath subsubprotocol.
+ * This class provides a http based implementation of the StorageFile interface. It is used by the
+ * database engine to access persistent data and transaction logs under the http and https subsubprotocols.
*/
-class URLFile extends InputStreamFile
+class URLFile extends InputStreamFile<URLStorageFactory>
{
- private final URLStorageFactory storageFactory;
-
URLFile( URLStorageFactory storageFactory, String path)
{
super( storageFactory, path);
- this.storageFactory = storageFactory;
}
URLFile( URLStorageFactory storageFactory, String parent, String name)
{
super( storageFactory, parent, name);
- this.storageFactory = storageFactory;
}
URLFile( URLFile dir, String name)
{
super( dir,name);
- this.storageFactory = dir.storageFactory;
}
private URLFile( URLStorageFactory storageFactory, String child, int pathLen)
{
super( storageFactory, child, pathLen);
- this.storageFactory = storageFactory;
}
/**