|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.senn.magic.util.WebUtils
public final class WebUtils
This class provides useful methods for web related development.
Some of the methods are similar to some servlet methods (working with request parameters).
| Field Summary | |
|---|---|
static String |
PARAM_SEPARATOR_CHAR
The character used to separate the request parameters: & |
static String |
PARAM_START_CHAR
The character used to indicate the start of the request parameters: ? |
static String |
PARAM_VALUE_CHAR
The character used to show the value of a request parameter: = |
static String |
PROTOCOL_SEPARATOR
The character sequence used to indicate the end of the protocol name: ://For example: http://senn-magic.blogspot.com |
| Method Summary | |
|---|---|
static String |
getBitlyURL(String login,
String apiKey,
String longURL)
This method shortens a provided url using the Bitly API. |
static String |
getDummyContent(int lineAmount)
Provides dummy content for filling up a web page with dummy content. |
static int |
getParameterCount(String url)
Counts how many request parameters a url contains |
static Map<String,String> |
getParameterMap(String url)
Gets all the request parameters of a url with their values. |
static String |
getParameterValue(String url,
String paramKey,
boolean ignoreCase)
Gets the value of the provided request parameter |
static String |
getProtocol(String url)
Returns the protocol name of the provided url. |
static String |
getTinyURL(String longURL)
This method shortens a provided url using the TinyURL API. |
static void |
openURL(String url)
This method opens the provided url in the system's default browser. |
static boolean |
parameterExists(String url,
String paramKey)
Checks if a parameter exists in the provided url. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PARAM_START_CHAR
?
public static final String PARAM_SEPARATOR_CHAR
&
public static final String PARAM_VALUE_CHAR
=
public static final String PROTOCOL_SEPARATOR
://http://senn-magic.blogspot.com
| Method Detail |
|---|
public static void openURL(String url)
throws Exception
Desktop can be found and will try to launch the browser
from the Desktop class.Runtime.getRuntime().exec() which may affect the
performance of your application.WebUtils.openURL(String) method from
BareBonesBrowserLaunch
url - the url of the webpage you want to open
Exceptionpublic static String getDummyContent(int lineAmount)
lineAmount - the amount of lines (separated by <br />)
String - the dummy contentStringUtils.getFillerText(int, String)public static String getProtocol(String url)
url = "http://senn-magic.blogspot.com" will return "http"
null when no valid protocol name is found
url -
String - the protocol of the urlpublic static Map<String,String> getParameterMap(String url)
Map if no parameters are present, and null when the
url is invalid
url -
Map - a Map containing the parameters and their valuespublic static int getParameterCount(String url)
url -
int - the amount of parameters
public static boolean parameterExists(String url,
String paramKey)
url - paramKey - the name of the parameter you want to check - this is case sensitive
boolean - true if the parameter exists, false if it doesn't
public static String getParameterValue(String url,
String paramKey,
boolean ignoreCase)
url - paramKey - the name of the parameterignoreCase - set to false if you want @param paramKey to be case sensitive
String - the value of the parameter, or null if the parameter doesn't exist
public static String getBitlyURL(String login,
String apiKey,
String longURL)
throws org.apache.commons.httpclient.HttpException,
IOException,
Exception
http://senn-magic.blogspot.com => http://bit.ly/bPvmjY
login - a valid Bitly loginapiKey - a valid Bitly API-key associated with the loginlongURL - the url to shorten
String - a shortened link to your url (ie. http://bit.ly/bPvmjY)
HttpException
IOException
Exception
public static String getTinyURL(String longURL)
throws org.apache.commons.httpclient.HttpException,
IOException
http://senn-magic.blogspot.com => http://tinyurl.com/ylj7zwb
longURL - the url to shorten
String - a shortened link to your url (ie. http://tinyurl.com/ylj7zwb)
HttpException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||