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