|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.algosome.common.io.URLConnect
public class URLConnect
URLConnect is a class that can be used to connect to and read a website. This class provides functionality to perform GET and PUT methods for dynamic websites, the parameters of which are stored within a hashmap keyed with the parameters. Parameters are formatted into a query string using the getQueryString function, the default implementation uses UTF-8 encoding.
Note: WWW consortium stipulates UTF-8 encoding should always be used: UTF-8 is the default encoding of this object.
To utilize this object properly, users must
Field Summary | |
---|---|
protected java.lang.String |
encoding
The type of encoding to use for the URL submission. |
protected java.util.Map<java.lang.String,java.lang.String> |
parameters
HashMap defining parameters and values for a GET or PUT query string. |
protected boolean |
query_method
Indicates whether GET or PUT will be used to contact a server. |
protected java.lang.String |
url
Specifies a URL to look up. |
Constructor Summary | |
---|---|
URLConnect()
Creates an empty URLConnect object containing no parameters. |
|
URLConnect(java.lang.String url)
Creates a URLConnect object with a given URL |
|
URLConnect(URLConnect e)
Creates an URLConnect object from a previous URLConnect object. |
Method Summary | |
---|---|
void |
doQuery(InputStreamParser parser)
Performs an HTTP request to NCBI: sets the URL based upon the current query method, then calls retrieveURLOutput. |
java.lang.String |
getEncoding()
Retrieves the encoding of this object. |
java.lang.String |
getParameter(java.lang.String param)
Retrieves the value to a parameter, or null if none has been set. |
boolean |
getQueryMethod()
Retrieves the HTTP method for query strings. |
java.lang.String |
getQueryString()
Retrieves a query string based upon the current parameters. |
java.lang.String |
getURL()
Retrieves the URL associated with this object. |
protected void |
retrieveURLOutput(java.lang.String url,
InputStreamParser parser)
Retrieves the output from the given url parameter. |
void |
setEncoding(java.lang.String encoding)
Sets the encoding of this object. |
void |
setParameter(java.lang.String param,
java.lang.String value)
Sets the value to a parameter for dynamic websites. |
void |
setQueryMethod(boolean b)
Sets the HTTP method for query strings. |
void |
setURL(java.lang.String u)
Sets the main URL to retrieve |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<java.lang.String,java.lang.String> parameters
protected java.lang.String url
protected boolean query_method
protected java.lang.String encoding
Constructor Detail |
---|
public URLConnect()
public URLConnect(java.lang.String url)
url
- The URL to set this object to retrieve.public URLConnect(URLConnect e)
e
- A pre-formed URLConnect object containing a set of parameters to use.Method Detail |
---|
public void setURL(java.lang.String u)
u
- A String represention of the URL associated with this object.public java.lang.String getURL()
public void setQueryMethod(boolean b)
b
- A boolean indicating the type of HTTP method to usepublic boolean getQueryMethod()
public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
Note: WWW specifies URL encoding to be UTF-8. Changing this value from the default may result in unexpected behavior.
encoding
- String representation of the encoding type.public void setParameter(java.lang.String param, java.lang.String value)
param
- The parameter keyvalue
- The value of the parameter.public java.lang.String getParameter(java.lang.String param)
param
- The parameter to retrieve
protected void retrieveURLOutput(java.lang.String url, InputStreamParser parser) throws java.io.IOException, java.io.UnsupportedEncodingException
url
- The URL to read and return the contents.parser
- An object that implements the InputStreamParser interface.
java.io.IOException
- if a connection could not be read or established.
java.io.UnsupportedEncodingException
- If encoding of a POST query could not be established.doQuery(InputStreamParser parser)
,
com.io.InputStreamParser
public java.lang.String getQueryString() throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
- in the case the appropriate encoding cannot be used.public void doQuery(InputStreamParser parser) throws java.io.IOException, java.io.UnsupportedEncodingException
parser
- An object that implements the InputStreamParser interface.
java.io.IOException
- if the connecetion cannot be read or established.
java.io.UnsupportedEncodingException
- If the submission cannot be UTF-8 Encoded.retrieveURLOutput(String url, InputStreamParser is)
,
com.io.InputStreamParser
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |