com.ihr.xbrl.util
Class URITools

java.lang.Object
  extended by com.ihr.xbrl.util.URITools

public class URITools
extends java.lang.Object


Constructor Summary
URITools()
           
 
Method Summary
static boolean areSameUri(java.net.URI uri1, java.net.URI uri2)
           
static java.lang.String decodeUri(java.lang.String uri)
          Decodes a string according to RFC 2396.
static void decodeUri(java.lang.String uri, java.lang.StringBuffer buf)
          Decodes a string according to RFC 2396.
static java.lang.String encodeUri(java.lang.String uri)
          Encodes a string according to RFC 2396.
static void encodeUri(java.lang.String uri, java.lang.StringBuffer buf)
          Encodes a string according to RFC 2396.
static java.net.URI fixEndWithSlash(java.lang.String uri)
          Creates an URI that ends with a slash character '/' if the input string in the uri parameter does not ends with the slash character.
static java.lang.String fixFileSchemeURIToString(java.net.URI uri)
          If the URI passed in as a parameter is of the file: scheme, then toString does not return file:/// but file:/ This seems to be incorrect so this method just fix this.
static java.net.URI getDetectIsURIOrFile(java.lang.String fileString)
          Detects if the input string is a file uri, a remote uri or a local file name and returns a uri pointing to the target.
static java.net.URI getNormalURI(java.net.URI sinonimURI)
           
static java.net.URI makeAbsolute(java.net.URI base, java.net.URI uri)
           
static java.lang.String packURI(java.lang.String uri, int maxLength)
          Takes a string representation of an URI and packs it to a maximum length of maxLenght characters.
static java.net.URI relativize(java.net.URI base, java.net.URI full)
          Creates a new URI that contains a path relative to the base URI.
static java.net.URI relativizeMore(java.net.URI from, java.net.URI to)
          Computes a relative path from the URI in the from argument to the URI in the to argument This function does not work if the incoming parameters contain several slashes together ie (file:/C:/hello////this%20is%20a%20test)
static java.net.URI removeFragment(java.net.URI uri)
           
static java.net.URI URLtoFileName(java.net.URL u)
          This function transforms a URL of the form file:/C:/Program Files/svs/xbrljlib-2.0.jar into a proper file URI to be used as a parameter for the File(URI) method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URITools

public URITools()
Method Detail

getNormalURI

public static java.net.URI getNormalURI(java.net.URI sinonimURI)

areSameUri

public static boolean areSameUri(java.net.URI uri1,
                                 java.net.URI uri2)

makeAbsolute

public static java.net.URI makeAbsolute(java.net.URI base,
                                        java.net.URI uri)

relativize

public static java.net.URI relativize(java.net.URI base,
                                      java.net.URI full)
Creates a new URI that contains a path relative to the base URI. This function does not adds .. to go from the base path to the full path

Parameters:
base - URI
full - URI
Returns:
URI

relativizeMore

public static java.net.URI relativizeMore(java.net.URI from,
                                          java.net.URI to)
Computes a relative path from the URI in the from argument to the URI in the to argument This function does not work if the incoming parameters contain several slashes together ie (file:/C:/hello////this%20is%20a%20test)

Parameters:
from - URI Absolute URI
to - URI Absolute URI
Returns:
URI

removeFragment

public static java.net.URI removeFragment(java.net.URI uri)

encodeUri

public static java.lang.String encodeUri(java.lang.String uri)
Encodes a string according to RFC 2396. According to this spec, any characters outside the range 0x20 - 0x7E must be escaped because they are not printable characters, except for characters in the fragment identifier. Even within this range a number of characters must be escaped. This method will perform this escaping.

Parameters:
uri - The URI to encode.
Returns:
The encoded URI.

encodeUri

public static void encodeUri(java.lang.String uri,
                             java.lang.StringBuffer buf)
Encodes a string according to RFC 2396.

Parameters:
uri - The URI to encode.
buf - The StringBuffer that the encoded URI will be appended to.
See Also:
encodeUri(java.lang.String)

decodeUri

public static java.lang.String decodeUri(java.lang.String uri)
Decodes a string according to RFC 2396. According to this spec, any characters outside the range 0x20 - 0x7E must be escaped because they are not printable characters, except for any characters in the fragment identifier. This method will translate any escaped characters back to the original.

Parameters:
uri - The URI to decode.
Returns:
The decoded URI.

decodeUri

public static void decodeUri(java.lang.String uri,
                             java.lang.StringBuffer buf)
Decodes a string according to RFC 2396.

Parameters:
uri - The URI to decode.
buf - The StringBuffer that the decoded URI will be appended to.
See Also:
decodeUri(java.lang.String)

packURI

public static java.lang.String packURI(java.lang.String uri,
                                       int maxLength)
Takes a string representation of an URI and packs it to a maximum length of maxLenght characters.

Parameters:
uri -
maxLength -
Returns:
String
Since:
2.6.8

URLtoFileName

public static java.net.URI URLtoFileName(java.net.URL u)
This function transforms a URL of the form file:/C:/Program Files/svs/xbrljlib-2.0.jar into a proper file URI to be used as a parameter for the File(URI) method. http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx

Parameters:
u -
Returns:

fixFileSchemeURIToString

public static java.lang.String fixFileSchemeURIToString(java.net.URI uri)
If the URI passed in as a parameter is of the file: scheme, then toString does not return file:/// but file:/ This seems to be incorrect so this method just fix this. If the URI is of any other type, this method just returns the passedIn URI converted to String using URI.toString()

Parameters:
uri -
Returns:

getDetectIsURIOrFile

public static java.net.URI getDetectIsURIOrFile(java.lang.String fileString)
                                         throws java.net.URISyntaxException
Detects if the input string is a file uri, a remote uri or a local file name and returns a uri pointing to the target.

if the string starts with file: this is a local file uri. if the string starts with http: this is a remote file uri. if the string contains no scheme, then threat it as a local file in the local directory.

Parameters:
confFileText -
Returns:
Throws:
java.net.URISyntaxException

fixEndWithSlash

public static java.net.URI fixEndWithSlash(java.lang.String uri)
                                    throws java.net.URISyntaxException
Creates an URI that ends with a slash character '/' if the input string in the uri parameter does not ends with the slash character.

Parameters:
uri - the input string to create a uri from
Returns:
new URI just created from the string or the string after adding a trailing slash character
Throws:
java.net.URISyntaxException - in case the URI raises this exception when it is created


Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa