|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.glub.secureftp.bean.FTPCommand
public class FTPCommand
The FTPCommand
class is responsible for handling the standard
commands used in the File Transfer Protocol.
Constructor Summary | |
---|---|
FTPCommand(BufferedReader reader,
PrintWriter writer)
Create a new FTPCommand object. |
|
FTPCommand(BufferedReader reader,
PrintWriter writer,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new FTPCommand object. |
Method Summary | |
---|---|
void |
abort(FTPData data)
Abort a data transfer. |
void |
acct(String account)
Specify the account name to the FTP server. |
void |
append(String file,
FTPData data)
Append to a file on the FTP server. |
void |
cdup()
Move up one directory on the FTP server. |
void |
chdir(String dir)
Change remote directory on the FTP server. |
void |
delete(String filename)
Delete a file from the FTP server. |
void |
forcePasvToUseControlIP(boolean on)
Forces passive data transfers to use the control socket IP address. |
String |
getReply()
Get the last full reply from the FTP server. |
int |
getReplyCode()
Get the last reply code from the FTP server. |
String |
getReplyMessage()
Get the last reply message from the FTP server. |
String |
help(String item)
Get help from the FTP server. |
void |
list(String itemsToList,
FTPData data,
boolean showHidden)
List files in a directory on the FTP server. |
Date |
mdtm(String file)
Get the modification time of a file on the FTP server. |
void |
mkdir(String dir)
Make a directory on the FTP server. |
void |
modeZ()
Mode Z compression |
void |
nlst(String itemsToList,
FTPData data)
NList files in a directory on the FTP server. |
void |
noop()
Send a noop to the FTP server. |
void |
pass(String password)
Specify the password for logging in to the FTP server. |
HostInfo |
pasv()
Request a PASV data transfer from the FTP server. |
void |
port(HostInfo hostInfo)
Request a PORT data transfer from the FTP server. |
String |
pwd()
Get the working directory on the FTP server. |
void |
quit()
Quit the FTP session. |
void |
raw(String rawCmd)
Send a raw command to the FTP server. |
protected void |
recvCmd()
Receive the message back from the FTP server. |
void |
rename(String from,
String to)
Rename a file on the FTP server. |
void |
rest(long byteOffset)
Restart an incomplete file transfer. |
void |
retrieve(String file,
FTPData data)
Retrieve a file from the FTP server. |
void |
rmdir(String dir)
Remove a directory from the FTP server. |
protected void |
sendCmd(String cmd)
Send a command to the FTP server. |
protected void |
sendCmd(String cmd,
String cmdMask)
Send a command to the FTP server with command masking for client reporting. |
void |
setControlIP(String ip)
Sets the control channel IP address. |
void |
setRecvCmdStream(OutputStream recvCmdStream)
Set the stream responsible for getting replies from the FTP server. |
void |
setSendCmdStream(OutputStream sendCmdStream)
Set the stream responsible for getting commands sent to the FTP server. |
long |
size(String filename)
Get the size of a file from the FTP server. |
void |
store(String file,
FTPData data)
Store a file on the FTP server. |
String |
syst()
Get system information from the FTP server. |
void |
type(char t)
Set the type of transfer. |
void |
user(String username)
Specify the username for logging in to the FTP server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FTPCommand(BufferedReader reader, PrintWriter writer)
FTPCommand
object.
reader
- based on the input stream from the control socket.writer
- based on the output stream from the control socket.public FTPCommand(BufferedReader reader, PrintWriter writer, OutputStream sendCmdStream, OutputStream recvCmdStream)
FTPCommand
object.
reader
- based on the input stream from the control socket.writer
- based on the output stream from the control socket.sendCmdStream
- stream used to report commands set to the FTP server.recvCmdStream
- stream used to report commands received from the
FTP server.Method Detail |
---|
public void setRecvCmdStream(OutputStream recvCmdStream)
recvCmdStream
- the stream used to get replies from the FTP server.public void setSendCmdStream(OutputStream sendCmdStream)
sendCmdStream
- the stream used to get the commands sent to
the FTP server.public void user(String username) throws FTPNeedPasswordException, FTPNeedAccountException, FTPBadLoginException, FTPException, IllegalArgumentException
username
- name of the user attempting to login.
FTPNeedPasswordException
- if a password is required for login.
FTPNeedAccountException
- if account name is required for login.
FTPBadLoginException
- if login is denied.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if username
is missing.public void pass(String password) throws FTPNeedAccountException, FTPBadLoginException, FTPException, IllegalArgumentException
password
- password for the user attempting to login
FTPNeedAccountException
- if account name is required for login.
FTPBadLoginException
- if login is denied.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if username
is missing.public void acct(String account) throws FTPBadLoginException, FTPException, IllegalArgumentException
account
- account name for the user attempting to login
FTPBadLoginException
- if login is denied.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if username
is missing.public void quit() throws FTPException
FTPException
- if the FTP server returns an error code.public String syst() throws FTPException
FTPException
- if the FTP server returns an error code.public void delete(String filename) throws FTPException, IllegalArgumentException
filename
- name of the file to delete.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if filename
is missing.public void rename(String from, String to) throws FTPException, IllegalArgumentException
from
- existing name of the file.to
- new name for the file.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if either from
or
to
is missing.public void mkdir(String dir) throws FTPException, FTPAccessDeniedException, IllegalArgumentException
dir
- new directory name.
FTPAccessDeniedException
- if the directory couldn't be created
due to access restrictions.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if dir
is missing.public void rmdir(String dir) throws FTPException, IllegalArgumentException
dir
- new directory name.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if dir
is missing.public void rest(long byteOffset) throws FTPException
byteOffset
- the amount of bytes to seek into the restore.
FTPException
- if the FTP server returns an error code.public Date mdtm(String file) throws FTPNoSuchFileException, FTPException, IllegalArgumentException
file
- the name of the file.
null
if the time could not be
determined.
FTPNoSuchFileException
- if filename
does not exist.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if file
is missing.public void chdir(String dir) throws FTPNotADirectoryException, FTPNoSuchFileException, FTPException, IllegalArgumentException
dir
- the directory name.
FTPNotADirectoryException
- if dir
is not a directory.
FTPNoSuchFileException
- if dir
does not exist.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if dir
is missing.public void cdup() throws FTPException
FTPException
- if the FTP server returns an error code.public String pwd() throws FTPException
FTPException
- if the FTP server returns an error code.public void abort(FTPData data) throws FTPException, IllegalArgumentException
This method is not synchronized since abort may need to interrupt another method executing on the same object.
data
- an Object that implements the FTPData interface.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if data
is missing.public void retrieve(String file, FTPData data) throws FTPException, IOException, IllegalArgumentException
file
- name of the file.data
- an Object that implements the FTPData interface.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
IllegalArgumentException
- if either file
or
data
is missing.public void store(String file, FTPData data) throws FTPException, IOException, IllegalArgumentException
file
- name of the file.data
- an Object that implements the FTPData interface.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
IllegalArgumentException
- if either file
or
data
is missing.public void append(String file, FTPData data) throws FTPException, IOException, IllegalArgumentException
file
- name of the file.data
- an Object that implements the FTPData interface.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
IllegalArgumentException
- if either file
or
data
is missing.public void type(char t) throws FTPException
t
- the transfer type ('A' = ascii, 'I' = binary image).
FTPException
- if the FTP server returns an error code.public void modeZ() throws FTPException
FTPException
- if the FTP server returns an error code.public long size(String filename) throws FTPNoSuchFileException, FTPException, IllegalArgumentException
filename
- name of the file.
FTPNoSuchFileException
- if filename
does not exist.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if filename
is missing.public void list(String itemsToList, FTPData data, boolean showHidden) throws FTPException, IOException, IllegalArgumentException
itemsToList
- the items to list.data
- an Object that implements the FTPData interface.showHidden
- flag to show hidden files (subject to availibility)
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
IllegalArgumentException
- if data
is missing.public void nlst(String itemsToList, FTPData data) throws FTPException, IOException, IllegalArgumentException
itemsToList
- the items to list.data
- an Object that implements the FTPData interface.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
IllegalArgumentException
- if data
is missing.public void port(HostInfo hostInfo) throws FTPException, IllegalArgumentException
hostInfo
- HostInfo for the local listening socket.
FTPException
- if the FTP server returns an error code.
IllegalArgumentException
- if hostInfo is nullpublic HostInfo pasv() throws FTPException
FTPException
- if the FTP server returns an error code.public String help(String item) throws FTPException
item
- item to get help on from server
FTPException
- if the FTP server returns an error code.public void raw(String rawCmd) throws FTPException
rawCmd
- command to send to the server
FTPException
- if the FTP server returns an error code.public void noop() throws FTPException
FTPException
- if the FTP server returns an error code.public String getReply()
public int getReplyCode()
public String getReplyMessage()
protected void sendCmd(String cmd) throws FTPException
cmd
- the command to send to the FTP server.
FTPException
- if the FTP server returns an error code.protected void sendCmd(String cmd, String cmdMask) throws FTPException
cmd
- the command to send to the FTP server.cmdMask
- the command mask that will be returned to the client.
FTPException
- if the FTP server returns an error code.protected void recvCmd() throws FTPException
FTPException
- if the FTP server returns an error code.public void forcePasvToUseControlIP(boolean on)
on
- true if to use control socket IP, false if off.public void setControlIP(String ip)
ip
- the control socket IPforcePasvToUseControlIP(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |