net.sf.hermesftp.cmd
Class AbstractFtpCmd

java.lang.Object
  extended by net.sf.hermesftp.cmd.AbstractFtpCmd
All Implemented Interfaces:
java.lang.Cloneable, FtpCmd, FtpConstants
Direct Known Subclasses:
AbstractFtpCmdList, AbstractFtpCmdPasv, AbstractFtpCmdPort, AbstractFtpCmdRetr, AbstractFtpCmdStor, FtpCmdAbor, FtpCmdAllo, FtpCmdAuth, FtpCmdCdup, FtpCmdClnt, FtpCmdCwd, FtpCmdDele, FtpCmdFeat, FtpCmdHelp, FtpCmdMdtm, FtpCmdMkd, FtpCmdMode, FtpCmdNoop, FtpCmdNotImpl, FtpCmdOpts, FtpCmdPass, FtpCmdPbsz, FtpCmdProt, FtpCmdPwd, FtpCmdQuit, FtpCmdRest, FtpCmdRmd, FtpCmdRnfr, FtpCmdRnto, FtpCmdSize, FtpCmdStat, FtpCmdStru, FtpCmdSyst, FtpCmdType, FtpCmdUser

public abstract class AbstractFtpCmd
extends java.lang.Object
implements FtpCmd, FtpConstants

Abstract ancestor of FTP command classes that provides some functionallity shared by different command classes.

Author:
Lars Behnke

Field Summary
 
Fields inherited from interface net.sf.hermesftp.common.FtpConstants
ATTR_CLIENT_NAME, ATTR_DATA_PROT, ATTR_FILE_OFFSET, ATTR_FORCE_UTF8, ATTR_GROUP_DATA, ATTR_LOGIN_TIME, ATTR_RENAME_FILE, ATTR_RESTART_MARKERS, ATTR_SSL, ATTR_USER_DATA, BYTE_LENGTH, BYTE_MASK, DEFAULT_BEAN_RES, DEFAULT_KEYSTORE, DEFAULT_KEYSTORE_PASS, DT_ASCII, DT_BINARY, DT_EBCDIC, HERMES_HOME, MILLI, MODE_BLOCK, MODE_COMPRESS, MODE_STREAM, MODE_ZIP, MSG_GOODBYE, MSG150, MSG200, MSG200_NOTED, MSG200_PBSZ, MSG200_SIZE, MSG200_TYPE, MSG202, MSG211_FEAT_ENTRY, MSG211_FEAT_FOOTER, MSG211_FEAT_HEADER, MSG211_STAT, MSG213_SIZE, MSG213_TIME, MSG214, MSG220, MSG220_WEL, MSG226, MSG227, MSG229, MSG230, MSG234, MSG250, MSG257, MSG331, MSG350, MSG350_REST, MSG421, MSG425, MSG426, MSG431, MSG450, MSG451, MSG500, MSG500_CMD, MSG501, MSG501_PATH, MSG501_SIZE, MSG503, MSG503_USR, MSG504, MSG522, MSG530, MSG530_AUTH, MSG534, MSG536, MSG550, MSG550_COMM, MSG550_EXISTS, MSG550_MSG, MSG550_NOTEMPTY, MSG550_PERM, MSG553, OPT_ALLOWED_PASSIVE_PORTS, OPT_BUFFER_SIZE, OPT_CHARSET_ASCII, OPT_CHARSET_EBCDIC, OPT_EMULATE_UNIX, OPT_FTP_PORT, OPT_IPV4_BLACK_LIST, OPT_IPV6_BLACK_LIST, OPT_MAX_CONNECTIONS, OPT_MAX_DOWNLOAD_RATE, OPT_MAX_IDLE_SECONDS, OPT_MAX_UPLOAD_RATE, OPT_MSG_GOODBYE, OPT_MSG_WELCOME, OPT_REMOTE_DIR, OPT_SSL_ALLOW_EXPLICIT, OPT_SSL_ALLOW_IMPLICIT, OPT_SSL_CIPHER_SUITES, OPT_SSL_FORCE, OPT_SSL_KEYSTORE_FILE, OPT_SSL_KEYSTORE_PASS, OPT_SSL_PORT_IMPLICIT, PRIV_NONE, PRIV_READ, PRIV_READ_WRITE, PRIV_WRITE, PWD, SEPARATOR, SERVER_STATUS_HALTED, SERVER_STATUS_INIT, SERVER_STATUS_READY, SERVER_STATUS_UNDEF, SPACE, STAT_BYTES_DOWNLOADED, STAT_BYTES_UPLOADED, STAT_DOWNLOAD_RATE, STAT_FILES_DOWNLOADED, STAT_FILES_UPLOADED, STAT_UPLOAD_RATE, STRUCT_FILE, STRUCT_RECORD, TYPE_NAMES, WILDCARD
 
Constructor Summary
AbstractFtpCmd()
           
 
Method Summary
protected  java.lang.String getAbsPath(java.lang.String path)
          Returns the absolute path of the passed rel. path.
protected  long getAndResetFileOffset()
           
 java.lang.String getArguments()
          Returns the arguments previously passed to the instance.
 FtpSessionContext getCtx()
          Getter method for the java bean ctx.
protected  java.lang.String getPathArg()
          Returns a path argument.
 int getPermission()
          Gets the permission on the current path.
 java.lang.String getToken()
          Returns the command token.
 boolean handleAsyncCmd(java.lang.String req)
          Handles any request on the control connection that was sent while the current command is executed.
 boolean isResponded()
           
protected  java.lang.String msg(java.lang.String msgKey)
          Returns a message resource string.
protected  java.lang.String msg(java.lang.String msgKey, java.lang.Object[] args)
          Returns a message resource string.
protected  java.lang.String msg(java.lang.String msgKey, java.lang.String arg)
          Returns a message resource string.
protected  void msgOut(java.lang.String msgKey)
          Convenience method that prints out a message to the control channel..
protected  void msgOut(java.lang.String msgKey, java.lang.Object[] args)
          Writes the message identified by the passed key to the control stream.
protected  void msgOut(java.lang.String msgKey, java.lang.String argument)
          Convenience method that prints out a message to the control channel.
protected  void out(java.lang.String text)
          Writes out the response to a client command.
 void setArguments(java.lang.String args)
          Passes the optional command argument.
 void setCtx(FtpSessionContext ctx)
          Setter method for the java bean ctx.
 void setToken(java.lang.String token)
          Sets the command token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.hermesftp.cmd.FtpCmd
execute, getHelp, isAuthenticationRequired
 

Constructor Detail

AbstractFtpCmd

public AbstractFtpCmd()
Method Detail

msg

protected java.lang.String msg(java.lang.String msgKey,
                               java.lang.Object[] args)
Returns a message resource string.

Parameters:
msgKey - The message key.
args - The arguments.
Returns:
The message.

msg

protected java.lang.String msg(java.lang.String msgKey)
Returns a message resource string.

Parameters:
msgKey - The message key.
Returns:
The message.

msg

protected java.lang.String msg(java.lang.String msgKey,
                               java.lang.String arg)
Returns a message resource string.

Parameters:
msgKey - The message key.
arg - An single message argument.
Returns:
The message.

out

protected void out(java.lang.String text)
Writes out the response to a client command.

Parameters:
text - The response.

msgOut

protected void msgOut(java.lang.String msgKey,
                      java.lang.Object[] args)
Writes the message identified by the passed key to the control stream. If additional arguments are passed they are integrated into the message string.

Parameters:
msgKey - The message key as defined in the resource file.
args - The optional arguments.

msgOut

protected void msgOut(java.lang.String msgKey)
Convenience method that prints out a message to the control channel..

Parameters:
msgKey - The key of the message.

msgOut

protected void msgOut(java.lang.String msgKey,
                      java.lang.String argument)
Convenience method that prints out a message to the control channel.

Parameters:
msgKey - The key of the message.
argument - Text argument.

getPathArg

protected java.lang.String getPathArg()
Returns a path argument.

Returns:
The path

getAbsPath

protected java.lang.String getAbsPath(java.lang.String path)
Returns the absolute path of the passed rel. path.

Parameters:
path - The relative path;
Returns:
The absolute path

getAndResetFileOffset

protected long getAndResetFileOffset()
Returns:
Returns the file offset to be used, or null not offset defined.

setArguments

public void setArguments(java.lang.String args)
Passes the optional command argument.

Specified by:
setArguments in interface FtpCmd
Parameters:
args - The arguments as text

getArguments

public java.lang.String getArguments()
Returns the arguments previously passed to the instance.

Returns:
the command line arguments.

getCtx

public FtpSessionContext getCtx()
Getter method for the java bean ctx.

Returns:
Returns the value of the java bean ctx.

setCtx

public void setCtx(FtpSessionContext ctx)
Setter method for the java bean ctx.

Specified by:
setCtx in interface FtpCmd
Parameters:
ctx - The value of ctx to set.

getPermission

public int getPermission()
Gets the permission on the current path.

Returns:
The permission constant.

getToken

public java.lang.String getToken()
Returns the command token.

Specified by:
getToken in interface FtpCmd
Returns:
The command token.

setToken

public void setToken(java.lang.String token)
Sets the command token.

Specified by:
setToken in interface FtpCmd
Parameters:
token - The command token (e.g. STOR, RETR, ...)

isResponded

public boolean isResponded()
Returns:
True if response has been sent.

handleAsyncCmd

public boolean handleAsyncCmd(java.lang.String req)
Handles any request on the control connection that was sent while the current command is executed. For instance, while storing or retrieving the client may issue an abort or status command.

Specified by:
handleAsyncCmd in interface FtpCmd
Parameters:
req - The request that has to be handled.
Returns:
True is request was handled, otherwise false.


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.