This documentation is part of the Link Checker Library project.

de.tw.website.linkchecker.util
Class UrlUtil

java.lang.Object
  |
  +--de.tw.website.linkchecker.util.UrlUtil

public class UrlUtil
extends java.lang.Object

Utilities for URLs.

Version:
1.0
Author:
Thomas Weinbrenner

Field Summary
static java.lang.String separator
          Separator character for URLs.
static char separatorChar
          Separator character for URLs.
 
Constructor Summary
UrlUtil()
           
 
Method Summary
static java.lang.String buildAbsoluteUrlFromRelativeReference(java.lang.String startUrl, java.lang.String relativeUrl)
          Builds an absolute URL from a relative reference from an absolute URL.
static boolean fileProtocolURL(java.lang.String url)
          Returns whether a absolute URL is of type file protocoll.
static java.lang.String getLastPartOfUrl(java.lang.String url)
          Returns the last part from the end of a URL; i.e., use '/' separator.
static java.lang.String getProtocolAndServerName(java.lang.String url)
           
static boolean isAbsoluteUrl(java.lang.String url)
          Absolute of relative URL?
static boolean isProtocolMissing(java.lang.String url)
           
static java.lang.String stripFileName(java.lang.String url)
          Strips file name or last directory name from end of url.
static java.lang.String stripLastPart(java.lang.String url)
          Strips last part (file name or directory name) including separator character from url.
static java.lang.String stripOffNameReference(java.lang.String url)
          Strips off #name part on the end of the given url.
static java.lang.String stripOffParameter(java.lang.String url)
          Strip off HTTP-Get parameters beginning with a '?'.
static java.lang.String stripPath(java.lang.String url)
          Returns the file from the end of the HTML path; i.e., use '/' separator.
static java.lang.String urlDecode(java.lang.String url)
          Decodes url-encoded URLs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

separator

public static final java.lang.String separator
Separator character for URLs.

separatorChar

public static final char separatorChar
Separator character for URLs.
Constructor Detail

UrlUtil

public UrlUtil()
Method Detail

isAbsoluteUrl

public static boolean isAbsoluteUrl(java.lang.String url)
Absolute of relative URL?
Returns:
true, if the URL is absolute.

stripPath

public static java.lang.String stripPath(java.lang.String url)
Returns the file from the end of the HTML path; i.e., use '/' separator.
Returns:
Example: returns 'Index.html' from URL 'http://www.whatever.com/Index.html'.

getLastPartOfUrl

public static java.lang.String getLastPartOfUrl(java.lang.String url)
Returns the last part from the end of a URL; i.e., use '/' separator.
Returns:
Example: returns 'Index.html' from URL 'http://www.whatever.com/Index.html'.

stripFileName

public static java.lang.String stripFileName(java.lang.String url)
Strips file name or last directory name from end of url.
See Also:
stripLastPart(java.lang.String)

stripLastPart

public static java.lang.String stripLastPart(java.lang.String url)
Strips last part (file name or directory name) including separator character from url.

fileProtocolURL

public static boolean fileProtocolURL(java.lang.String url)
Returns whether a absolute URL is of type file protocoll.

stripOffNameReference

public static java.lang.String stripOffNameReference(java.lang.String url)
Strips off #name part on the end of the given url.

stripOffParameter

public static java.lang.String stripOffParameter(java.lang.String url)
Strip off HTTP-Get parameters beginning with a '?'.

buildAbsoluteUrlFromRelativeReference

public static java.lang.String buildAbsoluteUrlFromRelativeReference(java.lang.String startUrl,
                                                                     java.lang.String relativeUrl)
Builds an absolute URL from a relative reference from an absolute URL. Assume http://localhost/whateverDir/whateverFile.html has a reference to ../index.html, this function returns http://localhost/index.html.
Parameters:
startUrl - The URL of a resource that contains a reference.
relativeUrl - The URL relative to startUrl.

urlDecode

public static java.lang.String urlDecode(java.lang.String url)
Decodes url-encoded URLs. This is a home-made implementation. I'm not sure whether it is ok, but is seams so.

isProtocolMissing

public static boolean isProtocolMissing(java.lang.String url)

getProtocolAndServerName

public static java.lang.String getProtocolAndServerName(java.lang.String url)

This documentation is part of the Link Checker Library project.