đź“„ Update year in copyright line
[jSite.git] / src / main / java / de / todesbaum / util / freenet / fcp2 / ClientPutDir.java
1 /*
2  * jSite - ClientPutDir.java - Copyright Â© 2006–2019 David Roden
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 package de.todesbaum.util.freenet.fcp2;
20
21 import java.io.IOException;
22 import java.io.Writer;
23
24 /**
25  * Abstract base class for all put requests that insert a directory.
26  *
27  * @param <C>
28  *            The type of the â€śClientPutDir” command
29  * @author David Roden &lt;droden@gmail.com&gt;
30  */
31 public class ClientPutDir<C extends ClientPutDir<?>> extends ClientPut {
32
33         /** The default file of the directory. */
34         protected String defaultName;
35
36         /**
37          * Creates a new request with the specified name, identifier, and URI.
38          *
39          * @param name
40          *            The name of the request
41          * @param identifier
42          *            The identifier of the request
43          * @param uri
44          *            The URI of the request
45          */
46         public ClientPutDir(String name, String identifier, String uri) {
47                 super(name, identifier, uri);
48         }
49
50         /**
51          * Returns the default name of the directory.
52          *
53          * @return The default name of the directory
54          */
55         public String getDefaultName() {
56                 return defaultName;
57         }
58
59         /**
60          * Sets the default name of the directory. The default name of a directory
61          * is the name of the file that will be delivered if the directory was
62          * requested without a filename. It's about the same as the
63          * <code>index.html</code> file that gets delivered if you only request a
64          * directory from a webserver.
65          *
66          * @param defaultName
67          *            The default name of the directory
68          */
69         public void setDefaultName(String defaultName) {
70                 this.defaultName = defaultName;
71         }
72
73         /**
74          * {@inheritDoc}
75          */
76         @Override
77         protected void write(Writer writer) throws IOException {
78                 super.write(writer);
79                 if (defaultName != null)
80                         writer.write("DefaultName=" + defaultName + LINEFEED);
81         }
82
83 }