com.jaxfront.core.util
Class URLHelper

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

public class URLHelper
extends java.lang.Object

Author:
srzxuz TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

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
 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)
          Creates the nls file name from a passing file name (string) and a language.
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.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 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.net.URL base, java.lang.String rel)
           
static boolean urlResourceExist(java.net.URL resURL)
           
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

URL_SEPARATOR

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

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

_xuiXsdURL

public static java.net.URL _xuiXsdURL
Constructor Detail

URLHelper

public URLHelper()
Method Detail

getXUIXsdURL

public static java.net.URL getXUIXsdURL()

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

readResponse

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

writeResponse

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

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

extractSessionId

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

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()

getUrlFromUri

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

getUserURL

public static java.net.URL getUserURL(java.net.URL targetURL,
                                      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.lang.String url)

getUserURL

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

getPluginsURL

public static java.net.URL getPluginsURL()

getActionsURL

public static java.net.URL getActionsURL()

getHelpTemplateURL

public static java.net.URL getHelpTemplateURL()

getFunctionsURL

public static java.net.URL getFunctionsURL()

getFunctionsXSDURL

public static java.net.URL getFunctionsXSDURL()

getPluginsXSDURL

public static java.net.URL getPluginsXSDURL()

getPreferencesXSDURL

public static java.net.URL getPreferencesXSDURL()

getUserHomeURL

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

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 -

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.

writeToUrl

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

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.

getFile

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

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:

isDefinedLanguage

public static boolean isDefinedLanguage(java.lang.String 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 -

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 -

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.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 fileName,
                                                        java.lang.String suffix,
                                                        java.lang.String extension)
Creates the nls file name from a passing file name (string) and a language.

Parameters:
fileName - name of the file
suffix - file suffix
extension - file extension

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 -

extractFileName

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

getParentURL

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

getDefaultXUILocationURL

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

getDefaultXSDLocationURL

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

getDefaultXMLLocationURL

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

getDefaultLocationURL

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

doesUrlExist

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

pointToSameFolder

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

relativize

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

relativize

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

resolve

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

getRelativePath

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

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

getFileName

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

isUrl

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

checkURL

public boolean checkURL(java.lang.String url)

checkURL

public boolean checkURL(java.net.URL url)

getXMLDBMappingURL

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

getJAXFormsURL

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

urlResourceExist

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