|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.bioquery.bqutils.UrlUtils
This class provides some simple static methods to simplify working with HTTP calls.
This class was originally written to provide an alternate way to extract querystring paramaters from the URL of an HTTP request. This function is available in the javax.servlet.http.HttpUtils class, but at time bioquery was hosted on a server with a bug in the parseQueryString() method of that class. This situation will soon be resolved, and it may be possible, but not necessary to migrate some of the calls to class to javax.servlet.http.HttpUtils methods.
| Constructor Summary | |
UrlUtils()
|
|
| Method Summary | |
static java.lang.String |
addParameter(java.lang.String url,
java.lang.String paramName,
java.lang.String parameter)
Takes the given url String and adds the given parameter to the querystring of that url. |
static java.util.Hashtable |
getAllParameters(java.lang.String queryString)
Given a querystring from a URL, this method will extract all of the parameters and put them in a Hashtable in which the first part of the querystring is the key and the second part is the value. |
static java.lang.String |
removeSpaces(java.lang.String originalString)
Finds all spaces in the given String and replaces them with '+' chars. |
static java.lang.String |
restoreSpaces(java.lang.String urlString)
Finds all '+' characters in the given String and replaces them with spaces. |
static java.lang.String |
setSession(java.lang.String url,
java.lang.String sessionId)
Takes the given url String and adds the given JSessionId. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public UrlUtils()
| Method Detail |
public static java.lang.String setSession(java.lang.String url,
java.lang.String sessionId)
http://www.bioquery.org/servletname?jsessionid=owieu938739url - the String representing the URLsessionId - the sessionId for this session that was determined
by the web container at the start of the session.
public static java.lang.String addParameter(java.lang.String url,
java.lang.String paramName,
java.lang.String parameter)
url - the String representing the URLparamName - the first half of the querystring. Such as
'filename' in the example above.parameter - the second half of the querystring. Such as
'somepath' in the example above.
public static java.util.Hashtable getAllParameters(java.lang.String queryString)
throws java.lang.StringIndexOutOfBoundsException
If a querystring has a blank value (example: 'filename= ') the name will be placed in the Hashtable paired with an empty string: "". If the querystring is otherwise malformed (example: ends with a '&') it will throw a StringIndexOutOfBoundsException.
Please note that this method automatically restores spaces in the parameters. It replaces any '+' symbols found with spaces before placing the Strings in the HashTable.
This method does not extract the jsessionid from the url. The jsessionid is ignored
Note that this method is essentially identical to the javax.servlet.http.HttpUtils.parseQueryString() method, which may be preferrable to use. This was originally developed in response to a bug in that method in the web container in which bioquery was originally hosted. This problem may now be resolved.
queryString - a String representing a URL or the querystring
from a URLjava.lang.StringIndexOutOfBoundsException - if the querystring is
malformed (does not contain a 'paramname=' after the '?' or each
'&' char.public static java.lang.String removeSpaces(java.lang.String originalString)
originalString - any String that may contain spaces.public static java.lang.String restoreSpaces(java.lang.String urlString)
urlString - any String that contains '+' where there should
be spaces.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||