public class URITools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.net.URI |
addPath(java.net.URI uri,
java.lang.String... parts)
Concatenates all parts using the / separator at the end of URI indicated by rm parameter.
|
static boolean |
areSameUri(java.net.URI uri1,
java.net.URI uri2)
Are same uri.
|
static void |
checkSecureScheme(javax.xml.transform.sax.SAXSource source)
This method will check the content of source to find if the file indicated
is a https scheme URL rather than http URL.
|
static java.net.URI |
commonBase(java.util.List<java.net.URI> uris)
Computes the common part of incoming URIS and returns a new URI for that part.
|
static boolean |
compareAuthorityAndPath(java.net.URI uri1,
java.net.URI uri2)
Compare authority and paths of two URIs and returns true if they are equals.
|
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.StringBuilder buf)
Decodes a string according to RFC 2396.
|
static java.lang.String |
decodeUriInUTF8(java.lang.String uri)
Decode URI string and convert UTF8 encoded characters to Java string characters.
|
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.StringBuilder buf)
Encodes a string according to RFC 2396.
|
static java.lang.String |
fileName(java.lang.String path)
If the path passed contains directories this returns just the last
part of the path.
|
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 |
fixEndWithSlashString(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.lang.String |
getAuthorityAndPath(java.net.URI uri)
Returns a string that contains only the uri authority and path.
|
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.lang.String |
getFileName(java.net.URI fUri)
Returns only the file name from path in the fUri parameter or the
empty string if the fURI ends with slash.
|
static java.lang.String |
getNID(java.net.URI urn)
For URN URIs this method returns the NID.
|
static java.net.URI |
getNormalURI(java.net.URI sinonimURI)
Gets the normal uri.
|
static java.net.URL |
getURLAfterRedirects(java.net.URL testURL)
Gets the URL after redirects.
|
static java.net.URL |
getURLAfterRedirects(java.net.URL testURL,
java.lang.String method)
Gets the URL after redirects.
|
static boolean |
hasCommonBase(java.util.List<java.net.URI> uris)
Checks the list of
uris received has all the scheme and host in common
so a call to #commonBase(ArrayList) will not raise an exception. |
static java.lang.String |
hashResources()
Hash resources.
|
static java.net.URI |
makeAbsolute(java.net.URI base,
java.net.URI uri)
Make absolute.
|
static java.net.URI |
makeProperFileName(java.net.URI baseURI,
DTSContainer dts,
java.lang.String extension)
Generates an absolute file name in the same directory indicated by baseURI using the role
type to extract information from it and adding the extension indicated in the extension
parameter.
|
static java.net.URI |
makeProperFileName(java.net.URI baseURI,
XBRLRoleType role,
java.lang.String extension)
Generates an absolute file name in the same directory indicated by baseURI using the role
type to extract information from it and adding the extension indicated in the extension
parameter.
|
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 |
removeExtension(java.net.URI uri)
Removes the extension from the file name.
|
static java.net.URI |
removeFragment(java.net.URI uri)
Removes the fragment.
|
static java.lang.String |
removeTrailingSlash(java.lang.String pathName)
Removes forward slash characters and the end of this pathName.
|
static java.lang.String |
resolveXBRLScheme(java.lang.String uriIsASCII)
If the protocol of this URI is xbrl. change it to be http or file
|
static boolean |
safeCheckIsFilePath(java.lang.String uri)
Safe check is file path.
|
static boolean |
safeCheckIsFileUri(java.lang.String uri)
Returns true if the string is a valid URI.
|
static boolean |
safeCheckIsHttpUri(java.lang.String uri)
Safe check is http uri.
|
static boolean |
safeCheckIsUriValid(java.lang.String uri)
Safe check is uri valid.
|
static java.lang.String |
URItoFileString(java.lang.String path)
If the path passed in is a URI using the file scheme, this method
will return back a file name using OS conventions.
|
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.
|
public static java.net.URI getNormalURI(java.net.URI sinonimURI)
This method is provided to create a unique key to identify the URI. The converted URI might not be used to connect to any host because important information is removed such as the user info and port number
sinonimURI
- the sinonim uripublic static boolean areSameUri(java.net.URI uri1, java.net.URI uri2)
uri1
- the uri1uri2
- the uri2public static java.net.URI makeAbsolute(java.net.URI base, java.net.URI uri)
base
- the baseuri
- the uripublic static java.net.URI relativize(java.net.URI base, java.net.URI full)
base
- URIfull
- URIpublic static java.net.URI relativizeMore(java.net.URI from, java.net.URI to)
from
- URI Absolute URIto
- URI Absolute URIpublic static java.net.URI removeFragment(java.net.URI uri)
uri
- the uripublic static java.lang.String encodeUri(java.lang.String uri)
uri
- The URI to encode.public static void encodeUri(java.lang.String uri, java.lang.StringBuilder buf)
uri
- The URI to encode.buf
- The StringBuffer that the encoded URI will be appended to.encodeUri(java.lang.String)
public static java.lang.String decodeUri(java.lang.String uri)
uri
- The URI to decode.public static void decodeUri(java.lang.String uri, java.lang.StringBuilder buf)
uri
- The URI to decode.buf
- The StringBuffer that the decoded URI will be appended to.decodeUri(java.lang.String)
public static java.lang.String decodeUriInUTF8(java.lang.String uri)
uri
- the uripublic static java.lang.String packURI(java.lang.String uri, int maxLength)
uri
- the urimaxLength
- the max lengthpublic static boolean safeCheckIsFilePath(java.lang.String uri)
uri
- the uripublic static boolean safeCheckIsFileUri(java.lang.String uri)
uri
- the uripublic static boolean safeCheckIsHttpUri(java.lang.String uri)
uri
- the uripublic static boolean safeCheckIsUriValid(java.lang.String uri)
uri
- the uripublic static java.net.URI URLtoFileName(java.net.URL u)
u
- the upublic static java.lang.String resolveXBRLScheme(java.lang.String uriIsASCII)
uriIsASCII
- the uri is asciipublic static java.lang.String fixFileSchemeURIToString(java.net.URI uri)
uri
- the uripublic static java.net.URI getDetectIsURIOrFile(java.lang.String fileString) throws java.net.URISyntaxException
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.
fileString
- the file stringjava.net.URISyntaxException
- the URI syntax exceptionpublic static java.net.URI fixEndWithSlash(java.lang.String uri) throws java.net.URISyntaxException
uri
- the input string to create a uri fromjava.net.URISyntaxException
- in case the URI raises this exception when it is createdpublic static java.lang.String fixEndWithSlashString(java.lang.String uri)
uri
- the input string to create a uri frompublic static java.lang.String removeTrailingSlash(java.lang.String pathName)
pathName
- the path namepublic static java.lang.String URItoFileString(java.lang.String path)
path
- the pathpublic static java.lang.String fileName(java.lang.String path)
path
- the pathpublic static java.net.URI makeProperFileName(java.net.URI baseURI, XBRLRoleType role, java.lang.String extension)
baseURI
- the base URI to resolve the file name generated.role
- the role type to process and obtain information from in order to prepare a file nameextension
- the new file extensionpublic static java.net.URI makeProperFileName(java.net.URI baseURI, DTSContainer dts, java.lang.String extension)
baseURI
- the base URI to resolve the file name generated.dts
- the DTSContainer to obtain a name fromextension
- the new file extensionpublic static java.lang.String hashResources()
public static java.net.URI commonBase(java.util.List<java.net.URI> uris)
if the uris
parameter is null this method returns null. If the
uris
parameter is the empty array, the empty URI is returned
This method can raise URISyntaxException if the provided URIs has nothin in common
or has only the scheme in common. Use #hasCommonBase(ArrayList)
to check
for this condition prior to call this method and avoid exceptions.
uris
- list of URIs to compute the common partpublic static boolean hasCommonBase(java.util.List<java.net.URI> uris)
uris
received has all the scheme and host in common
so a call to #commonBase(ArrayList)
will not raise an exception.uris
- list of URIs to compute the common partpublic static java.lang.String getNID(java.net.URI urn)
urn
- the urnpublic static void checkSecureScheme(javax.xml.transform.sax.SAXSource source)
source
- SAXSourcepublic static java.net.URL getURLAfterRedirects(java.net.URL testURL) throws java.io.IOException
testURL
- the test URLjava.io.IOException
- Signals that an I/O exception has occurred.public static java.net.URL getURLAfterRedirects(java.net.URL testURL, java.lang.String method) throws java.io.IOException
testURL
- the test URLmethod
- the methodjava.io.IOException
- Signals that an I/O exception has occurred.public static java.net.URI addPath(java.net.URI uri, java.lang.String... parts)
uri
- the uriparts
- String parts to be addedpublic static java.net.URI removeExtension(java.net.URI uri)
uri
- the uripublic static java.lang.String getFileName(java.net.URI fUri)
fUri
- the f uripublic static java.lang.String getAuthorityAndPath(java.net.URI uri)
uri
- the uripublic static boolean compareAuthorityAndPath(java.net.URI uri1, java.net.URI uri2)
uri1
- the uri 1uri2
- the uri 2Copyright 2006-2015 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa