org.w3c.jwput
Class JW

java.lang.Object
  |
  +--org.w3c.jwput.JW
All Implemented Interfaces:
JWOptions, org.w3c.www.protocol.http.RequestObserver
Direct Known Subclasses:
JWGet, JWPut

public class JW
extends java.lang.Object
implements org.w3c.www.protocol.http.RequestObserver, JWOptions

JW allows the user to perform HTTP requests


Field Summary
protected  boolean aborted
           
static java.lang.String BANNER
          BANNER
static java.lang.String DEFAULT_MIME
          Default mime type
protected  boolean done
           
protected  ETagsDatabase etagsDB
           
protected  java.io.LineNumberReader in
           
protected  java.util.Properties jwprops
           
protected  java.util.Vector listeners
           
protected  org.w3c.www.protocol.http.HttpManager manager
           
protected  java.lang.String password
           
protected  java.lang.String ppassword
           
protected  boolean prompt
           
protected  java.lang.String puser
           
protected  boolean quiet
           
protected  org.w3c.www.protocol.http.Request request
           
protected  JWUI ui
           
protected  java.util.Hashtable uriInfos
           
protected  java.lang.String user
           
static java.lang.String USER_AGENT
          USER_AGENT HEADER
protected  boolean verbose
           
static java.lang.String VERSION
          Software version
static java.lang.String WINIE_DOC_URL
          Documentation URL
static java.lang.String WINIE_LATEST_ZIP
          Latest distribution URL
static java.lang.String WINIE_URL
          Winie URL
 
Fields inherited from interface org.w3c.jwput.JWOptions
ACCEPT_LANGUAGE_P, BACKUP_P, DEF_TRIES, ETAGS_DB, FALSE_P, HEADER_PREFIX, HIDE_POPUPS_P, HOMEDIR_P, LOAD_DIR_P, MIME_PREFIX, MIMEDEF_P, OVERWRITE_P, PASSWORD_P, PROGRESS_BAR_P, PROMPT_P, PROXY_HOST_P, PROXY_PORT_P, PROXY_SET_P, PUT_CVS_P, QUIET_P, REC_P, SAVE_DIR_P, SOCKS_HOST_P, SOCKS_PORT_P, TRIES_P, TRUE_P, USER_AGENT_P, USER_P, VERBOSE_P, WPUTDIR, WPUTRC
 
Constructor Summary
JW()
           
 
Method Summary
 void abort()
           
 void addJWListener(org.w3c.jwput.event.JWListener listener)
           
static void check(java.io.File file)
          Check if the directory containing this file exists, if not create it.
protected  org.w3c.www.protocol.http.Request createRequest(java.util.Hashtable headers)
          Create a HTTP Request using the given headers.
protected  void displayErrorMessage(org.w3c.www.protocol.http.Reply reply)
          Display the error reply (including the body).
protected  void displayErrorMessage(org.w3c.www.protocol.http.Reply reply, java.lang.String msg)
          Display the error reply (including the body).
protected  void displayMessage(org.w3c.www.protocol.http.Reply reply)
          Display the reply (including the body).
protected  void fireDownloadEvent(java.lang.String file, java.lang.String url)
           
protected  void fireUploadEvent(java.lang.String file, java.lang.String url)
           
 java.lang.String getETag(java.io.File file, java.lang.String url)
           
protected  ETagsDatabase getETagsDatabase()
           
static java.lang.String getFileName(java.lang.String path)
           
 org.w3c.www.protocol.http.HttpManager getManager(java.util.Properties props)
          Get the HttpManager.
static java.io.File getPathConfig()
           
static int getPort(java.net.URL url)
          Get the port number included in this URL.
static org.w3c.util.XMLProperties getPreferences()
           
static java.io.File getPreferencesFile()
          Get the preferences file
 java.util.Properties getProperties()
          Get the General Properties.
 java.util.Properties getUserProperties()
          Get the User Properties.
protected  void initialize(java.util.Properties props)
           
protected  boolean isAborted()
           
