public class FileRetrCommandHandler extends AbstractStubDataCommandHandler implements CommandHandler
The file
property specifies the pathname for the file whose contents should
be returned from this command. The file path is relative to the CLASSPATH (using the
ClassLoader for this class).
An exception is thrown if the file
property has not been set or if the specified
file does not exist or cannot be read.
Each invocation record stored by this CommandHandler includes the following data element key/values:
PATHNAME_KEY
("pathname") - the pathname of the file submitted on the invocation (the first command parameter)
Modifier and Type | Field and Description |
---|---|
static String |
PATHNAME_KEY |
finalReplyCode, finalReplyMessageKey, finalReplyText, preliminaryReplyCode, preliminaryReplyMessageKey, preliminaryReplyText
LOG
Constructor and Description |
---|
FileRetrCommandHandler()
Create new uninitialized instance
|
FileRetrCommandHandler(String file)
Create new instance using the specified file pathname
|
Modifier and Type | Method and Description |
---|---|
protected void |
beforeProcessData(Command command,
Session session,
InvocationRecord invocationRecord)
Perform any necessary logic before transferring data across the data connection.
|
protected void |
processData(Command command,
Session session,
InvocationRecord invocationRecord)
Abstract method placeholder for subclass transfer of data across the data connection.
|
void |
setFile(String file)
Set the path of the file whose contents should be returned when this command is
invoked.
|
afterProcessData, handleCommand, sendFinalReply, setFinalReplyCode, setFinalReplyMessageKey, setFinalReplyText, setPreliminaryReplyCode, setPreliminaryReplyMessageKey, setPreliminaryReplyText
clearInvocations, getInvocation, handleCommand, numberOfInvocations, sendReply
assertValidReplyCode, getReplyTextBundle, quotes, setReplyTextBundle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleCommand
public static final String PATHNAME_KEY
public FileRetrCommandHandler()
public FileRetrCommandHandler(String file)
file
- - the path to the fileAssertFailedException
- - if the file is nullprotected void beforeProcessData(Command command, Session session, InvocationRecord invocationRecord) throws Exception
AbstractStubDataCommandHandler
beforeProcessData
in class AbstractStubDataCommandHandler
command
- - the Command to be handledsession
- - the session on which the Command was submittedinvocationRecord
- - the InvocationRecord; CommandHandlers are expected to add
handler-specific data to the InvocationRecord, as appropriateException
- - if an error occursAbstractStubDataCommandHandler.beforeProcessData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
protected void processData(Command command, Session session, InvocationRecord invocationRecord)
AbstractStubDataCommandHandler
processData
in class AbstractStubDataCommandHandler
command
- - the Command to be handledsession
- - the session on which the Command was submittedinvocationRecord
- - the InvocationRecord; CommandHandlers are expected to add
handler-specific data to the InvocationRecord, as appropriateAbstractStubDataCommandHandler.processData(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
public void setFile(String file)
file
- - the path to the fileAssertFailedException
- - if the file is nullCopyright © 2016. All rights reserved.