com.jaxfront.core.util
Class URLHelper

java.lang.Object
  extended by com.jaxfront.core.util.URLHelper

public class URLHelper
extends java.lang.Object


Field Summary
static java.net.URL _xuiXsdURL
           
static java.lang.String CONFIG_DIRECTORY
           
static java.lang.String EXAMPLES_DIRECTORY
           
static java.lang.String URL_SEPARATOR
           
 
Constructor Summary
URLHelper()
           
 
Method Summary
static java.lang.String canonicalize(java.lang.String path)
           
 boolean checkURL(java.lang.String url)
           
 boolean checkURL(java.net.URL url)
           
static java.lang.String createFileNameWithSuffix(java.lang.String fileName, java.lang.String suffix, java.lang.String extension)
           
static java.lang.String createFileNameWithSuffix(java.net.URL xuiUrl, java.lang.String suffix, java.lang.String extension)
          Creates the nls file name from a passing XUI URL and a language.
static java.lang.String createFileNameWithSuffix(java.net.URL xuiURL, java.lang.String fileName, java.lang.String suffix, java.lang.String extension)
           
static java.lang.String createNameWithSuffix(java.net.URL xuiURL, java.lang.String fileName, java.lang.String suffix, java.lang.String extension)
           
static java.lang.String createNLSFileName(java.net.URL xuiUrl, java.lang.String language)
          Creates the nls file name from a passing XUI URL and a language.
static java.lang.String createNLSFilePathLocation(java.net.URL xuiUrl, java.lang.String language)
          Creates the nls file path location from a passing XUI URL and a language.
static java.net.URL createNLSURL(java.net.URL xuiUrl, java.lang.String language)
          Creates a nls URL from a passing xui URL and a language.
static java.lang.String createNLSURLName(java.net.URL xuiUrl, java.lang.String language)
          Creates the nls file location from a passing XUI URL and a language.
static boolean doesUrlExist(java.net.URL url)
           
static java.net.HttpURLConnection doSend(java.lang.String aUrl2S, java.lang.String sessionId, byte[] content, java.lang.String encoding, boolean contentAsParameter)
           
static java.lang.String extractFileName(java.lang.String path)
           
static java.lang.String extractSessionId(java.lang.String response)
           
static java.net.URL getActionsURL()
           
static java.net.URL getDefaultLocationURL(java.net.URL baseUrl, java.lang.String extension)
           
static java.net.URL getDefaultXMLLocationURL(java.net.URL baseUrl)
           
static java.net.URL getDefaultXSDLocationURL(java.net.URL baseUrl)
           
static java.net.URL getDefaultXUILocationURL(java.net.URL baseUrl)
           
static java.io.File getFile(java.net.URL url)
           
static java.lang.String getFileName(java.net.URL url)
           
static java.net.URL getFunctionsURL()
           
static java.net.URL getFunctionsXSDURL()
           
static java.net.URL getHelpTemplateURL()
           
static java.lang.String getHostAddress(java.lang.String url)
          Returns the host address of an url string.
static int getHostPort(java.lang.String url)
          Returns the host port of an url string.
static java.net.URL getInternalURL(java.lang.String url)
          Try to resolve an url within the classpath.
static java.net.URL getJAXFormsURL(java.net.URL xsdURL, java.net.URL xuiURL)
           
static java.lang.String getLanguage(java.lang.String nlsFileName)
           
static java.net.URL getParentURL(java.net.URL aUrl)
           
static java.net.URL getPluginsURL()
           
static java.net.URL getPluginsXSDURL()
           
static java.net.URL getPreferencesXSDURL()
           
static java.lang.String getRelativePath(java.io.File home, java.io.File f)
          get relative path of File 'f' with respect to 'home' directory example : home = /a/b/c f = /a/d/e/x.txt s = getRelativePath(home,f) = ../..
static java.lang.String getRelativePath(java.net.URL base, java.net.URL rel)
           
static java.net.URI getUri(java.lang.String path)
           
static java.net.URI getUri(java.net.URL url)
           
static java.net.URL getUrlFromUri(java.net.URI uri)
           
static java.net.URL getUserHomeURL(java.lang.String relativeURL)
           
static java.net.URL getUserURL(java.lang.String url)
           
static java.net.URL getUserURL(java.lang.String url, boolean lookupInternal)
           
static java.net.URL getUserURL(java.net.URL targetURL, java.lang.String url)
           
static java.net.URL getUserURL(java.net.URL targetURL, java.lang.String url, boolean lookupInternal)
           
static java.net.URL getXMLDBMappingURL(java.net.URL xsdURL, java.net.URL xuiURL)
           
static java.net.URL getXUIXsdURL()
           
static boolean isDefinedLanguage(java.lang.String language)
           
static boolean isUrl(java.lang.String url)
           
static void main(java.lang.String[] args)
           
static java.net.URLConnection openConnection(java.net.URL from)
           