protected  boolean isAbortedOrDone()
           
protected  boolean isDone()
           
 void notifyProgress(org.w3c.www.protocol.http.RequestEvent event)
          Request Observer
 org.w3c.www.protocol.http.Reply performRequest(java.lang.String method, java.lang.String url)
          Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly.
 org.w3c.www.protocol.http.Reply performRequest(java.lang.String method, java.lang.String url, java.util.Hashtable headers)
          Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly.
 org.w3c.www.protocol.http.Reply performRequest(java.lang.String method, java.lang.String url, java.io.InputStream body, java.util.Hashtable headers)
          Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly.
 org.w3c.www.protocol.http.Reply performRequest(java.lang.String method, java.lang.String url, java.io.InputStream body, java.util.Hashtable headers, boolean follow)
          Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly.
protected  void removeEtag(java.io.File file, java.lang.String url)
           
 void removeJWListener(org.w3c.jwput.event.JWListener listener)
           
protected  void saveEtag(java.io.File file, java.lang.String url, java.lang.String etag)
           
static void savePreferences(java.util.Properties prefs)
           
protected  void setAborted(boolean aborted)
           
protected  void setDone(boolean done)
           
protected  void skipBody(org.w3c.www.protocol.http.Reply reply)
          Should be called to purge the reply, otherwise the connection won't be marked idle and won't be reused.
 void updateProperties(java.util.Properties props)
          Update the user properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_AGENT

public static final java.lang.String USER_AGENT
USER_AGENT HEADER

BANNER

public static final java.lang.String BANNER
BANNER

VERSION

public static final java.lang.String VERSION
Software version

WINIE_LATEST_ZIP

public static final java.lang.String WINIE_LATEST_ZIP
Latest distribution URL

WINIE_DOC_URL

public static final java.lang.String WINIE_DOC_URL
Documentation URL

WINIE_URL

public static final java.lang.String WINIE_URL
Winie URL

DEFAULT_MIME

public static final java.lang.String DEFAULT_MIME
Default mime type

ui

protected JWUI ui

manager

protected org.w3c.www.protocol.http.HttpManager manager

etagsDB

protected ETagsDatabase etagsDB

verbose

protected boolean verbose

prompt

protected boolean prompt

quiet

protected boolean quiet

in

protected java.io.LineNumberReader in

user

protected java.lang.String user

password

protected java.lang.String password

puser

protected java.lang.String puser

ppassword

protected java.lang.String ppassword

jwprops

protected java.util.Properties jwprops

uriInfos

protected java.util.Hashtable uriInfos

done

protected boolean done

aborted

protected boolean aborted

request

protected org.w3c.www.protocol.http.Request request

listeners

protected java.util.Vector listeners
Constructor Detail

JW

public JW()
Method Detail

addJWListener

public void addJWListener(org.w3c.jwput.event.JWListener listener)

removeJWListener

public void removeJWListener(org.w3c.jwput.event.JWListener listener)

fireUploadEvent

protected void fireUploadEvent(java.lang.String file,
                               java.lang.String url)

fireDownloadEvent

protected void fireDownloadEvent(java.lang.String file,
                                 java.lang.String url)

isAbortedOrDone

protected boolean isAbortedOrDone()

isAborted

protected boolean isAborted()

isDone

protected boolean isDone()

setAborted

protected void setAborted(boolean aborted)

setDone

protected void setDone(boolean done)

abort

public void abort()

getETagsDatabase

protected ETagsDatabase getETagsDatabase()

getETag

public java.lang.String getETag(java.io.File file,
                                java.lang.String url)

saveEtag

protected void saveEtag(java.io.File file,
                        java.lang.String url,
                        java.lang.String etag)

removeEtag

protected void removeEtag(java.io.File file,
                          java.lang.String url)

getManager

public org.w3c.www.protocol.http.HttpManager getManager(java.util.Properties props)
Get the HttpManager.
Parameters:
props - the properties
Returns:
a HttpManager instance

notifyProgress

public void notifyProgress(org.w3c.www.protocol.http.RequestEvent event)
Request Observer
Specified by:
notifyProgress in interface org.w3c.www.protocol.http.RequestObserver

getPort

public static int getPort(java.net.URL url)
Get the port number included in this URL.
Returns:
an int

displayErrorMessage

protected void displayErrorMessage(org.w3c.www.protocol.http.Reply reply)
Display the error reply (including the body).
Parameters:
reply - the HTTP reply

displayErrorMessage

protected void displayErrorMessage(org.w3c.www.protocol.http.Reply reply,
                                   java.lang.String msg)
Display the error reply (including the body).
Parameters:
reply - the HTTP reply
msg - the message to display

displayMessage

protected void displayMessage(org.w3c.www.protocol.http.Reply reply)
Display the reply (including the body).
Parameters:
reply - the HTTP reply

createRequest

protected org.w3c.www.protocol.http.Request createRequest(java.util.Hashtable headers)
Create a HTTP Request using the given headers.
Parameters:
headers - a Hastable containing HTTP headers
Returns:
a HTTP Request

skipBody

protected void skipBody(org.w3c.www.protocol.http.Reply reply)
Should be called to purge the reply, otherwise the connection won't be marked idle and won't be reused.
Parameters:
reply - the reply to purge.

performRequest

public org.w3c.www.protocol.http.Reply performRequest(java.lang.String method,
                                                      java.lang.String url)
Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly.
Parameters:
method - the HTTP Method (HEAD, GET, PUT, TRACE, ...)
url - the destination url
Returns:
a Reply instance

performRequest

public org.w3c.www.protocol.http.Reply performRequest(java.lang.String method,
                                                      java.lang.String url,
                                                      java.util.Hashtable headers)
Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly.
Parameters:
method - the HTTP Method (HEAD, GET, PUT, TRACE, ...)
url - the destination url
headers - HTTP headers
Returns:
a Reply instance

performRequest

public org.w3c.www.protocol.http.Reply performRequest(java.lang.String method,
                                                      java.lang.String url,
                                                      java.io.InputStream body,
                                                      java.util.Hashtable headers)
Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly. In case of redirection, Reply.getLocation() will allways return the target URL.
Parameters:
method - the HTTP Method (HEAD, GET, PUT, TRACE, ...)
url - the destination url
body - an inputStream (null if there is no body in the request)
headers - HTTP headers
Returns:
a Reply instance

performRequest

public org.w3c.www.protocol.http.Reply performRequest(java.lang.String method,
                                                      java.lang.String url,
                                                      java.io.InputStream body,
                                                      java.util.Hashtable headers,
                                                      boolean follow)
Perform a HTTP/1.1 Request, handle authorization and redirection automaticaly. In case of redirection, Reply.getLocation() will allways return the target URL.
Parameters:
method - the HTTP Method (HEAD, GET, PUT, TRACE, ...)
url - the destination url
body - an inputStream (null if there is no body in the request)
headers - HTTP headers
follow - follow redirections?
Returns:
a Reply instance

getProperties

public java.util.Properties getProperties()
Get the General Properties.
Returns:
a Property set

getUserProperties

public java.util.Properties getUserProperties()
Get the User Properties.
Returns:
a Property set

updateProperties

public void updateProperties(java.util.Properties props)
Update the user properties
Parameters:
props - the new properties

initialize

protected void initialize(java.util.Properties props)

check

public static void check(java.io.File file)
Check if the directory containing this file exists, if not create it.
Parameters:
file - the file

getPathConfig

public static java.io.File getPathConfig()

getPreferencesFile

public static java.io.File getPreferencesFile()
Get the preferences file
Returns:
a File instance

getPreferences

public static org.w3c.util.XMLProperties getPreferences()
                                                 throws java.io.IOException,
                                                        java.io.FileNotFoundException

savePreferences

public static void savePreferences(java.util.Properties prefs)
                            throws java.io.IOException

getFileName

public static java.lang.String getFileName(java.lang.String path)