Class JavaCGIBridge

java.lang.Object
  |
  +--java.net.URLConnection
        |
        +--java.net.HttpURLConnection
              |
              +--JavaCGIBridge
All Implemented Interfaces:
java.lang.Runnable

public class JavaCGIBridge
extends java.net.HttpURLConnection
implements java.lang.Runnable

The JavaCGIBridge class POSTS and GETS data from URLs using various helper methods. It also provides the capability of timing out if the connection takes too long to transfer data by using threads to monitor whether the data is taking too long to transfer (implements Runnable).

Version:
1.00, 10 Aug 1997
Author:
Gunther Birznieks

 Modifications including adding 401 HTTP security , P. Lemkin (NCI), J. Evans(CIT), C. Santos(CIT), G. Thornwall (SAIC), 
         NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home , JavaCGIBridgeTimeOutException

Field Summary
private  java.lang.String bottomSeparator
          The bottom of data separator.
private static int defaultThreadJavaCGIBridgeTimeOut
          This is the default CGI Timeout in milliseconds.
private  java.lang.String fieldSeparator
          The field separator.
private  boolean gotHdrFlag
           
private  java.util.Vector headers
           
private  java.util.Hashtable keys
           
private static char keySeparator
           
private  java.lang.String passwd
          possibly used for Authentication
private static boolean PFL_NEW_READ_BUF_CODE
           
private  int responseCode
          set when return from server
private  java.lang.String responseMsg
           
private  java.lang.String rowSeparator
          The row separator.
private  java.net.Socket sock
          socket for fine-grain control
private  boolean threadCanRunMethodExecute
          This is a flag that makes it so that the run() method is at least semi-private for Threading.
private  java.lang.String threadCGIData
          This is the returned URL data.
private  boolean threadCompleted
          This is a flag indicating whether the URL data was retrieved inside the thread or not.
private  java.util.Hashtable threadFormVar
          The HTML form data for the URL that data is retrieved from.
private  int threadJavaCGIBridgeTimeOut
          This is the actual CGI Timeout value in milliseconds for the instantiated object.
private  java.net.URL threadURL
          The URL That data is retrieved from.
private  java.lang.String topSeparator
          The top of data separator.
private  java.net.URL urlArg
          may need because of HttpURLConnection
private  java.lang.String userName
          possibly used for Authentication
 
Fields inherited from class java.net.HttpURLConnection
followRedirects, HTTP_ACCEPTED, HTTP_BAD_GATEWAY, HTTP_BAD_METHOD, HTTP_BAD_REQUEST, HTTP_CLIENT_TIMEOUT, HTTP_CONFLICT, HTTP_CREATED, HTTP_ENTITY_TOO_LARGE, HTTP_FORBIDDEN, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_INTERNAL_ERROR, HTTP_LENGTH_REQUIRED, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_MULT_CHOICE, HTTP_NO_CONTENT, HTTP_NOT_ACCEPTABLE, HTTP_NOT_AUTHORITATIVE, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_OK, HTTP_PARTIAL, HTTP_PAYMENT_REQUIRED, HTTP_PRECON_FAILED, HTTP_PROXY_AUTH, HTTP_REQ_TOO_LONG, HTTP_RESET, HTTP_SEE_OTHER, HTTP_SERVER_ERROR, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, instanceFollowRedirects, method, methods, responseMessage
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, contentClassPrefix, contentPathProp, defaultAllowUserInteraction, defaultUseCaches, doInput, doOutput, factory, fileNameMap, fileNameMapLoaded, handlers, ifModifiedSince, UnknownContentHandlerP, url, useCaches
 
Constructor Summary
JavaCGIBridge()
          JavaCGIBridge() - Constructs the object with no initialization.
JavaCGIBridge(java.net.URL url)
          JavaCGIBridge() - Constructs the object with no initialization.
JavaCGIBridge(java.net.URL url, java.lang.String userName, java.lang.String passwd)
          JavaCGIBridge() - Constructs the object with userName, password.
 
Method Summary
 void addFormValue(java.util.Hashtable ht, java.lang.String formKey, java.lang.String formValue)
          addFormValue() - adds a form variable, value pair to the passed Hashtable.