static java.io.InputStream openStream(java.net.URL from)
          Opens a connection to this URL and returns an InputStream for reading from that connection.
static boolean pointToSameFolder(java.net.URL url1, java.net.URL url2)
           
static java.lang.StringBuffer readResponse(java.net.HttpURLConnection con)
           
static java.net.URI relativize(java.net.URL base, java.net.URI rel)
           
static java.net.URI relativize(java.net.URL base, java.net.URL rel)
           
static java.net.URI resolve(java.lang.String base, java.lang.String rel)
          Merges a base path with a relative path. result is: /a/b/c -> ..
static java.net.URI resolve(java.net.URL base, java.lang.String rel)
           
static boolean urlResourceExist(java.net.URL resURL)
           
static java.io.File urlToFile(java.net.URL url)
           
static void writeResponse(java.net.HttpURLConnection con, java.lang.String content)
           
static void writeToUrl(java.net.URL storeToUrl, char[] buffer)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_xuiXsdURL

public static java.net.URL _xuiXsdURL

CONFIG_DIRECTORY

public static final java.lang.String CONFIG_DIRECTORY
See Also:
Constant Field Values

EXAMPLES_DIRECTORY

public static final java.lang.String EXAMPLES_DIRECTORY
See Also:
Constant Field Values

URL_SEPARATOR

public static final java.lang.String URL_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

URLHelper

public URLHelper()
Method Detail

canonicalize

public static java.lang.String canonicalize(java.lang.String path)

checkURL

public boolean checkURL(java.lang.String url)

checkURL

public boolean checkURL(java.net.URL url)

createFileNameWithSuffix

public static java.lang.String createFileNameWithSuffix(java.lang.String fileName,
                                                        java.lang.String suffix,
                                                        java.lang.String extension)

createFileNameWithSuffix

public static java.lang.String createFileNameWithSuffix(java.net.URL xuiUrl,
                                                        java.lang.String suffix,
                                                        java.lang.String extension)
Creates the nls file name from a passing XUI URL and a language.

Parameters:
xuiUrl -
language -

createFileNameWithSuffix

public static java.lang.String createFileNameWithSuffix(java.net.URL xuiURL,
                                                        java.lang.String fileName,
                                                        java.lang.String suffix,
                                                        java.lang.String extension)

createNameWithSuffix

public static java.lang.String createNameWithSuffix(java.net.URL xuiURL,
                                                    java.lang.String fileName,
                                                    java.lang.String suffix,
                                                    java.lang.String extension)

createNLSFileName

public static java.lang.String createNLSFileName(java.net.URL xuiUrl,
                                                 java.lang.String language)
Creates the nls file name from a passing XUI URL and a language.

Parameters:
xuiUrl -
language -

createNLSFilePathLocation

public static java.lang.String createNLSFilePathLocation(java.net.URL xuiUrl,
                                                         java.lang.String language)
Creates the nls file path location from a passing XUI URL and a language.

Parameters:
xuiUrl -
language -

createNLSURL

public static java.net.URL createNLSURL(java.net.URL xuiUrl,
                                        java.lang.String language)
Creates a nls URL from a passing xui URL and a language.

Parameters:
xuiUrl -
language -
Returns:

createNLSURLName

public static java.lang.String createNLSURLName(java.net.URL xuiUrl,
                                                java.lang.String language)
Creates the nls file location from a passing XUI URL and a language.

Parameters:
xuiUrl -
language -

doesUrlExist

public static boolean doesUrlExist(java.net.URL url)

doSend

public static java.net.HttpURLConnection doSend(java.lang.String aUrl2S,
                                                java.lang.String sessionId,
                                                byte[] content,
                                                java.lang.String encoding,
                                                boolean contentAsParameter)
                                         throws java.net.MalformedURLException,
                                                java.io.IOException,
                                                java.net.ProtocolException
Throws:
java.net.MalformedURLException
java.io.IOException
java.net.ProtocolException

extractFileName

public static java.lang.String extractFileName(java.lang.String path)

extractSessionId

public static java.lang.String extractSessionId(java.lang.String response)

getActionsURL

public static java.net.URL getActionsURL()

getDefaultLocationURL

public static java.net.URL getDefaultLocationURL(java.net.URL baseUrl,
                                                 java.lang.String extension)

getDefaultXMLLocationURL

public static java.net.URL getDefaultXMLLocationURL(java.net.URL baseUrl)

getDefaultXSDLocationURL

public static java.net.URL getDefaultXSDLocationURL(java.net.URL baseUrl)

getDefaultXUILocationURL

public static java.net.URL getDefaultXUILocationURL(java.net.URL baseUrl)

getFile

public static java.io.File getFile(java.net.URL url)

getFileName

public static java.lang.String getFileName(java.net.URL url)

getFunctionsURL

public static java.net.URL getFunctionsURL()

getFunctionsXSDURL

