From 4aa8626a4290644be70b2fe35de7c9d392d4574f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 16 Mar 2012 20:47:23 +0100 Subject: [PATCH] Add possibility to choose a manifest putter for an insert. --- .../util/freenet/fcp2/ClientPutComplexDir.java | 2 +- .../todesbaum/util/freenet/fcp2/ClientPutDir.java | 77 +++++++++++++++++++++- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java index 4be7528..be61b81 100644 --- a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java +++ b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java @@ -38,7 +38,7 @@ import de.todesbaum.util.io.Closer; * @author David Roden <droden@gmail.com> * @version $Id$ */ -public class ClientPutComplexDir extends ClientPutDir { +public class ClientPutComplexDir extends ClientPutDir { /** The file entries of this directory. */ private List fileEntries = new ArrayList(); diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java b/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java index b9291a9..e3396bd 100644 --- a/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java +++ b/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java @@ -25,14 +25,60 @@ import java.io.Writer; /** * Abstract base class for all put requests that insert a directory. * + * @param + * The type of the “ClientPutDir” command * @author David Roden <droden@gmail.com> - * @version $Id$ */ -public class ClientPutDir extends ClientPut { +public class ClientPutDir> extends ClientPut { + + /** + * All possible manifest putters. Manifest putters are used to distribute + * files of a directory insert to different containers, depending on size, + * type, and other factors. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + */ + public enum ManifestPutter { + + /** + * Use the “simple” manifest putter. Despite its name this is currently + * the default manifest putter. + */ + SIMPLE("simple"), + + /** Use the “default” manifest putter. */ + DEFAULT("default"); + + /** The name of the manifest putter. */ + private final String name; + + /** + * Creates a new manifest putter. + * + * @param name + * The name of the manifest putter + */ + private ManifestPutter(String name) { + this.name = name; + } + + /** + * Returns the name of the manifest putter. + * + * @return The name of the manifest putter + */ + public String getName() { + return name; + } + + } /** The default file of the directory. */ protected String defaultName; + /** The manifest putter to use. */ + private ManifestPutter manifestPutter; + /** * Creates a new request with the specified name, identifier, and URI. * @@ -71,6 +117,30 @@ public class ClientPutDir extends ClientPut { } /** + * Returns the current manifest putter. + * + * @return The current manifest putter (may be {@code null}) + */ + public ManifestPutter getManifestPutter() { + return manifestPutter; + } + + /** + * Sets the manifest putter for the “ClientPutDir” command. If {@code null} + * is given the node will choose a manifest putter. + * + * @param manifestPutter + * The manifest putter to use for the command (may be + * {@code null}) + * @return This ClientPutDir command + */ + @SuppressWarnings("unchecked") + public C setManifestPutter(ManifestPutter manifestPutter) { + this.manifestPutter = manifestPutter; + return (C) this; + } + + /** * {@inheritDoc} */ @Override @@ -78,6 +148,9 @@ public class ClientPutDir extends ClientPut { super.write(writer); if (defaultName != null) writer.write("DefaultName=" + defaultName + LINEFEED); + if (manifestPutter != null) { + writer.write("ManifestPutter=" + manifestPutter.getName() + LINEFEED); + } } } -- 2.7.4