private  java.lang.String base64encode(java.lang.String str)
          base64encode() - return str encoded to base64 format.
private  int base64Length(int strLength)
          base64Length() - compute# bytes it takes to store LEN bytes in base64.
 java.lang.String basicAuthenticationEncode(java.lang.String user, java.lang.String passwd)
          basicAuthenticationEncode() - create authentication header contents for the `Basic' scheme.
 void connect()
          connect() - implements abstract method for HttpURLconnection.
 void disconnect()
          disconnect() - implements abstract method for HttpURLconnection.
 java.lang.String getBottomSeparator()
          getBottomSeparator() - Returns the bottom separator for the object When getParsedData method is called, the object uses the bottom separator to determine where the rows of data inside the raw HTML output actually end.
static int getDefaultThreadJavaCGIBridgeTimeOut()
          getDefaultThreadJavaCGIBridgeTimeOut() - default communication time out Return default static value in milliseconds for the class.
 java.lang.String getField(java.lang.String str)
          getField() - helper routine for parsing header key PFL - 8-7-00 See pg931, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
 java.lang.String getFieldSeparator()
          getFieldSeparator() - Returns the field separator for the object.
 java.lang.String getHeaderField(int n)
          getHeaderField() - implements getHeaderField for HttpURLconnection.
 java.lang.String getHeaderField(java.lang.String key)
          getHeaderField() - implements HeaderField for HttpURLconnection.
(package private)  void getHeaders()
          getHeaders() - help routine read header from HTTP connection.
private  java.lang.String getHttpRequestInThread(java.net.URL u, java.util.Hashtable ht)
          getHttpRequestInThread() - Returns HTTP Request data to the thread that was launched to GET/POST data for a URL.
 java.io.InputStream getInputStream()
          getInputStream() - implements getInputStream for HttpURLconnection.
(package private) static java.lang.String getKey(java.lang.String str)
          getKey() - helper routine for parsing header field PFL - 8-7-00 See pg931, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
 java.util.Hashtable getKeyValuePairs(java.util.Vector vectorOfVectors)
          getKeyValuePairs() - cvt getParsedData to hashtable.
 java.io.OutputStream getOutputStream()
          getOutputStream() - implements getOutputStream for HttpURLconnection.
 java.util.Vector getParsedData(java.net.URL u)
          getParsedData() - returns parsed data in form of Vector of Vectors containing the returned fields inside of a Vector of returned rows.
 java.util.Vector getParsedData(java.net.URL u, java.util.Hashtable ht)
          getParsedData() - returns parsed data in form of Vector of Vectors Returns parsed data in the form of a Vector of Vectors containing the returned fields inside of a Vector of returned rows.
 java.lang.String getRawCGIData(java.net.URL u)
          getRawCGIData() - returns raw HTML data as a String from the passed URL.
 java.lang.String getRawCGIData(java.net.URL u, java.util.Hashtable ht)
          getRawCGIData() - returns raw HTML data as a String from URL & hashtable.
 byte[] getRawCGIDataByte(java.net.URL u, java.util.Hashtable ht)
          getRawCGIDataByte() - returns raw HTML data as byte[] from URL&hashtable.
 java.lang.String getRowSeparator()
          getRowSeparator() - Returns the row separator for the object.
 int getThreadJavaCGIBridgeTimeOut()
          getThreadJavaCGIBridgeTimeOut() - actual communication time out in msec.
 java.lang.String getTopSeparator()
          getTopSeparator() - Returns the top separator for the object.
private  java.lang.String getURLEncodedHashTable(java.util.Hashtable ht)
          getURLEncodedHashTable() - form variables inside hashtable as URLencoded string of parameters for a CGI based program to process.
 java.lang.String HeaderFieldKey(int n)
          HeaderFieldKey() - implements HeaderFieldKey for HttpURLconnection.
 void JavaCGIBridgeSep(java.lang.String field, java.lang.String row, java.lang.String top, java.lang.String bottom)
          JavaCGIBridgeSep() - constructs the object with new separator values
(package private) static java.lang.String recv(java.io.InputStream in)
          recv() - helper routine to read a \n-terminated string from input stream.
 void run()
          run() - This run thread asynchronously POSTs and GETs data from URL and places the contents into the threadCGIData variable.
(package private) static void send(java.io.OutputStream out, java.lang.String s)
          send() - helper routine to send a string to output stream.
 void setBottomSeparator(java.lang.String s)
          setBottomSeparator() - Sets the bottom separator for the object.
static void setDefaultThreadJavaCGIBridgeTimeOut(int t)
          setDefaultThreadJavaCGIBridgeTimeOut() - set communication time out Static method sets the default communication time out in milliseconds for the class.
 void setFieldSeparator(java.lang.String s)
          setFieldSeparator() - Sets the field separator for the object.
 void setRowSeparator(java.lang.String s)
          setRowSeparator() - Sets the row separator for the object.
 void setThreadJavaCGIBridgeTimeOut(int t)
          setThreadJavaCGIBridgeTimeOut() - actual communication time out in msec.
 void setTopSeparator(java.lang.String s)
          setTopSeparator() - Sets the top separator for the object.
 boolean usingProxy()
          usingProxy() - impimplements abstract method for HttpURLconnection.
 
Methods inherited from class java.net.HttpURLConnection
, getErrorStream, getFollowRedirects, getHeaderFieldDate, getInstanceFollowRedirects, getPermission, getRequestMethod, getResponseCode, getResponseMessage, setFollowRedirects, setInstanceFollowRedirects, setRequestMethod
 
Methods inherited from class java.net.URLConnection
checkfpx, getAllowUserInteraction, getContent, getContent, getContentEncoding, getContentHandler, getContentHandlerPkgPrefixes, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderFieldInt, getHeaderFieldKey, getIfModifiedSince, getLastModified, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, lookupContentHandlerClassFor, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, stripOffParameters, toString, typeToPackageName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

PFL_NEW_READ_BUF_CODE

private static final boolean PFL_NEW_READ_BUF_CODE

fieldSeparator

private java.lang.String fieldSeparator
The field separator. When a CGI script or HTML file returns data, then the getParsedData() method will know how to separate fields by looking at this variable. The default value is "~|~" (tilde + pipe + tilde). This is considered sufficiently unlikely to appear inside of actual field data that it is a pretty good field separator to parse on. If the user of this class needs a different separator, it may be overridden by calling the appropriate method.

rowSeparator

private java.lang.String rowSeparator
The row separator. When a CGI script or HTML file returns data, then the getParsedData() method will know how to separate returned rows by looking at this variable. The default value is "~|~\n" (tilde + pipe + tilde + newline). This is considered sufficiently unlikely to appear inside of actual row data that it is a pretty good row separator to parse on. If the user of this class needs a different separator, it may be overridden by calling the appropriate method.

topSeparator

private java.lang.String topSeparator
The top of data separator. When a CGI script or HTML file returns data, then the getParsedData() method will determine when to start parsing data by encountering this separator. The default value is "" implicitly followed by a newline. That is, a newline is generally expected to follow this separator.

bottomSeparator

private java.lang.String bottomSeparator
The bottom of data separator. When a CGI script or HTML file returns data, then the getParsedData() method will determine when to stop parsing data by encountering this separator. The default value is "" implicitly followed by a newline. That is, a newline is generally expected to follow this separator.

threadURL

private java.net.URL threadURL
The URL That data is retrieved from. This is an instance variable rather than a parameter because the data retrieval is done from a launched thread which gets no parameters.

threadFormVar

private java.util.Hashtable threadFormVar
The HTML form data for the URL that data is retrieved from. This is an instance variable rather than a parameter because the data retrieval is done from a launched thread which gets no parameters.

threadCompleted

private boolean threadCompleted
This is a flag indicating whether the URL data was retrieved inside the thread or not.

threadCGIData

private java.lang.String threadCGIData
This is the returned URL data. It is an instance variable because the run() method of the thread cannot explicitly return data.

defaultThreadJavaCGIBridgeTimeOut

private static int defaultThreadJavaCGIBridgeTimeOut
This is the default CGI Timeout in milliseconds. For example, a value of 10000 will tell the class to throw a JavaCGIBridgeTimeOutException if the data is not retrieved within 10 seconds of having initiated a data transfer. PFL 2-16-99, reset to 60 seconds or 60000.

threadJavaCGIBridgeTimeOut

private int threadJavaCGIBridgeTimeOut
This is the actual CGI Timeout value in milliseconds for the instantiated object. Notice that the default value is a static class variable that applies across all instances of this class. This variable, on the other hand, is the actual value the object uses.

threadCanRunMethodExecute

private boolean threadCanRunMethodExecute
This is a flag that makes it so that the run() method is at least semi-private for Threading. This flag has to be set true in order for another object to execute the run() method.

urlArg

private java.net.URL urlArg
may need because of HttpURLConnection

userName

private java.lang.String userName
possibly used for Authentication

passwd

private java.lang.String passwd
possibly used for Authentication

sock

private java.net.Socket sock
socket for fine-grain control

keys

private java.util.Hashtable keys

headers

private java.util.Vector headers

gotHdrFlag

private boolean gotHdrFlag

keySeparator

private static final char keySeparator

responseCode

private int responseCode
set when return from server

responseMsg

private java.lang.String responseMsg
Constructor Detail

JavaCGIBridge

public JavaCGIBridge(java.net.URL url)
JavaCGIBridge() - Constructs the object with no initialization. This is the default (empty) constructor.

JavaCGIBridge

public JavaCGIBridge()
JavaCGIBridge() - Constructs the object with no initialization. This is the default (empty) constructor. *DEPRICATE*???? - need the url for connect() call.

JavaCGIBridge

public JavaCGIBridge(java.net.URL url,
                     java.lang.String userName,
                     java.lang.String passwd)
JavaCGIBridge() - Constructs the object with userName, password. This is the default (empty) constructor.
Parameters:
url -  
userName -  
passwd -  
Method Detail

JavaCGIBridgeSep

public void JavaCGIBridgeSep(java.lang.String field,
                             java.lang.String row,
                             java.lang.String top,
                             java.lang.String bottom)
JavaCGIBridgeSep() - constructs the object with new separator values
Parameters:
field -  
row, -  
top -  
bottom -  

connect

public void connect()
             throws java.io.IOException
connect() - implements abstract method for HttpURLconnection. This lets us control Authorization: requests... if userName, and password were specified. PFL - 8-7-00. See pg929, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
connect in class java.net.URLConnection

disconnect

public void disconnect()
disconnect() - implements abstract method for HttpURLconnection. PFL - 8-7-00 See pg929, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
disconnect in class java.net.HttpURLConnection

usingProxy

public boolean usingProxy()
usingProxy() - impimplements abstract method for HttpURLconnection. PFL - 8-7-00 See pg929, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
usingProxy in class java.net.HttpURLConnection
Returns:
true if using a proxy server

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
getInputStream() - implements getInputStream for HttpURLconnection. Overide default provided in URL connection. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
getInputStream in class java.net.URLConnection
Returns:
input stream
See Also:
connect()

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
getOutputStream() - implements getOutputStream for HttpURLconnection. Overide default provided in URL connection. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
getOutputStream in class java.net.URLConnection
Returns:
output stream
See Also:
connect()

getHeaderField

public java.lang.String getHeaderField(int n)
getHeaderField() - implements getHeaderField for HttpURLconnection. Overide default provided in URL connection. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
getHeaderField in class java.net.URLConnection
Parameters:
n - is the field to get
Returns:
nth header field data
See Also:
getField(java.lang.String), getHeaders()

getHeaderField

public java.lang.String getHeaderField(java.lang.String key)
getHeaderField() - implements HeaderField for HttpURLconnection. Overide default provided in URL connection. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Overrides:
getHeaderField in class java.net.URLConnection
Parameters:
key - specified the header field to get
Returns:
data
See Also:
getHeaders()

HeaderFieldKey

public java.lang.String HeaderFieldKey(int n)
HeaderFieldKey() - implements HeaderFieldKey for HttpURLconnection. Overide default provided in URL connection. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Parameters:
n - is the header field
Returns:
data associated with key
See Also:
getHeaders(), getKey(java.lang.String)

send

static void send(java.io.OutputStream out,
                 java.lang.String s)
          throws java.io.IOException
send() - helper routine to send a string to output stream. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Parameters:
out - output stream to write to
s - is string to write

recv

static java.lang.String recv(java.io.InputStream in)
                      throws java.io.IOException
recv() - helper routine to read a \n-terminated string from input stream. PFL - 8-7-00 See pg930, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Parameters:
in - input stream to read from
Returns:
string data

getKey

static java.lang.String getKey(java.lang.String str)
getKey() - helper routine for parsing header field PFL - 8-7-00 See pg931, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Parameters:
str -  
Returns:
data

getField

public java.lang.String getField(java.lang.String str)
getField() - helper routine for parsing header key PFL - 8-7-00 See pg931, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
Parameters:
str -  
Returns:
data

getHeaders

void getHeaders()
getHeaders() - help routine read header from HTTP connection. PFL - 8-7-00 See pg931, Patrick Chan etal, Java Class Libraries 2nd Ed, Vol 1.
See Also:
basicAuthenticationEncode(java.lang.String, java.lang.String), connect(), getField(java.lang.String)

addFormValue

public void addFormValue(java.util.Hashtable ht,
                         java.lang.String formKey,
                         java.lang.String formValue)
addFormValue() - adds a form variable, value pair to the passed Hashtable.
Parameters:
ht - the Hashtable that contains the form variable/value pairs
formKey - the String that contains the form variable to add
formValue - the String that contains the form value to add

getKeyValuePairs

public java.util.Hashtable getKeyValuePairs(java.util.Vector vectorOfVectors)
getKeyValuePairs() - cvt getParsedData to hashtable. Takes the parsed data returned from the getParsedData method and changes it to a Hashtable of key, value pairs where the first Vector entry of each Vector record is the key and the rest of the second Vector entry for each record is the value of the Hashtable.
Parameters:
vectorOfVectors - the Vector of Vectors for the parsed data
Returns:
Hashtable containing converted variable/value pairs
See Also:
getParsedData(java.net.URL)

getParsedData

public java.util.Vector getParsedData(java.net.URL u)
                               throws JavaCGIBridgeTimeOutException
getParsedData() - returns parsed data in form of Vector of Vectors containing the returned fields inside of a Vector of returned rows. It throws JavaCGIBridgeTimeOutException if the retrieval times out.
Parameters:
u - URL to get parsed data from.
Returns:
Vector (records) of vectors (fields) of parsed data
Throws:
JavaCGIBridgeTimeOutException -  
See Also:
getParsedData(java.net.URL)

getParsedData

public java.util.Vector getParsedData(java.net.URL u,
                                      java.util.Hashtable ht)
                               throws JavaCGIBridgeTimeOutException
getParsedData() - returns parsed data in form of Vector of Vectors Returns parsed data in the form of a Vector of Vectors containing the returned fields inside of a Vector of returned rows. This form POSTs the HTML Form variable data to the URL. It throws JavaCGIBridgeTimeOutException if the retrieval times out.
Parameters:
u - URL to get parsed data from.
ht - Hashtable contains form variables to POST
Returns:
Vector (records) of vectors (fields) of parsed data
Throws:
JavaCGIBridgeTimeOutException -  
See Also:
getRawCGIData(java.net.URL)

getRawCGIData

public java.lang.String getRawCGIData(java.net.URL u)
                               throws JavaCGIBridgeTimeOutException
getRawCGIData() - returns raw HTML data as a String from the passed URL. It throws JavaCGIBridgeTimeOutException if the retrieval times out.
Parameters:
u - URL to get raw HTML from.
Returns:
String containing plain HTML text
Throws:
JavaCGIBridgeTimeOutException -  
See Also:
getRawCGIData(java.net.URL)

getRawCGIDataByte

public byte[] getRawCGIDataByte(java.net.URL u,
                                java.util.Hashtable ht)
                         throws JavaCGIBridgeTimeOutException
getRawCGIDataByte() - returns raw HTML data as byte[] from URL&hashtable. It returns raw HTML data as a byte[] from the passed URL and list. It throws JavaCGIBridgeTimeOutException if the retrieval times out. [TODO] rewrite this using buffered Byte I/O * * * * T O D O * * * * See if(PFL_NEW_READ_BUF_CODE) code in getHttpRequestInThread().
Parameters:
u - URL to get raw HTML from.
Returns:
ht is hashtable
Throws:
JavaCGIBridgeTimeOutException -  

getRawCGIData

public java.lang.String getRawCGIData(java.net.URL u,
                                      java.util.Hashtable ht)
                               throws JavaCGIBridgeTimeOutException
getRawCGIData() - returns raw HTML data as a String from URL & hashtable. Returns raw HTML data as a String from the passed URL and list of Form variable/value pairs stored in a Hashtable. This form POSTs the HTML Form variable data to the URL. It throws JavaCGIBridgeTimeOutException if the retrieval times out.
Parameters:
u - URL to get raw HTML from.
ht - Hashtable contains form variables to POST
Returns:
String containing plain HTML text
Throws:
JavaCGIBridgeTimeOutException -  
See Also:
getParsedData(java.net.URL)

getDefaultThreadJavaCGIBridgeTimeOut

public static int getDefaultThreadJavaCGIBridgeTimeOut()
getDefaultThreadJavaCGIBridgeTimeOut() - default communication time out Return default static value in milliseconds for the class. When the object retrieves data from a URL, it must get the data within timeout milliseconds or a JavaCGIBridgeTimeOutException is thrown.
Returns:
default communication time out in milliseconds
See Also:
setDefaultThreadJavaCGIBridgeTimeOut(int)

setDefaultThreadJavaCGIBridgeTimeOut

public static void setDefaultThreadJavaCGIBridgeTimeOut(int t)
setDefaultThreadJavaCGIBridgeTimeOut() - set communication time out Static method sets the default communication time out in milliseconds for the class. When the object retrieves data from a URL, it must get the data within timeout milliseconds or a JavaCGIBridgeTimeOutException is thrown.
Parameters:
t - default communication time out in milliseconds
See Also:
getDefaultThreadJavaCGIBridgeTimeOut()

getThreadJavaCGIBridgeTimeOut

public int getThreadJavaCGIBridgeTimeOut()
getThreadJavaCGIBridgeTimeOut() - actual communication time out in msec. Returns the actual communication time out in milliseconds for the object. When the object retrieves data from a URL, it must get the data within timeout milliseconds or a JavaCGIBridgeTimeOutException is thrown.
Returns:
communication time out in milliseconds
See Also:
setThreadJavaCGIBridgeTimeOut(int), getDefaultThreadJavaCGIBridgeTimeOut(), setDefaultThreadJavaCGIBridgeTimeOut(int)

setThreadJavaCGIBridgeTimeOut

public void setThreadJavaCGIBridgeTimeOut(int t)
setThreadJavaCGIBridgeTimeOut() - actual communication time out in msec. Sets the actual communication time out in milliseconds for the object. When the object retrieves data from a URL, it must get the data within timeout milliseconds or a JavaCGIBridgeTimeOutException is thrown.
Parameters:
t - communication time out in milliseconds
See Also:
getThreadJavaCGIBridgeTimeOut(), getDefaultThreadJavaCGIBridgeTimeOut(), setDefaultThreadJavaCGIBridgeTimeOut(int)

setFieldSeparator

public void setFieldSeparator(java.lang.String s)
setFieldSeparator() - Sets the field separator for the object. When getParsedData method is called, the object uses the field separator to determine where fields in a returned record of the raw HTML result set begin and end.
Parameters:
s - String containing new delimiting separator
See Also:
getParsedData(java.net.URL), getFieldSeparator()

getFieldSeparator

public java.lang.String getFieldSeparator()
getFieldSeparator() - Returns the field separator for the object. When getParsedData method is called, the object uses the field separator to determine where fields in a returned record of the raw HTML result set begin and end.
Returns:
Separator string
See Also:
getParsedData(java.net.URL), setFieldSeparator(java.lang.String)

setRowSeparator

public void setRowSeparator(java.lang.String s)
setRowSeparator() - Sets the row separator for the object. When getParsedData method is called, the object uses the row separator to determine where rows/records of the raw HTML result set begin and end.
Parameters:
s - String containing new delimiting separator
See Also:
getParsedData(java.net.URL), getRowSeparator()

getRowSeparator

public java.lang.String getRowSeparator()
getRowSeparator() - Returns the row separator for the object. When getParsedData method is called, the object uses the row separator to determine where rows/records of the raw HTML result set begin and end.
Returns:
Separator string
See Also:
getParsedData(java.net.URL), setRowSeparator(java.lang.String)

setTopSeparator

public void setTopSeparator(java.lang.String s)
setTopSeparator() - Sets the top separator for the object. When getParsedData method is called, the object uses the top separator to determine where the rows of data inside the raw HTML output actually begin.
Parameters:
s - String containing new delimiting separator
See Also:
getParsedData(java.net.URL), getTopSeparator()

getTopSeparator

public java.lang.String getTopSeparator()
getTopSeparator() - Returns the top separator for the object. When getParsedData method is called, the object uses the top separator to determine where the rows of data inside the raw HTML output actually begin.
Returns:
Separator string
See Also:
getParsedData(java.net.URL), setTopSeparator(java.lang.String)

setBottomSeparator

public void setBottomSeparator(java.lang.String s)
setBottomSeparator() - Sets the bottom separator for the object. When getParsedData method is called, the object uses the bottom separator to determine where the rows of data inside the raw HTML output actually end.
Parameters:
s - String containing new delimiting separator
See Also:
getParsedData(java.net.URL), getBottomSeparator()

getBottomSeparator

public java.lang.String getBottomSeparator()
getBottomSeparator() - Returns the bottom separator for the object When getParsedData method is called, the object uses the bottom separator to determine where the rows of data inside the raw HTML output actually end.
Returns:
Separator string
See Also:
getParsedData(java.net.URL), setBottomSeparator(java.lang.String)

run

public void run()
run() - This run thread asynchronously POSTs and GETs data from URL and places the contents into the threadCGIData variable. Since Threads do not return or pass parameter values, instance variables in this object are used to maintain state. This method is only public so that the Thread class can launch the thread.
Specified by:
run in interface java.lang.Runnable
See Also:
getRawCGIData(java.net.URL)

getURLEncodedHashTable

private java.lang.String getURLEncodedHashTable(java.util.Hashtable ht)
getURLEncodedHashTable() - form variables inside hashtable as URLencoded string of parameters for a CGI based program to process.
Parameters:
ht - Hashtable containing form variables
Returns:
URLencoded string of HTML form variables & values
See Also:
addFormValue(java.util.Hashtable, java.lang.String, java.lang.String)

getHttpRequestInThread

private java.lang.String getHttpRequestInThread(java.net.URL u,
                                                java.util.Hashtable ht)
getHttpRequestInThread() - Returns HTTP Request data to the thread that was launched to GET/POST data for a URL. This is a private method.
Parameters:
u - URL to retrieve and post data for
ht - Form variables to send to URL
Returns:
String containing retrieved HTML text
See Also:
getURLEncodedHashTable(java.util.Hashtable), run()

base64Length

private int base64Length(int strLength)
base64Length() - compute# bytes it takes to store LEN bytes in base64. Code mapped from wget-src-http.c.

base64encode

private java.lang.String base64encode(java.lang.String str)
base64encode() - return str encoded to base64 format. Code mapped from wget-src-http.c.

basicAuthenticationEncode

public java.lang.String basicAuthenticationEncode(java.lang.String user,
                                                  java.lang.String passwd)
basicAuthenticationEncode() - create authentication header contents for the `Basic' scheme. This is done by encoding the string `USER:PASS' in base64 and constructing the string
    "Authorization: Basic " + base64encode(user+":"+passwd)
Returns:
null if a problem.
See Also:
base64encode(java.lang.String)