public static java.net.URL getFunctionsXSDURL()

getHelpTemplateURL

public static java.net.URL getHelpTemplateURL()

getHostAddress

public static java.lang.String getHostAddress(java.lang.String url)
Returns the host address of an url string. Return null if no address is specified.

Parameters:
url - url string.

getHostPort

public static int getHostPort(java.lang.String url)
Returns the host port of an url string. Return -1 if no port is specified.

Parameters:
url - url string.

getInternalURL

public static java.net.URL getInternalURL(java.lang.String url)
Try to resolve an url within the classpath. All config & examples should first be tried to resolve through directory structure before loading from any jar.

Parameters:
url -

getJAXFormsURL

public static java.net.URL getJAXFormsURL(java.net.URL xsdURL,
                                          java.net.URL xuiURL)

getLanguage

public static java.lang.String getLanguage(java.lang.String nlsFileName)

getParentURL

public static java.net.URL getParentURL(java.net.URL aUrl)

getPluginsURL

public static java.net.URL getPluginsURL()

getPluginsXSDURL

public static java.net.URL getPluginsXSDURL()

getPreferencesXSDURL

public static java.net.URL getPreferencesXSDURL()

getRelativePath

public static java.lang.String getRelativePath(java.io.File home,
                                               java.io.File f)
get relative path of File 'f' with respect to 'home' directory example : home = /a/b/c f = /a/d/e/x.txt s = getRelativePath(home,f) = ../../d/e/x.txt

Parameters:
home - base path, should be a directory, not a file, or it doesn't make sense
f - file to generate path for
Returns:
path from home to f as a string

getRelativePath

public static java.lang.String getRelativePath(java.net.URL base,
                                               java.net.URL rel)

getUri

public static java.net.URI getUri(java.lang.String path)
                           throws java.net.URISyntaxException
Throws:
java.net.URISyntaxException

getUri

public static java.net.URI getUri(java.net.URL url)
                           throws java.net.URISyntaxException
Throws:
java.net.URISyntaxException

getUrlFromUri

public static java.net.URL getUrlFromUri(java.net.URI uri)
                                  throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

getUserHomeURL

public static java.net.URL getUserHomeURL(java.lang.String relativeURL)

getUserURL

public static java.net.URL getUserURL(java.lang.String url)

getUserURL

public static java.net.URL getUserURL(java.lang.String url,
                                      boolean lookupInternal)

getUserURL

public static java.net.URL getUserURL(java.net.URL targetURL,
                                      java.lang.String url)

getUserURL

public static java.net.URL getUserURL(java.net.URL targetURL,
                                      java.lang.String url,
                                      boolean lookupInternal)

getXMLDBMappingURL

public static java.net.URL getXMLDBMappingURL(java.net.URL xsdURL,
                                              java.net.URL xuiURL)

getXUIXsdURL

public static java.net.URL getXUIXsdURL()

isDefinedLanguage

public static boolean isDefinedLanguage(java.lang.String language)

isUrl

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

main

public static void main(java.lang.String[] args)
                 throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

openConnection

public static java.net.URLConnection openConnection(java.net.URL from)
                                             throws java.io.IOException
Throws:
java.io.IOException

openStream

public static java.io.InputStream openStream(java.net.URL from)
                                      throws java.io.IOException
Opens a connection to this URL and returns an InputStream for reading from that connection. This method is a shorthand for:
 openConnection().getInputStream()
 

Returns:
an input stream for reading from the URL connection.
Throws:
java.io.IOException - if an I/O exception occurs.
See Also:
URL.openConnection(), URLConnection.getInputStream()

pointToSameFolder

public static boolean pointToSameFolder(java.net.URL url1,
                                        java.net.URL url2)

readResponse

public static java.lang.StringBuffer readResponse(java.net.HttpURLConnection con)
                                           throws java.io.IOException
Throws:
java.io.IOException

relativize

public static java.net.URI relativize(java.net.URL base,
                                      java.net.URI rel)

relativize

public static java.net.URI relativize(java.net.URL base,
                                      java.net.URL rel)

resolve

public static java.net.URI resolve(java.lang.String base,
                                   java.lang.String rel)
Merges a base path with a relative path. result is: /a/b/c -> ../d = /a/b/d

Parameters:
base -
rel -
Returns:

resolve

public static java.net.URI resolve(java.net.URL base,
                                   java.lang.String rel)

urlResourceExist

public static boolean urlResourceExist(java.net.URL resURL)

urlToFile

public static java.io.File urlToFile(java.net.URL url)

writeResponse

public static void writeResponse(java.net.HttpURLConnection con,
                                 java.lang.String content)
                          throws java.io.IOException
Throws:
java.io.IOException

writeToUrl

public static void writeToUrl(java.net.URL storeToUrl,
                              char[] buffer)
                       throws java.io.IOException
Throws:
java.io.IOException