FTP-Server API

server.commands
Class AbstractCommand

java.lang.Object
  |
  +--server.commands.AbstractCommand
All Implemented Interfaces:
Comparable, Serializable
Direct Known Subclasses:
Abor, Admin, Allo, Appe, Cdup, Cwd, Dele, Help, List, Mdtm, Mkd, Nlst, Noop, NotLogedIn, Pass, Pasv, Port, Pwd, Quit, Rein, Rest, Retr, Rmd, Rnfr, Rnto, Size, Stat, Stor, Syst, Type, Unknown, User, Welcome

public abstract class AbstractCommand
extends Object
implements Comparable, Serializable

This is the superclass of ANY command! It formes the Chain-of-Responsibillity. The class MUST have the name of the FTP - command in order to work! Fx. is the command cwd handled by the class Cwd.class.

See Also:
Serialized Form

Field Summary
protected  Command command
           
protected  String name
           
protected  String originalOrder
           
protected  Session ses
           
 
Constructor Summary
AbstractCommand()
           
 
Method Summary
 void action(String originalOrder)
          Sends the Clients order to the Object.
 void addCommandLast(AbstractCommand command)
          Adds a command as the second last commmand.
 void build(Session ses, Command command)
          Is used to build up the chain.
protected abstract  void carryOut(String order)
          This method holds the implementation for the command.
 AbstractCommand clone(Session ses, Command com)
           
 int compareTo(Object o1)
           
protected  int countUp()
           
 boolean equals(Object o)
           
protected  String fileToSystem(File f)
          Takes a file, and prints it in the correct way (Windows vs Unix)
protected  File makeFileOfOrder(String order)
          Makes a file of an order.
 void save()
           
 AbstractCommand sort()
           
protected  void start()
          Empty method that can be overridden, and is called at instantiation time.
 String toString()
          Prints a comma seperated list of the the names in the Chain-of-responsibillity, from this AbstactCommand and forward.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

command

protected Command command

ses

protected Session ses

name

protected String name

originalOrder

protected String originalOrder
Constructor Detail

AbstractCommand

public AbstractCommand()
Method Detail

carryOut

protected abstract void carryOut(String order)
This method holds the implementation for the command. It is called with the result of a removeFirst(String order) call.

Parameters:
order - the order, except the first word.

save

public final void save()

clone

public final AbstractCommand clone(Session ses,
                                   Command com)

action

public final void action(String originalOrder)
Sends the Clients order to the Object. If AbstractCommand cannot handle the event, it will send it on to the next AbstractCommand in the Chain.
If the AbstractCommand can handle the event, the first word of the command is removed, and the remainder is send on to the abstract method carryOut(String order).

Parameters:
originalOrder - client order (fx. cwd)

countUp

protected int countUp()
               throws NullPointerException
NullPointerException

sort

public final AbstractCommand sort()

equals

public boolean equals(Object o)
Overrides:
equals in class Object

compareTo

public int compareTo(Object o1)
Specified by:
compareTo in interface Comparable

start

protected void start()
Empty method that can be overridden, and is called at instantiation time.


build

public final void build(Session ses,
                        Command command)
Is used to build up the chain.

Parameters:
ses - the session that this chain represents
command - the command object, that is used to communicate with the client.

addCommandLast

public final void addCommandLast(AbstractCommand command)
Adds a command as the second last commmand.

Parameters:
command - the new AbstractCommand to add to the chain

makeFileOfOrder

protected File makeFileOfOrder(String order)
Makes a file of an order.

Parameters:
order - a filename (example.txt)
Returns:
a File Object with the absolutePath to the file.

fileToSystem

protected String fileToSystem(File f)
Takes a file, and prints it in the correct way (Windows vs Unix)

Parameters:
f - File
Returns:
Output

toString

public String toString()
Prints a comma seperated list of the the names in the Chain-of-responsibillity, from this AbstactCommand and forward.

Overrides:
toString in class Object
Returns:
String...

FTP-Server API