It would make reviewing easier if you kept functional changes (such as
TempInputStream) separate from bulk re-indenting/comment removal. It matters
more for the node itself than for single-committer non-bundled utilities, of
course.
On Tuesday 17 June 2008 08:15, bombe at freenetproject.org wrote:
> Author: bombe
> Date: 2008-06-17 07:15:05 +0000 (Tue, 17 Jun 2008)
> New Revision: 20394
>
> Modified:
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ARK.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/AddPeer.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/AllData.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/BaseMessage.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ClientGet.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ClientHello.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ClientPut.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ClientPutComplexDir.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ClientPutDiskDir.java
>
trunk/apps/jFCPlib/src/net/pterodactylus/fcp/CloseConnectionDuplicateClientName.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ConfigData.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/DSAGroup.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/DataFound.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/EndListPeerNotes.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/EndListPeers.java
>
trunk/apps/jFCPlib/src/net/pterodactylus/fcp/EndListPersistentRequests.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FCPPluginMessage.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FCPPluginReply.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpAdapter.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpConnection.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpConnectionHandler.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpKeyPair.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpListener.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpMessage.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpTest.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpUtils.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FileEntry.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FinishedCompression.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/GenerateSSK.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/GetConfig.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/GetFailed.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/GetNode.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/GetPluginInfo.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/GetRequestStatus.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/IdentifierCollision.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ListPeer.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ListPeerNotes.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ListPeers.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ListPersistentRequests.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ModifyConfig.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ModifyPeer.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ModifyPeerNote.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ModifyPersistentRequest.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/NodeData.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/NodeHello.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/NodeRef.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/Peer.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PeerNote.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PeerRemoved.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/Persistence.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentGet.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPut.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPutDir.java
>
trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentRequestModified.java
>
trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentRequestRemoved.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PluginInfo.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/Priority.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ProtocolError.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PutFailed.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PutFetchable.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PutSuccessful.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/RemovePeer.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/RemovePersistentRequest.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/ReturnType.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/SSKKeypair.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/Shutdown.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/SimpleProgress.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/StartedCompression.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/SubscribeUSK.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/SubscribedUSKUpdate.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/TestDDAComplete.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/TestDDAReply.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/TestDDARequest.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/TestDDAResponse.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/URIGenerated.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/UnknownNodeIdentifier.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/UnknownPeerNoteType.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/UploadFrom.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/Verbosity.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/Version.java
> trunk/apps/jFCPlib/src/net/pterodactylus/fcp/WatchGlobal.java
> Log:
> fix email address
> reformat
> remove Id tags
>
... lots of indenting/comments, then ...
> Modified: trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpUtils.java
> ===================================================================
> --- trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpUtils.java
> 2008-06-17
07:00:49 UTC (rev 20393)
> +++ trunk/apps/jFCPlib/src/net/pterodactylus/fcp/FcpUtils.java
> 2008-06-17
07:15:05 UTC (rev 20394)
> @@ -19,8 +19,13 @@
>
> package net.pterodactylus.fcp;
>
> +import java.io.ByteArrayInputStream;
> +import java.io.ByteArrayOutputStream;
> import java.io.Closeable;
> import java.io.EOFException;
> +import java.io.File;
> +import java.io.FileInputStream;
> +import java.io.FileOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
> @@ -268,4 +273,198 @@
> }
> }
>
> + /**
> + * This input stream stores the content of another input stream either
> in
a
> + * file or in memory, depending on the length of the input stream.
> + *
> + * @author David ?Bombe? Roden <bombe at freenetproject.org>
> + */
> + public static class TempInputStream extends InputStream {
> +
> + /** The default maximum lenght for in-memory storage. */
> + public static final long MAX_LENGTH_MEMORY = 65536;
> +
> + /** The temporary file to read from. */
> + private final File tempFile;
> +
> + /** The input stream that reads from the file. */
> + private final InputStream fileInputStream;
> +
> + /** The input stream that reads from memory. */
> + private final InputStream memoryInputStream;
> +
> + /**
> + * Creates a new temporary input stream that stores the given
> input
> + * stream in a temporary file.
> + *
> + * @param originalInputStream
> + * The original input stream
> + * @throws IOException
> + * if an I/O error occurs
> + */
> + public TempInputStream(InputStream originalInputStream) throws
IOException {
> + this(originalInputStream, -1);
> + }
> +
> + /**
> + * Creates a new temporary input stream that stores the given
> input
> + * stream in memory if it is shorter than {@link
> #MAX_LENGTH_MEMORY},
> + * otherwise it is stored in a file.
> + *
> + * @param originalInputStream
> + * The original input stream
> + * @param length
> + * The length of the input stream
> + * @throws IOException
> + * if an I/O error occurs
> + */
> + public TempInputStream(InputStream originalInputStream, long
> length)
throws IOException {
> + this(originalInputStream, length, MAX_LENGTH_MEMORY);
> + }
> +
> + /**
> + * Creates a new temporary input stream that stores the given
> input
> + * stream in memory if it is shorter than
> <code>maxMemoryLength</code>,
> + * otherwise it is stored in a file.
> + *
> + * @param originalInputStream
> + * The original input stream
> + * @param length
> + * The length of the input stream
> + * @param maxMemoryLength
> + * The maximum length to store in memory
> + * @throws IOException
> + * if an I/O error occurs
> + */
> + public TempInputStream(InputStream originalInputStream, long
> length, long
maxMemoryLength) throws IOException {
> + if ((length > -1) && (length <= maxMemoryLength)) {
> + ByteArrayOutputStream memoryOutputStream = new
ByteArrayOutputStream((int) length);
> + try {
> + FcpUtils.copy(originalInputStream,
> memoryOutputStream, length, (int)
length);
> + } finally {
> + memoryOutputStream.close();
> + }
> + tempFile = null;
> + fileInputStream = null;
> + memoryInputStream = new
ByteArrayInputStream(memoryOutputStream.toByteArray());
> + } else {
> + tempFile = File.createTempFile("temp-", ".bin");
> + tempFile.deleteOnExit();
> + FileOutputStream fileOutputStream = null;
> + try {
> + fileOutputStream = new
> FileOutputStream(tempFile);
> + FcpUtils.copy(originalInputStream,
> fileOutputStream);
> + fileInputStream = new
> FileInputStream(tempFile);
> + } finally {
> + FcpUtils.close(fileOutputStream);
> + }
> + memoryInputStream = null;
> + }
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public int available() throws IOException {
> + if (memoryInputStream != null) {
> + return memoryInputStream.available();
> + }
> + return fileInputStream.available();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public void close() throws IOException {
> + if (memoryInputStream != null) {
> + memoryInputStream.close();
> + return;
> + }
> + tempFile.delete();
> + fileInputStream.close();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public synchronized void mark(int readlimit) {
> + if (memoryInputStream != null) {
> + memoryInputStream.mark(readlimit);
> + return;
> + }
> + fileInputStream.mark(readlimit);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public boolean markSupported() {
> + if (memoryInputStream != null) {
> + return memoryInputStream.markSupported();
> + }
> + return fileInputStream.markSupported();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public int read() throws IOException {
> + if (memoryInputStream != null) {
> + return memoryInputStream.read();
> + }
> + return fileInputStream.read();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public int read(byte[] b) throws IOException {
> + if (memoryInputStream != null) {
> + return memoryInputStream.read(b);
> + }
> + return fileInputStream.read(b);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public int read(byte[] b, int off, int len) throws IOException {
> + if (memoryInputStream != null) {
> + return memoryInputStream.read(b, off, len);
> + }
> + return fileInputStream.read(b, off, len);
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public synchronized void reset() throws IOException {
> + if (memoryInputStream != null) {
> + memoryInputStream.reset();
> + return;
> + }
> + fileInputStream.reset();
> + }
> +
> + /**
> + * {@inheritDoc}
> + */
> + @Override
> + public long skip(long n) throws IOException {
> + if (memoryInputStream != null) {
> + return memoryInputStream.skip(n);
> + }
> + return fileInputStream.skip(n);
> + }
> +
> + }
> +
> }
>
... more indenting/comments, then...
> Modified: trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentGet.java
> ===================================================================
> --- trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentGet.java
2008-06-17 07:00:49 UTC (rev 20393)
> +++ trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentGet.java
2008-06-17 07:15:05 UTC (rev 20394)
> @@ -19,12 +19,12 @@
>
> package net.pterodactylus.fcp;
>
> +
> /**
> * The ?PersistentGet? message is sent to the client to inform it about a
> * persistent download, either in the client-local queue or in the global
queue.
> *
> - * @author <a href="mailto:dr at ina-germany.de">David Roden</a>
> - * @version $Id$
> + * @author David ?Bombe? Roden <bombe at freenetproject.org>
> */
> public class PersistentGet extends BaseMessage {
>
> @@ -113,7 +113,7 @@
> * @return The priority of the request
> */
> public Priority getPriority() {
> - return
> Priority.values()[FcpUtils.safeParseInt(getField("PriorityClass"),
7)];
> + return
> Priority.values()[FcpUtils.safeParseInt(getField("PriorityClass"),
Priority.unknown.ordinal())];
> }
>
> /**
>
> Modified: trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPut.java
> ===================================================================
> --- trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPut.java
2008-06-17 07:00:49 UTC (rev 20393)
> +++ trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPut.java
2008-06-17 07:15:05 UTC (rev 20394)
> @@ -23,8 +23,7 @@
> * A ?PersistentPut? message notifies a client about a persistent
> * {@link ClientPut} request.
> *
> - * @author <a href="mailto:dr at ina-germany.de">David Roden</a>
> - * @version $Id$
> + * @author David ?Bombe? Roden <bombe at freenetproject.org>
> */
> public class PersistentPut extends BaseMessage {
>
> @@ -113,11 +112,7 @@
> * priority could not be parsed
> */
> public Priority getPriority() {
> - try {
> - return
> Priority.values()[Integer.valueOf(getField("PriorityClass"))];
> - } catch (NumberFormatException nfe1) {
> - return Priority.unknown;
> - }
> + return
> Priority.values()[FcpUtils.safeParseInt(getField("PriorityClass"),
Priority.unknown.ordinal())];
> }
>
> /**
>
> Modified: trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPutDir.java
> ===================================================================
> --- trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPutDir.java
2008-06-17 07:00:49 UTC (rev 20393)
> +++ trunk/apps/jFCPlib/src/net/pterodactylus/fcp/PersistentPutDir.java
2008-06-17 07:15:05 UTC (rev 20394)
> @@ -25,7 +25,6 @@
> * message.
> *
> * @author David ?Bombe? Roden <bombe at freenetproject.org>
> - * @version $Id$
> */
> public class PersistentPutDir extends BaseMessage {
>
> @@ -72,7 +71,7 @@
> * @return The priority of the request
> */
> public Priority getPriority() {
> - return Priority.valueOf(getField("PriorityClass"));
> + return
> Priority.values()[FcpUtils.safeParseInt(getField("PriorityClass"),
Priority.unknown.ordinal())];
> }
>
> /**
>
... more indenting/comments ...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080805/bd72fe67/attachment.pgp>