[freenet-cvs] r17178 - trunk/freenet/src/freenet/support/io

nextgens at freenetproject.org nextgens at freenetproject.org
Mon Jan 21 12:15:59 UTC 2008


Author: nextgens
Date: 2008-01-21 12:15:59 +0000 (Mon, 21 Jan 2008)
New Revision: 17178

Modified:
   trunk/freenet/src/freenet/support/io/ReadOnlyFileSliceBucket.java
Log:
indent

Modified: trunk/freenet/src/freenet/support/io/ReadOnlyFileSliceBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/ReadOnlyFileSliceBucket.java	2008-01-21 12:15:24 UTC (rev 17177)
+++ trunk/freenet/src/freenet/support/io/ReadOnlyFileSliceBucket.java	2008-01-21 12:15:59 UTC (rev 17178)
@@ -13,7 +13,6 @@
 import freenet.support.SimpleFieldSet;
 import freenet.support.api.Bucket;
 
-
 /**
  * FIXME: implement a hash verifying version of this.
  */
@@ -22,33 +21,36 @@
 	private final File file;
 	private final long startAt;
 	private final long length;
-	
+
 	public ReadOnlyFileSliceBucket(File f, long startAt, long length) {
 		this.file = f;
 		this.startAt = startAt;
 		this.length = length;
 	}
-	
-    public ReadOnlyFileSliceBucket(SimpleFieldSet fs) throws CannotCreateFromFieldSetException {
-   		String tmp = fs.get("Filename");
-   		if(tmp == null) throw new CannotCreateFromFieldSetException("No filename");
-   		this.file = new File(tmp);
-   		tmp = fs.get("Length");
-   		if(tmp == null) throw new CannotCreateFromFieldSetException("No length");
-   		try {
-   			length = Long.parseLong(tmp);
-   		} catch (NumberFormatException e) {
-   			throw new CannotCreateFromFieldSetException("Corrupt length "+tmp, e);
-   		}
-   		tmp = fs.get("Offset");
-   		if(tmp == null) throw new CannotCreateFromFieldSetException("No offset");
-   		try {
-   			startAt = Long.parseLong(tmp);
-   		} catch (NumberFormatException e) {
-   			throw new CannotCreateFromFieldSetException("Corrupt offset "+tmp, e);
-   		}
+
+	public ReadOnlyFileSliceBucket(SimpleFieldSet fs) throws CannotCreateFromFieldSetException {
+		String tmp = fs.get("Filename");
+		if(tmp == null)
+			throw new CannotCreateFromFieldSetException("No filename");
+		this.file = new File(tmp);
+		tmp = fs.get("Length");
+		if(tmp == null)
+			throw new CannotCreateFromFieldSetException("No length");
+		try {
+			length = Long.parseLong(tmp);
+		} catch(NumberFormatException e) {
+			throw new CannotCreateFromFieldSetException("Corrupt length " + tmp, e);
+		}
+		tmp = fs.get("Offset");
+		if(tmp == null)
+			throw new CannotCreateFromFieldSetException("No offset");
+		try {
+			startAt = Long.parseLong(tmp);
+		} catch(NumberFormatException e) {
+			throw new CannotCreateFromFieldSetException("Corrupt offset " + tmp, e);
+		}
 	}
-    
+
 	public OutputStream getOutputStream() throws IOException {
 		throw new IOException("Bucket is read-only");
 	}
@@ -58,7 +60,7 @@
 	}
 
 	public String getName() {
-		return "ROFS:"+file.getAbsolutePath()+ ':' +startAt+ ':' +length;
+		return "ROFS:" + file.getAbsolutePath() + ':' + startAt + ':' + length;
 	}
 
 	public long size() {
@@ -70,34 +72,35 @@
 	}
 
 	public void setReadOnly() {
-		// Do nothing
+	// Do nothing
 	}
 
 	private class MyInputStream extends InputStream {
 
 		private RandomAccessFile f;
 		private long ptr; // relative to startAt
-		
+
 		MyInputStream() throws IOException {
 			try {
-				this.f = new RandomAccessFile(file,"r");
+				this.f = new RandomAccessFile(file, "r");
 				f.seek(startAt);
-				if(f.length() < (startAt+length))
-					throw new ReadOnlyFileSliceBucketException("File truncated? Length "+f.length()+" but start at "+startAt+" for "+length+" bytes");
+				if(f.length() < (startAt + length))
+					throw new ReadOnlyFileSliceBucketException("File truncated? Length " + f.length() + " but start at " + startAt + " for " + length + " bytes");
 				ptr = 0;
-			} catch (FileNotFoundException e) {
+			} catch(FileNotFoundException e) {
 				throw new ReadOnlyFileSliceBucketException(e);
 			}
 		}
-		
+
 		public int read() throws IOException {
 			if(ptr >= length)
 				return -1;
 			int x = f.read();
-			if(x != -1) ptr++;
+			if(x != -1)
+				ptr++;
 			return x;
 		}
-		
+
 		public int read(byte[] buf, int offset, int len) throws IOException {
 			if(ptr >= length)
 				return -1;
@@ -106,7 +109,7 @@
 			ptr += x;
 			return x;
 		}
-		
+
 		public int read(byte[] buf) throws IOException {
 			return read(buf, 0, buf.length);
 		}
@@ -117,20 +120,21 @@
 	}
 
 	public static class ReadOnlyFileSliceBucketException extends IOException {
+
 		private static final long serialVersionUID = -1;
-		
+
 		public ReadOnlyFileSliceBucketException(FileNotFoundException e) {
-			super("File not found: "+e.getMessage());
+			super("File not found: " + e.getMessage());
 			initCause(e);
 		}
 
 		public ReadOnlyFileSliceBucketException(String string) {
 			super(string);
 		}
-		
 	}
 
-	public void free() {}
+	public void free() {
+	}
 
 	public SimpleFieldSet toFieldSet() {
 		SimpleFieldSet fs = new SimpleFieldSet(false);
@@ -140,5 +144,4 @@
 		fs.put("Length", length);
 		return fs;
 	}
-	
 }




More information about the cvs mailing list