wttools.protocols.ftp
Class ProtocolImpl
java.lang.Object
|
+--wttools.protocols.ftp.ProtocolImpl
- All Implemented Interfaces:
- ProtocolIfc
- public class ProtocolImpl
- extends java.lang.Object
- implements ProtocolIfc
Class FTPImpl implements
- Version:
- $Revision: 1.2 $
- Author:
- Artur Hefczyc
| Fields inherited from interface wttools.protocols.ifc.ProtocolIfc |
CODE_BAD_REQUEST, CODE_CONNECTION_ERROR, CODE_CONNECTION_OK, CODE_FORBIDDEN, CODE_HOST_NOT_FOUND, CODE_INTERNAL_SERVER_ERROR, CODE_LENGTH_REQUIRED, CODE_NETWORK_NOT_REACHABLE, CODE_NO_CONTENT, CODE_NOT_FOUND, CODE_NOT_INITIALIZED, CODE_PARTIAL_CONTENT, CODE_REDIRECT, CODE_REQUEST_TIMEOUT, CODE_SERVER_NOT_REACHABLE, CODE_UNAUTHORIZED, CODE_VERSION_NOT_SUPPORTED, METHOD_GET, METHOD_HEAD |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ftpImpl
protected ProtocolIfc ftpImpl
ProtocolImpl
public ProtocolImpl()
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
setURI
public void setURI(URI v)
throws java.io.IOException
setURI method performs
- Specified by:
setURI in interface ProtocolIfc
- Parameters:
v - an URI value- Throws:
java.io.IOException - if an error occurs
getProtocolType
public java.lang.String getProtocolType()
getProtocolType method performs
- Specified by:
getProtocolType in interface ProtocolIfc
- Returns:
- a
String value
getInputStream
public java.io.InputStream getInputStream()
throws java.io.IOException
- Get the value of
inputStream.
- Specified by:
getInputStream in interface ProtocolIfc
- Returns:
- value of
inputStream.
getConnectionResult
public int getConnectionResult()
throws java.io.IOException
getConnectionResult method performs
- Specified by:
getConnectionResult in interface ProtocolIfc
- Returns:
- an
int value - Throws:
java.io.IOException - if an error occurs
connect
public void connect()
throws java.io.IOException
connect method performs
- Specified by:
connect in interface ProtocolIfc
- Throws:
java.io.IOException - if an error occurs
disconnect
public void disconnect()
throws java.io.IOException
disconnect method performs
- Specified by:
disconnect in interface ProtocolIfc
- Throws:
java.io.IOException - if an error occurs
getConnectionInfo
public java.lang.Object getConnectionInfo()
getConnectionInfo method performs
- Specified by:
getConnectionInfo in interface ProtocolIfc
- Returns:
getConnectionStatuses
public java.util.List getConnectionStatuses()
getConnectionStatuses method performs
- Specified by:
getConnectionStatuses in interface ProtocolIfc
- Returns:
getContentType
public java.lang.String getContentType()
throws java.io.IOException
getContentType method performs
- Specified by:
getContentType in interface ProtocolIfc
- Returns:
- a
String value
getContentLength
public long getContentLength()
throws java.io.IOException
getContentLength method performs
- Specified by:
getContentLength in interface ProtocolIfc
- Returns:
- a
long value
getServerId
public java.lang.String getServerId()
throws java.io.IOException
getServerId method performs
- Specified by:
getServerId in interface ProtocolIfc
- Returns:
- a
String value
getHeaderStrValue
public java.lang.String getHeaderStrValue(java.lang.String header_key)
throws java.io.IOException
getHeaderStrValue method performs
- Specified by:
getHeaderStrValue in interface ProtocolIfc
- Parameters:
header_key - a String value- Returns:
- a
String value
getHeaderIntValue
public long getHeaderIntValue(java.lang.String header_key)
throws java.io.IOException
getHeaderIntValue method performs
- Specified by:
getHeaderIntValue in interface ProtocolIfc
- Parameters:
header_key - a String value- Returns:
- a
long value
getAllHeaders
public java.util.HashMap getAllHeaders()
throws java.io.IOException
getAllHeaders method performs
- Specified by:
getAllHeaders in interface ProtocolIfc
- Returns:
- a
HashMap value
getTransferSpeed
public float getTransferSpeed()
getTransferSpeed method performs
- Specified by:
getTransferSpeed in interface ProtocolIfc
- Returns:
- a
float value
getURI
public URI getURI()
- Description copied from interface:
ProtocolIfc
getURI method returns URI for
which performing connection.
- Specified by:
getURI in interface ProtocolIfc
- Returns:
setClientId
public void setClientId(java.lang.String param1)
- Description copied from interface:
ProtocolIfc
setClientId method sets client identification
string. I don't know if it make sense but there is
"User-Aget" header in HTTP protocol
there which client sends to HTTP server.
- Specified by:
setClientId in interface ProtocolIfc
- Parameters:
param1 -
getClientId
public java.lang.String getClientId()
- Description copied from interface:
ProtocolIfc
getClientId method returns client identification
string which it sends to web sever during connection. In
HTTP protocol it is value of "User-Agent"
header.
- Specified by:
getClientId in interface ProtocolIfc
- Returns:
setStreamReadTimeout
public void setStreamReadTimeout(int param1)
- Description copied from interface:
ProtocolIfc
setStreamReadTimeout method sets timeout for reading
from input stream taken from socket. When some communication
problem occures during perfmorming data transmision application
may infinitely wait for data which will never arrive. To prevent
such situation you can set stream read timeout to ensure waiting
for data no longer than you expect. If set to 0 it means turn off
timeout and allow infinite reading.
- Specified by:
setStreamReadTimeout in interface ProtocolIfc
- Parameters:
param1 -
getStreamReadTimeout
public int getStreamReadTimeout()
- Description copied from interface:
ProtocolIfc
getStreamReadTimeout method returns value of stream
read timeout.
- Specified by:
getStreamReadTimeout in interface ProtocolIfc
- Returns:
setInputBufferSize
public void setInputBufferSize(int param1)
- Description copied from interface:
ProtocolIfc
setInputBufferSize method InputStream
returns data in packets. With this method you can sets size of
this packet. The smaller size of packet should be used if there
are some transmision problems and bigger size should be used if
we use network with very good bandwich to improve transmision
efficiency.
- Specified by:
setInputBufferSize in interface ProtocolIfc
- Parameters:
param1 -
getInputBufferSize
public int getInputBufferSize()
- Description copied from interface:
ProtocolIfc
getInputBufferSize method returns input buffer size
which is set for this protocol.
- Specified by:
getInputBufferSize in interface ProtocolIfc
- Returns:
setKeepAlive
public void setKeepAlive(boolean param1)
- Description copied from interface:
ProtocolIfc
setKeepAlive method sets keepAlive
variable. This variable determines keeping connection to web
server after completing user request. If we know that we want
reach only one resource from thet web server we can set
keepAlive to false and protocol
implementation should disconnect after finishing transmision.
But very often we want to download many files from web server
for example from FTP or HTTP server.
It is not effective to reconnection every time. It is better
to keep alive connection between downloading every file.
For example suppose we have to download 10 files from
HTTP server. Each file is about 10kB size.
So downloading each of them with good internet connection takes about
1 sec. But establishing connection takes from 1 sec to 30 sec.
Lets suppose that it takes about 10 sec. So we can see how much time
we can save with using keep alive connections.
- Specified by:
setKeepAlive in interface ProtocolIfc
- Parameters:
param1 -
isKeepAlive
public boolean isKeepAlive()
- Description copied from interface:
ProtocolIfc
getKeepAlive method returns value of keepAlive
field. keepAlive field switches between permaneent connection
mode and single transfer connection mode. Permanent connection mode
should allow to transfer many files with one persistent connection
to server.
- Specified by:
isKeepAlive in interface ProtocolIfc
- Returns:
saveContent
public void saveContent(java.lang.String param1)
throws java.io.IOException
- Description copied from interface:
ProtocolIfc
saveContent method performs saving resource data
to given disk file. I have doubt what mean resource data.
In general we can divide resource info on resource headers
and resource data. It is very usefull if we think about
HTTP resources. But if we think about mail message
headers are almost as important as message data. So in particular
protocol implementation headers should be joined with data.
- Specified by:
saveContent in interface ProtocolIfc
- Parameters:
param1 - - Throws:
java.io.IOException -
saveContent
public void saveContent(java.io.OutputStream param1)
throws java.io.IOException
- Description copied from interface:
ProtocolIfc
saveContent method performs saving resource data
to given OutputStream. This method does not open
nor close given stream. Closing stream should be performed by
user.
- Specified by:
saveContent in interface ProtocolIfc
- Parameters:
param1 - - Throws:
java.io.IOException -
getRealContentSize
public long getRealContentSize()
- Description copied from interface:
ProtocolIfc
getRealContentSize method returns received size of data. First of all
if undetected network error occurs we can recieve less data that we expect. So during
verification we can check if expected data size is equal to received. Second
if web server don't send expected data size then with this method we can know
how many bytes were received.
- Specified by:
getRealContentSize in interface ProtocolIfc
- Returns:
setUserName
public void setUserName(java.lang.String param1)
- Description copied from interface:
ProtocolIfc
setUserName method sets user name for authorization.
in general user name and pasword should be encoded in url with the form:
http://user:passwd@www.sf.net:8000/path/file.html
but sometimes it isn't possible to put user name and password in url and then
you can set them with these methods.
- Specified by:
setUserName in interface ProtocolIfc
- Parameters:
param1 -
getUserName
public java.lang.String getUserName()
- Description copied from interface:
ProtocolIfc
getUserName method returns user name used during authorization process.
User name can be taken from URI or from data received in setUserName(Strin name)
method.
- Specified by:
getUserName in interface ProtocolIfc
- Returns:
setUserPassword
public void setUserPassword(java.lang.String param1)
- Description copied from interface:
ProtocolIfc
setUserPassword method sets user password dor authorization.
in general user name and pasword should be encoded in url with the form:
http://user:passwd@www.sf.net:8000/path/file.html
but sometimes it isn't possible to put user name and password in url and then
you can set them with these methods.
- Specified by:
setUserPassword in interface ProtocolIfc
- Parameters:
param1 -
getUserPassword
public java.lang.String getUserPassword()
- Description copied from interface:
ProtocolIfc
getUserPassword method returns user password used during authorization process.
User name can be taken from URI or from data received in setUserName(Strin name)
method.
- Specified by:
getUserPassword in interface ProtocolIfc
- Returns:
setDebug
public void setDebug(boolean param1)
- Description copied from interface:
ProtocolIfc
- Method
setDebug sets debug mode.
- Specified by:
setDebug in interface ProtocolIfc
- Parameters:
param1 -
isDebug
public boolean isDebug()
- Specified by:
isDebug in interface ProtocolIfc
- Returns:
setAllowUserInteraction
public void setAllowUserInteraction(boolean allow)
- Specified by:
setAllowUserInteraction in interface ProtocolIfc
isAllowUserInteraction
public boolean isAllowUserInteraction()
- Specified by:
isAllowUserInteraction in interface ProtocolIfc
setAllowAllCookies
public void setAllowAllCookies(boolean allow)
- Specified by:
setAllowAllCookies in interface ProtocolIfc
isAllowAllCookies
public boolean isAllowAllCookies()
- Specified by:
isAllowAllCookies in interface ProtocolIfc
setRequestData
public void setRequestData(java.lang.String data)
- Specified by:
setRequestData in interface ProtocolIfc
getRequestData
public java.lang.String getRequestData()
- Specified by:
getRequestData in interface ProtocolIfc
isErrorRecoverable
public boolean isErrorRecoverable(int code)
- Description copied from interface:
ProtocolIfc
- This method
isErrorRecoverable should be able to return
info if given error code is permanent or not. I mean for example if
error code means "Page not found" it mean that there is no page
under requested URL. It is most probably permanent error. However
if error code means "Network not reachable" or
"Request timeout" it mean that in future during next try download
may be successful.
- Specified by:
isErrorRecoverable in interface ProtocolIfc
- Following copied from interface:
wttools.protocols.ifc.ProtocolIfc
- Parameters:
code - an int value of requested error code.- Returns:
- a
boolean calculated value of recoverability of error.
getContentData
public byte[] getContentData()
throws java.io.IOException
- Specified by:
getContentData in interface ProtocolIfc
setAllowRedirect
public void setAllowRedirect(boolean redirect)
- Specified by:
setAllowRedirect in interface ProtocolIfc
isAllowRedirect
public boolean isAllowRedirect()
- Specified by:
isAllowRedirect in interface ProtocolIfc
getEffectiveURI
public URI getEffectiveURI()
throws java.io.IOException
- Description copied from interface:
ProtocolIfc
getEffectiveURI returns effective uri of requested
resource. If during connecting to web server redirection response
occurs it means that effective URI is different then original.
- Specified by:
getEffectiveURI in interface ProtocolIfc
- Following copied from interface:
wttools.protocols.ifc.ProtocolIfc
- Returns:
- an
URI value of effective resource URI.
Copyright © GNU, wttools developers Team.