|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.portal.common.net.URLTools
public class URLTools
Nested Class Summary | |
---|---|
static class |
URLTools.PortReplacementGenerator
|
static class |
URLTools.URLMatch
|
static class |
URLTools.URLReplacementGenerator
|
Field Summary | |
---|---|
static java.lang.String |
FILE_PREFIX
|
static java.lang.String |
FTP_PREFIX
|
static java.lang.String |
HTTP_PREFIX
|
static java.lang.String |
HTTPS_PREFIX
|
static java.lang.String |
RE_EMAIL_VALIDATION
|
Constructor Summary | |
---|---|
URLTools()
|
Method Summary | |
---|---|
static java.lang.String |
decodeXWWWFormURL(java.lang.String s)
|
static java.lang.String |
encodeXWWWFormURL(java.lang.String s)
|
static void |
enforceAbsoluteURL(java.lang.String url)
Enforces that the given URL is absolute |
static boolean |
exists(java.lang.String stringURL,
boolean allowNull)
to remove : an API should not try to accomodate the client for that kind of situation, why not also something like forbidStringLengthToDivisibleBy3 ? |
static boolean |
exists(java.net.URL url)
Determines that the specified URL corresponds to an existing resource by trying to open a stream from it. |
static boolean |
exists(java.net.URL url,
long waitForMillis)
Determines if the specified URL corresponds to an existing resource by trying to open a stream from it. |
static URLTools.URLMatch[] |
extractURLsFrom(java.lang.String markup)
|
static byte[] |
getContent(java.net.URL url,
int soTimeoutMillis,
int connTimeoutMillis)
Fetches content from of the URL as a byte array or null if a problem occurred. |
static java.io.InputStream |
getContentAsInputStream(java.net.URL url,
int soTimeoutMillis,
int connTimeoutMillis)
Fetches content from URL as an InputStream. |
static int |
getURLCountIn(java.lang.String markup)
|
static boolean |
isEmailValid(java.lang.String address)
Return true is the address is not null and matches the email validation regular expression. |
static boolean |
isNetworkURL(java.lang.String url)
|
static boolean |
isURLAbsolute(java.lang.String url)
|
static java.lang.String |
replaceServerPortInURL(java.lang.String url,
int newPort)
|
static java.lang.String |
replaceURLsBy(java.lang.String markup,
java.lang.String[] replacements)
|
static java.lang.String |
replaceURLsBy(java.lang.String markup,
URLTools.URLReplacementGenerator generator)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String RE_EMAIL_VALIDATION
public static final java.lang.String HTTP_PREFIX
public static final java.lang.String HTTPS_PREFIX
public static final java.lang.String FTP_PREFIX
public static final java.lang.String FILE_PREFIX
Constructor Detail |
---|
public URLTools()
Method Detail |
---|
public static boolean isURLAbsolute(java.lang.String url)
public static byte[] getContent(java.net.URL url, int soTimeoutMillis, int connTimeoutMillis) throws java.lang.IllegalArgumentException
null
if a problem occurred. The timeout values
must not be negative integers, when it is equals to zero it means that it does not setup a timeout and use the
default values.
url
- the URL the URL of the resourcesoTimeoutMillis
- the socket connection timeout in millisconnTimeoutMillis
- the connection timeout in millis
java.lang.IllegalArgumentException
- if the URL is null or any time out value is negativepublic static java.io.InputStream getContentAsInputStream(java.net.URL url, int soTimeoutMillis, int connTimeoutMillis) throws java.io.IOException
url
- the URL the URL of the resourcesoTimeoutMillis
- the socket connection timeout in millisconnTimeoutMillis
- the connection timeout in millis
java.lang.IllegalArgumentException
- if the URL is null or any time out value is negative
java.io.IOException
public static boolean isNetworkURL(java.lang.String url)
url
-
public static void enforceAbsoluteURL(java.lang.String url) throws java.lang.IllegalArgumentException
url
- the String representation of the URL to be checked
java.lang.IllegalArgumentException
- if the given URL is not absolutepublic static java.lang.String encodeXWWWFormURL(java.lang.String s)
public static java.lang.String decodeXWWWFormURL(java.lang.String s)
public static boolean isEmailValid(java.lang.String address)
public static boolean exists(java.net.URL url)
exists(url, 1000)
url
-
public static boolean exists(java.net.URL url, long waitForMillis) throws java.lang.IllegalArgumentException
url
- the URL to be testedwaitForMillis
- the number of milliseconds to wait before timing out, 0 meaning never timing out.
java.lang.IllegalArgumentException
- if the url is null or the time out negativepublic static boolean exists(java.lang.String stringURL, boolean allowNull)
stringURL
- allowNull
- true
if passing null
will be ignored and just return
false
, false
to throw an IllegalArgumentException
is the given
URL is null
.
public static URLTools.URLMatch[] extractURLsFrom(java.lang.String markup)
public static int getURLCountIn(java.lang.String markup)
public static java.lang.String replaceURLsBy(java.lang.String markup, java.lang.String[] replacements)
public static java.lang.String replaceURLsBy(java.lang.String markup, URLTools.URLReplacementGenerator generator)
public static java.lang.String replaceServerPortInURL(java.lang.String url, int newPort)
url
- newPort
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |