X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FClientPutDir.java;h=96cdd3bfe3108e167d6abe66e904368ec9209af7;hb=e47e15fdbb7515f5a3757c3f5df8c1d0950aee8e;hp=1474c7d9acfb55f10cdfb7f383a25497be56dc0c;hpb=e4f461213da0e30faf9e9eb2e97626abff320618;p=jSite.git diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java b/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java index 1474c7d..96cdd3b 100644 --- a/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java +++ b/src/de/todesbaum/util/freenet/fcp2/ClientPutDir.java @@ -1,6 +1,5 @@ /* - * todesbaum-lib - - * Copyright (C) 2006 David Roden + * jSite - ClientPutDir.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,18 +23,64 @@ 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. - * + * * @param name * The name of the request * @param identifier @@ -49,7 +94,7 @@ public class ClientPutDir extends ClientPut { /** * Returns the default name of the directory. - * + * * @return The default name of the directory */ public String getDefaultName() { @@ -62,7 +107,7 @@ public class ClientPutDir extends ClientPut { * requested without a filename. It's about the same as the * index.html file that gets delivered if you only request a * directory from a webserver. - * + * * @param defaultName * The default name of the directory */ @@ -71,6 +116,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 +147,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); + } } }