wttools.protocols
Class AbstractProtocol

java.lang.Object
  |
  +--wttools.protocols.AbstractProtocol
All Implemented Interfaces:
ProtocolIfc
Direct Known Subclasses:
ProtocolImpl, ProtocolImpl, ProtocolImpl, ProtocolImpl, ProtocolImpl

public abstract class AbstractProtocol
extends java.lang.Object
implements ProtocolIfc

Class AbstractProtocol implements

Version:
$Revision: 1.10 $
Author:
Artur Hefczyc

Field Summary
protected  boolean allowAllCookies
           
protected  boolean allowRedirect
           
protected  boolean allowUserInteraction
           
protected  long bytesDownloaded
           
protected  java.lang.String clientId
           
protected  boolean debug
           
protected  int inputBufferSize
           
protected  boolean keepAlive
           
protected  java.lang.String requestData
           
protected  int streamReadTimeout
           
protected  URI uri
          variable uri contains value of
protected  java.lang.String userName
          variable userName contains value of
protected  java.lang.String userPassword
          variable userPassword contains value of
 
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
 
Constructor Summary
AbstractProtocol()
           
 
Method Summary
protected  void deb(java.lang.String str)
          deb method performs
 java.lang.String getClientId()
          Get the value of clientId.
 byte[] getContentData()
           
 long getHeaderIntValue(java.lang.String param1)
          Method getHeaderStrValue returns header value as long integer for given header name.
 int getInputBufferSize()
          Get the value of inputBufferSize.
 long getRealContentSize()
          getRealContentSize method performs
 java.lang.String getRequestData()
          Get the value of requestData.
 int getStreamReadTimeout()
          Get the value of streamReadTimeout.
 URI getURI()
          Get the value of uri.
 java.lang.String getUserName()
          Get the value of userName.
 java.lang.String getUserPassword()
          Get the value of userPassword.
 boolean isAllowAllCookies()
           
 boolean isAllowRedirect()
           
 boolean isAllowUserInteraction()
           
 boolean isDebug()
          Get the value of debug.
 boolean isErrorRecoverable(int code)
          This method isErrorRecoverable should be able to return info if given error code is permanent or not.
 boolean isKeepAlive()
          Get the value of keepAlive.
 void saveContent(java.io.OutputStream out_stream)
          saveContent method performs
 void saveContent(java.lang.String file_name)
          saveContent method performs
 void setAllowAllCookies(boolean allow)
           
 void setAllowRedirect(boolean redirect)
           
 void setAllowUserInteraction(boolean allow)
           
 void setClientId(java.lang.String v)
          Set the value of clientId.
 void setDebug(boolean v)
          Set the value of debug.
 void setInputBufferSize(int v)
          Set the value of inputBufferSize.
 void setKeepAlive(boolean v)
          Set the value of keepAlive.
 void setRequestData(java.lang.String v)
          Set the value of requestData.
 void setStreamReadTimeout(int v)
          Set the value of streamReadTimeout.
 void setURI(URI v)
          Set the value of uri.
 void setUserName(java.lang.String v)
          Set the value of userName.
 void setUserPassword(java.lang.String v)
          Set the value of userPassword.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wttools.protocols.ifc.ProtocolIfc
connect, disconnect, getAllHeaders, getConnectionInfo, getConnectionResult, getConnectionStatuses, getContentLength, getContentType, getEffectiveURI, getHeaderStrValue, getInputStream, getProtocolType, getServerId, getTransferSpeed
 

Field Detail

uri

protected URI uri
variable uri contains value of

userName

protected java.lang.String userName
variable userName contains value of

userPassword

protected java.lang.String userPassword
variable userPassword contains value of

clientId

protected java.lang.String clientId

requestData

protected java.lang.String requestData

keepAlive

protected boolean keepAlive

debug

protected boolean debug

allowUserInteraction

protected boolean allowUserInteraction

allowAllCookies

protected boolean allowAllCookies

allowRedirect

protected boolean allowRedirect

inputBufferSize

protected int inputBufferSize

streamReadTimeout

protected int streamReadTimeout

bytesDownloaded

protected long bytesDownloaded
Constructor Detail

AbstractProtocol

public AbstractProtocol()
Method Detail

setAllowRedirect

public void setAllowRedirect(boolean redirect)
Specified by:
setAllowRedirect in interface ProtocolIfc

isAllowRedirect

public boolean isAllowRedirect()
Specified by:
isAllowRedirect in interface ProtocolIfc

getRequestData

