com.atlassian.renderer.util
Class UrlUtil

java.lang.Object
  extended by com.atlassian.renderer.util.UrlUtil

public class UrlUtil
extends Object


Field Summary
static List URL_PROTOCOLS
           
protected static int URL_SCHEMA_LENGTH
          Maximum length of a URL schema, e.g.
 
Constructor Summary
UrlUtil()
           
 
Method Summary
static String buildNewRelativeUrl(javax.servlet.http.HttpServletRequest request, String name, String value)
          Deprecated. since 3.12 this is not used. Builds a URL with a new parameter, replacing any existing parameters with that name but maintaining all other parameters.

For example /foo.html?name=fred&key=FLINT

static boolean containsUrl(String str)
           
static String correctBaseUrls(String html, String baseUrl)
          Fixes the URLs used in content imported from external sources to have a base URL that points to that external source.
static String escapeSpecialCharacters(String url)
          Deprecated. since 3.12 use HtmlEscaper.escapeAmpersands(String,boolean) passing 'true' to preserveExistingEntities.
static String escapeUrlFirstCharacter(String linkBody)
           
static Map getQueryParameters(String url)
          Returns a map of query parameters extracted the given url.
static int getUrlIndex(String str)
           
static boolean startsWithUrl(String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_PROTOCOLS

public static final List URL_PROTOCOLS

URL_SCHEMA_LENGTH

protected static final int URL_SCHEMA_LENGTH
Maximum length of a URL schema, e.g. "https://"

See Also:
Constant Field Values
Constructor Detail

UrlUtil

public UrlUtil()
Method Detail

escapeSpecialCharacters

public static String escapeSpecialCharacters(String url)
Deprecated. since 3.12 use HtmlEscaper.escapeAmpersands(String,boolean) passing 'true' to preserveExistingEntities.

Will return a new string with ampersands replaced with '&'.

Returns:
the safe(r) string

startsWithUrl

public static boolean startsWithUrl(String str)

containsUrl

public static boolean containsUrl(String str)

getUrlIndex

public static int getUrlIndex(String str)

escapeUrlFirstCharacter

public static String escapeUrlFirstCharacter(String linkBody)

correctBaseUrls

public static String correctBaseUrls(String html,
                                     String baseUrl)
Fixes the URLs used in content imported from external sources to have a base URL that points to that external source. For example, where a JIRA portlet uses a URL relative to JIRA, the JIRA base URL should be prepended so Confluence users see the correct URL.

Links are fixed in href and src attributes in the HTML. Different types of links are treated differently (assuming a baseUrl of "http://www.example.com/path/to/file.html"):

Parameters:
html - the HTML text which will have its links corrected to match the base URL of the remote server.
baseUrl - the URL which local links will be made relative to. Typically this is the base URL of the remote content.
Returns:
HTML text modified so all links point to the remote content.

buildNewRelativeUrl

public static String buildNewRelativeUrl(javax.servlet.http.HttpServletRequest request,
                                         String name,
                                         String value)
Deprecated. since 3.12 this is not used. Builds a URL with a new parameter, replacing any existing parameters with that name but maintaining all other parameters.

For example /foo.html?name=fred&key=FLINT

Parameters:
request - The current request
name - The name of the parameter to add/replace
value - The value of the parameter to add/replace

getQueryParameters

public static Map getQueryParameters(String url)
Returns a map of query parameters extracted the given url.

Parameters:
url - to extract query parameters from
Returns:
a Map of query parameters


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.