X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FCommand.java;fp=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FCommand.java;h=0000000000000000000000000000000000000000;hb=38bdc433e50669e8244a63b5af59e597f88f1d29;hp=63aaa9c7c14efb233bff195c1cbd5dc73cc78a74;hpb=f14b9fbe6d88e23920b10a75ebeba4d38390301b;p=jSite.git diff --git a/src/de/todesbaum/util/freenet/fcp2/Command.java b/src/de/todesbaum/util/freenet/fcp2/Command.java deleted file mode 100644 index 63aaa9c..0000000 --- a/src/de/todesbaum/util/freenet/fcp2/Command.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * jSite - Command.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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.todesbaum.util.freenet.fcp2; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Writer; - -/** - * Abstract base class for all commands. - *

- * In addition to the replies listed at the type comment of each specific - * command the node can always send the following messages: - * ProtocolError (if this library screws up), - * CloseConnectionDuplicateClientName (if a client with the same - * name of the {@link de.todesbaum.util.freenet.fcp2.Connection} connects). So - * when receiving messages from the node you should always be prepared for - * something you did not expect. - * - * @author David Roden <droden@gmail.com> - * @version $Id$ - */ -public abstract class Command { - - /** The line feed sequence used by the library. */ - protected static final String LINEFEED = "\r\n"; - - /** - * The name of the command. The name is sent to the node so it can not be - * chosen arbitrarily! - */ - private final String commandName; - - /** - * The identifier of the command. This identifier is used to identify - * replies that are caused by a command. - */ - private final String identifier; - - /** - * Creates a new command with the specified name and identifier. - * - * @param name - * The name of the command - * @param identifier - * The identifier of the command - */ - public Command(String name, String identifier) { - this.commandName = name; - this.identifier = identifier; - } - - /** - * Returns the name of this command. - * - * @return The name of this command - */ - public String getCommandName() { - return commandName; - } - - /** - * Return the identifier of this command. - * - * @return The identifier of this command - */ - public String getIdentifier() { - return identifier; - } - - /** - * Writes all parameters to the specified writer. - *

- * NOTE: Subclasses of Command must call - * super.write(writer) before or after writing their own - * parameters! - * - * @param writer - * The stream to write the parameters to - * @throws IOException - * if an I/O error occurs - */ - protected void write(Writer writer) throws IOException { - if (identifier != null) - writer.write("Identifier=" + identifier + LINEFEED); - } - - /** - * Returns whether this command has payload to send after the message. - * Subclasses need to return true here if they need to send - * payload after the message. - * - * @return true if this command has payload to send, - * false otherwise - */ - protected boolean hasPayload() { - return false; - } - - /** - * Returns the payload of this command as an {@link InputStream}. This - * method is never called if {@link #hasPayload()} returns - * false. - * - * @return The payload of this command - */ - protected InputStream getPayload() { - return null; - } - - /** - * Returns the length of the payload. This method is never called if - * {@link #hasPayload()} returns false. - * - * @return The length of the payload - */ - protected long getPayloadLength() { - return -1; - } - -}