Object
URIs are a crucial part of the Workshop API. This class provides a number of simple methods to improve manipulation of URIs. Wherever possible, these methods should be used to create, manipulate and inspect URIs. In particular there are a number of inconsistencies in the Java Runtime implementation of URI. UNC paths are not handled consistently between URI and java.io.File. Also URIs can be hard to inspect safely for filenames, extensions, etc... The methods below provide safe ways to perform these actions and should be used exclusively.
Object
URIUtil
Constructor Summary |
|
Method Summary |
public static |
|
public static |
|
public static | |
public static | |
public static | |
public static |
|
public static |
|
public static |
|
public static | |
public static | |
public static | |
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static | |
public static boolean |
|
public static boolean |
|
public static boolean | |
public static boolean | |
public static boolean | |
public static | |
public static | |
public static | |
public static |
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public URIUtil()
Method Detail |
public staticChange the scheme of a URIURI
changeScheme(URI
uri,String
newScheme)
public staticcreates a new URI using the specified URI as the parent of the new URIURI
createFromParent(URI
uriParent,String
sName, boolean isDir)
DEPRECATED
public staticCreate a URI encoding the string as appropriateURI
createURI(String
unencodedUriString)
throwsURISyntaxException
URISyntaxException
DEPRECATED
public staticCreate a URI encoding the strings as appropriateURI
createURI(String
unencodedScheme,String
unencodedSSP,String
unencodedFragment)
throwsURISyntaxException
URISyntaxException
DEPRECATED
public staticCreate a URI encoding the strings as appropriateURI
createURI(String
unencodedScheme,String
unencodedSSP)
throwsURISyntaxException
URISyntaxException
DEPRECATED
public staticCreate a URI from an already encoded stringURI
createURINoEncode(String
encodedUriString)
throwsURISyntaxException
URISyntaxException
DEPRECATED
public staticCreate a URI from an already encoded set of stringsURI
createURINoEncode(String
encodedScheme,String
encodedSSP,String
encodedFragment)
throwsURISyntaxException
URISyntaxException
DEPRECATED
public staticCreate a URI from an already encoded set of stringsURI
createURINoEncode(String
encodedScheme,String
encodedSSP)
throwsURISyntaxException
URISyntaxException
public staticString
decode(String
s)
public staticString
encode(String
s)
public staticConstruct a URI from the given file. This method will canonicalize the file before converting it to a URIURI
fromFile(File
f)
public staticCreate a URI from the given string.URI
fromString(String
path)
public staticGet the file extension for this URI.String
getExtension(URI
uri)
DEPRECATED Please use FileSvc.get().getIFile(uri).getName().
public staticreturns the filename portion of the uriString
getFilename(URI
uri)
public staticThis will return the path portion of the uri as an OS-specific path to the file if the URI points to a file, or just the path if it is not. For instance, on Windows, the leading '/' is trimmed for windows drive letters, and UNC paths are resolved correctly.String
getFilePath(URI
uri)
public staticString
getInternalPath(URI
uri)
public staticreturns the parent path of the URI. if this uri is a directory, it will return the parent of the directory.String
getParentPath(URI
uri)
DEPRECATED Please use FileSvc.get().getIFile(uri).getParentIFile().getURI().
public staticreturns the parent URI of the URI. this is a shortcut for generating a new uri using the parent path.URI
getParentURI(URI
uri)
public staticReturn the scheme of this uri.String
getScheme(URI
uri)
public static boolean isAncestor(Determines whether one URI is the parent of anotherURI
parent,URI
child)
public static boolean isDirectory(URI
uri)
Determines if the given URI is a directory. The standard mechanism is
to check for a trailing "/". This method will attempt to conver the
URI to a file if appropriate and verify this assumption. If the file
is a directory, but doesn't have a "/" it will assert.
public static boolean isFile(URI
uri)
Determines if the given URI is a file. This merely means that it is
not a directory.
public static boolean isFileURI(URI
uri)
Determine if the given URI represents a file object
public static boolean isUrlURI(URI
uri)
Determine if the given URI represents an http or ftp object
public staticNormalize the URI. This is just likeURI
normalize(URI
uri)
URI.normalize()
however it is consistent with java.io.File in how it constructs URIs
for UNC Paths, preserving the leading double slash and empty authority.
public staticResolve the URI. This is just likeURI
resolve(URI
base,URI
child)
URI.resolve(String)
however it is consistent with java.io.File in how it constructs URIs
for UNC Paths, preserving the leading double slash and empty authority.
public staticResolve the URI. This is just likeURI
resolve(URI
base,String
child)
URI.resolve(String)
however
it is consistent with java.io.File in how it constructs URIs for UNC
Paths, preserving the leading double slash and empty authority
DEPRECATED Please use FileSvc.get().getIFile(URI).getFile() if you need a file. Please consider not using the final getFile() if an IFile will suffice.
public staticConverts the given URI into a Java file object.File
toFile(URI
uri)