hu.midori.kosmos.server.util
Class UrlUtils

java.lang.Object
  extended by hu.midori.kosmos.server.util.UrlUtils

public class UrlUtils
extends java.lang.Object

Utility methods for manipulating complicated URLs.

Version:
$Id$
Author:
Aron Gombas

Constructor Summary
UrlUtils()
           
 
Method Summary
static java.lang.String getBaseUrl(java.lang.String url)
          Returns the "base" part (the part that doesn't contain the path and query parts) of the given URL.
static java.lang.String getContextUrl(java.lang.String url)
          Returns the "base" part and the "context path" part of the given URL.
static java.lang.String parseExtensionItemFromUrl(java.lang.String url)
          Kosmos uses an extended URL format.
static java.lang.String[] parseUserInfoFromUrl(java.lang.String url)
          Returns a two-element array with the username and password from the given URL, or null if those are not specified in the URL.
static java.lang.String removeUserInfoFromUrl(java.lang.String url)
          Removes the userinfo part from the given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlUtils

public UrlUtils()
Method Detail

getBaseUrl

public static java.lang.String getBaseUrl(java.lang.String url)
                                   throws java.net.MalformedURLException
Returns the "base" part (the part that doesn't contain the path and query parts) of the given URL.

Throws:
java.net.MalformedURLException

getContextUrl

public static java.lang.String getContextUrl(java.lang.String url)
Returns the "base" part and the "context path" part of the given URL.


removeUserInfoFromUrl

public static java.lang.String removeUserInfoFromUrl(java.lang.String url)
                                              throws java.net.MalformedURLException
Removes the userinfo part from the given URL.

Returns:
the truncated URL.
Throws:
java.net.MalformedURLException

parseUserInfoFromUrl

public static java.lang.String[] parseUserInfoFromUrl(java.lang.String url)
                                               throws java.net.MalformedURLException
Returns a two-element array with the username and password from the given URL, or null if those are not specified in the URL.

Throws:
java.net.MalformedURLException

parseExtensionItemFromUrl

public static java.lang.String parseExtensionItemFromUrl(java.lang.String url)
Kosmos uses an extended URL format. It is a standard URL postfixed by a :myvalue string. This method returns this extension.