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
static java.lang.String BANNER
          BANNER
static java.lang.String DEFAULT_MIME
          Default mime type
protected  ETagsDatabase etagsDB
           
protected  java.io.LineNumberReader in
           
protected  java.util.Properties jwprops
           
protected  org.w3c.www.protocol.http.HttpManager manager
           
protected  java.lang.String password
           
protected  boolean prompt
           
protected  boolean quiet
           
protected  JWUI ui
           
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, MIME_PREFIX, MIMEDEF_P, OVERWRITE_P, PASSWORD_P, PROMPT_P, PROXY_HOST_P, PROXY_PORT_P, PROXY_SET_P, QUIET_P, REC_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
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 displayMessage(org.w3c.www.protocol.http.Reply reply)
          Display the reply (including the body).
 java.lang.String getETag(java.io.File file, java.lang.String url)
           
protected  ETagsDatabase getETagsDatabase()
           
 org.w3c.www.protocol.http.HttpManager getManager(java.util.Properties props)
          Get the HttpManager.
static int getPort(java.net.URL url)
          Get the port number included in this URL.
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)
           
 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)
           
protected  void saveEtag(java.io.File file, java.lang.String url, java.lang.String etag)
           
static void savePreferences(java.util.Properties prefs)
           
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

jwprops

protected java.util.Properties jwprops
Constructor Detail

JW

public JW()
Method Detail

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

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 peoperties

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

getPreferencesFile

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

savePreferences

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