public java.lang.String getRequestData()
Get the value of requestData.
Specified by:
getRequestData in interface ProtocolIfc
Returns:
value of requestData.

setRequestData

public void setRequestData(java.lang.String v)
Set the value of requestData.
Specified by:
setRequestData in interface ProtocolIfc
Parameters:
v - Value to assign to requestData.

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

isDebug

public boolean isDebug()
Get the value of debug.
Specified by:
isDebug in interface ProtocolIfc
Returns:
value of debug.

setDebug

public void setDebug(boolean v)
Set the value of debug.
Specified by:
setDebug in interface ProtocolIfc
Parameters:
v - Value to assign to debug.

getUserPassword

public java.lang.String getUserPassword()
Get the value of userPassword.
Specified by:
getUserPassword in interface ProtocolIfc
Returns:
value of userPassword.

setUserPassword

public void setUserPassword(java.lang.String v)
Set the value of userPassword.
Specified by:
setUserPassword in interface ProtocolIfc
Parameters:
v - Value to assign to userPassword.

getUserName

public java.lang.String getUserName()
Get the value of userName.
Specified by:
getUserName in interface ProtocolIfc
Returns:
value of userName.

setUserName

public void setUserName(java.lang.String v)
Set the value of userName.
Specified by:
setUserName in interface ProtocolIfc
Parameters:
v - Value to assign to userName.

isKeepAlive

public boolean isKeepAlive()
Get the value of keepAlive.
Specified by:
isKeepAlive in interface ProtocolIfc
Returns:
value of keepAlive.

setKeepAlive

public void setKeepAlive(boolean v)
Set the value of keepAlive.
Specified by:
setKeepAlive in interface ProtocolIfc
Parameters:
v - Value to assign to keepAlive.

getInputBufferSize

public int getInputBufferSize()
Get the value of inputBufferSize.
Specified by:
getInputBufferSize in interface ProtocolIfc
Returns:
value of inputBufferSize.

setInputBufferSize

public void setInputBufferSize(int v)
Set the value of inputBufferSize.
Specified by:
setInputBufferSize in interface ProtocolIfc
Parameters:
v - Value to assign to inputBufferSize.

getStreamReadTimeout

public int getStreamReadTimeout()
Get the value of streamReadTimeout.
Specified by:
getStreamReadTimeout in interface ProtocolIfc
Returns:
value of streamReadTimeout.

setStreamReadTimeout

public void setStreamReadTimeout(int v)
Set the value of streamReadTimeout.
Specified by:
setStreamReadTimeout in interface ProtocolIfc
Parameters:
v - Value to assign to streamReadTimeout.

getClientId

public java.lang.String getClientId()
Get the value of clientId.
Specified by:
getClientId in interface ProtocolIfc
Returns:
value of clientId.

setClientId

public void setClientId(java.lang.String v)
Set the value of clientId.
Specified by:
setClientId in interface ProtocolIfc
Parameters:
v - Value to assign to clientId.

getURI

public URI getURI()
Get the value of uri.
Specified by:
getURI in interface ProtocolIfc
Returns:
value of uri.

setURI

public void setURI(URI v)
            throws java.io.IOException
Set the value of uri.
Specified by:
setURI in interface ProtocolIfc
Parameters:
v - Value to assign to uri.
Throws:
java.io.IOException - if an error occurs

getRealContentSize

public long getRealContentSize()
getRealContentSize method performs
Specified by:
getRealContentSize in interface ProtocolIfc
Returns:
a long value

saveContent

public void saveContent(java.lang.String file_name)
                 throws java.io.IOException
saveContent method performs
Specified by:
saveContent in interface ProtocolIfc
Parameters:
file_name - a String value
Throws:
java.io.IOException - if an error occurs

saveContent

public void saveContent(java.io.OutputStream out_stream)
                 throws java.io.IOException
saveContent method performs
Specified by:
saveContent in interface ProtocolIfc
Parameters:
out_stream - an OutputStream value
Throws:
java.io.IOException - if an error occurs

getContentData

public byte[] getContentData()
                      throws java.io.IOException
Specified by:
getContentData in interface ProtocolIfc

getHeaderIntValue

public long getHeaderIntValue(java.lang.String param1)
                       throws java.io.IOException
Description copied from interface: ProtocolIfc
Method getHeaderStrValue returns header value as long integer for given header name.
Specified by:
getHeaderIntValue in interface ProtocolIfc
Parameters:
param1 -
Returns:

deb

protected void deb(java.lang.String str)
deb method performs
Parameters:
str - a String value

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.


Copyright GNU, wttools developers Team.