Class COM.Extropia.net.JavaCGIBridge
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.Extropia.net.JavaCGIBridge

java.lang.Object
   |
   +----COM.Extropia.net.JavaCGIBridge

public class JavaCGIBridge
extends Object
implements Runnable
This is a class that POSTS and GETS data from URLs using various helper methods. This class 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).

Helper methods allow you to set up form variables, get setup information over a URL, get raw or pre-parsed HTML data, and more.

The getParsedData method relies on instance variables which tell the parser where the data begins and ends (top and bottom separators respectively). The field and row separators inform the parser where records and fields end.

The default top separator is <!--start of data-->

The default bottom separator is <!--end of data-->

The default field separator is ~|~ (tilde + pipe + tilde).

The default row separator is ~|~\n (tilde + pipe + tilde + newline).


Constructor Index

 o JavaCGIBridge()
Constructs the object with no initialization.
 o JavaCGIBridge(String, String, String, String)
Constructs the object with new separator values

Method Index

 o addFormValue(Hashtable, String, String)
Adds a form variable, value pair to the passed Hashtable.
 o getBottomSeparator()
Returns the bottom separator for the object.
 o getDefaultThreadJavaCGIBridgeTimeOut()
Static method returns the default communication time out in milliseconds for the class.
 o getFieldSeparator()
Returns the field separator for the object.
 o getKeyValuePairs(Vector)
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.
 o getParsedData(URL)
Returns parsed data in the form of a Vector of Vectors containing the returned fields inside of a Vector of returned rows.
 o getParsedData(URL, Hashtable)
Returns parsed data in the form of a Vector of Vectors containing the returned fields inside of a Vector of returned rows.
 o getRawCGIData(URL)
Returns raw HTML data as a String from the passed URL.
 o getRawCGIData(URL, Hashtable)
Returns raw HTML data as a String from the passed URL and list of Form variable/value pairs stored in a Hashtable.
 o getRowSeparator()
Returns the row separator for the object.
 o getThreadJavaCGIBridgeTimeOut()
Returns the actual communication time out in milliseconds for the object.
 o getTopSeparator()
Returns the top separator for the object.
 o run()
This run thread asynchronously POSTs and GETs data from a URL and places the contents into the threadCGIData variable.
 o setBottomSeparator(String)
Sets the bottom separator for the object.
 o setDefaultThreadJavaCGIBridgeTimeOut(int)
Static method sets the default communication time out in milliseconds for the class.
 o setFieldSeparator(String)
Sets the field separator for the object.
 o setRowSeparator(String)
Sets the row separator for the object.
 o setThreadJavaCGIBridgeTimeOut(int)
Sets the actual communication time out in milliseconds for the object.
 o setTopSeparator(String)
Sets the top separator for the object.

Constructors

 o JavaCGIBridge
  public JavaCGIBridge(String field,
                       String row,
                       String top,
                       String bottom)
Constructs the object with new separator values
 o JavaCGIBridge
  public JavaCGIBridge()
Constructs the object with no initialization. This is the default (empty) constructor.

Methods

 o addFormValue
  public void addFormValue(Hashtable ht,
                           String formKey,
                           String formValue)
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
 o getKeyValuePairs
  public Hashtable getKeyValuePairs(Vector vectorOfVectors)
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
 o getParsedData
  public Vector getParsedData(URL u) throws JavaCGIBridgeTimeOutException
Returns parsed data in the form of a Vector of Vectors containing the returned fields inside of a Vector of returned rows.
Parameters:
u - URL to get parsed data from.
Returns:
Vector (records) of vectors (fields) of parsed data
Throws: JavaCGIBridgeTimeOutException
If the retrieval times out
See Also:
getRawCGIData
 o getParsedData
  public Vector getParsedData(URL u,
                              Hashtable ht) throws JavaCGIBridgeTimeOutException
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.
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
If the retrieval times out
See Also:
getRawCGIData
 o getRawCGIData
  public String getRawCGIData(URL u) throws JavaCGIBridgeTimeOutException
Returns raw HTML data as a String from the passed URL.
Parameters:
u - URL to get raw HTML from.
Returns:
String containing plain HTML text
Throws: JavaCGIBridgeTimeOutException
If the retrieval times out
See Also:
getParsedData
 o getRawCGIData
  public String getRawCGIData(URL u,
                              Hashtable ht) throws JavaCGIBridgeTimeOutException
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.
Parameters:
u - URL to get raw HTML from.
ht - Hashtable contains form variables to POST
Returns:
String containing plain HTML text
Throws: JavaCGIBridgeTimeOutException
If the retrieval times out
See Also:
getParsedData
 o getDefaultThreadJavaCGIBridgeTimeOut
  public static int getDefaultThreadJavaCGIBridgeTimeOut()
Static method returns 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.
Returns:
default communication time out in milliseconds
See Also:
setDefaultThreadJavaCGIBridgeTimeOut
 o setDefaultThreadJavaCGIBridgeTimeOut
  public static void setDefaultThreadJavaCGIBridgeTimeOut(int t)
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
 o getThreadJavaCGIBridgeTimeOut
  public int getThreadJavaCGIBridgeTimeOut()
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, getDefaultThreadJavaCGIBridgeTimeOut, setDefaultThreadJavaCGIBridgeTimeOut
 o setThreadJavaCGIBridgeTimeOut
  public void setThreadJavaCGIBridgeTimeOut(int t)
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
 o setFieldSeparator
  public void setFieldSeparator(String s)
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, getFieldSeparator
 o getFieldSeparator
  public String 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, setFieldSeparator
 o setRowSeparator
  public void setRowSeparator(String s)
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, getRowSeparator
 o getRowSeparator
  public String 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, setRowSeparator
 o setTopSeparator
  public void setTopSeparator(String s)
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, getTopSeparator
 o getTopSeparator
  public String 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, setTopSeparator
 o setBottomSeparator
  public void setBottomSeparator(String s)
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, getBottomSeparator
 o getBottomSeparator
  public String 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, setBottomSeparator
 o run
  public void run()
This run thread asynchronously POSTs and GETs data from a 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.
See Also:
getRawCGIData

All Packages  Class Hierarchy  This Package  Previous  Next  Index