Package aQute.libg.uri
Class URIUtil
- java.lang.Object
-
- aQute.libg.uri.URIUtil
-
public final class URIUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.net.URIEMPTYURIprivate static java.util.regex.PatternWINDOWS_FILE_PATTERN
-
Constructor Summary
Constructors Constructor Description URIUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetDefaultPort(java.lang.String scheme)static booleanisRemote(java.net.URI uri)Answer if the given URL is on the local system or remotestatic java.util.Optional<java.nio.file.Path>pathFromURI(java.lang.String uriString)Attempts to fetch a path on the file system for the given URI string.private static java.util.Optional<java.nio.file.Path>pathFromURI(java.lang.String uriString, java.net.URI uri)static java.util.Optional<java.nio.file.Path>pathFromURI(java.net.URI uri)Attempts to fetch a path on the file system for the given URI.static java.net.URIresolve(java.net.URI baseURI, java.lang.String reference)Resolves a URI reference against a base URI.
-
-
-
Method Detail
-
resolve
public static java.net.URI resolve(java.net.URI baseURI, java.lang.String reference) throws java.net.URISyntaxExceptionResolves a URI reference against a base URI. Work-around for bugs in java.net.URI (e.g.http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708535)- Parameters:
baseURI-reference-- Returns:
- the resolved
URI - Throws:
java.net.URISyntaxException
-
pathFromURI
public static java.util.Optional<java.nio.file.Path> pathFromURI(java.lang.String uriString)
Attempts to fetch a path on the file system for the given URI string. Tries a few more tricks than the standard method of Paths.get(new URI(uriString)) - it can handle plain paths, and also nested URI pseudo-schemes like reference: and jar:. Examples:- /path/to/file => /path/to/file
- reference:file:/path/to/file => /path/to/file
- jar:file:/path/to/file.jar!/some/contained/element => /path/to/file.jar
- http://server/path/to/file => null
- Parameters:
uriString- The URI string for which we are attempting to construct a path.- Returns:
- The method's best guess as to which file on the local filesystem this URI refers, or an empty Optional if it's invalid or not a local filesystem URI.
-
pathFromURI
public static java.util.Optional<java.nio.file.Path> pathFromURI(java.net.URI uri)
Attempts to fetch a path on the file system for the given URI. Tries a few more tricks than the standard method of Paths.get(uri) - it can handle plain paths, and also nested URI pseudo-schemes like reference: and jar:. Examples:- /path/to/file => /path/to/file
- reference:file:/path/to/file => /path/to/file
- jar:file:/path/to/file.jar!/some/contained/element => /path/to/file.jar
- http://server/path/to/file => null
- Parameters:
uri- The URI for which we are attempting to construct a path.- Returns:
- The method's best guess as to which file on the local filesystem this URI refers, or an empty Optional if it's invalid or not a local filesystem URI.
-
pathFromURI
private static java.util.Optional<java.nio.file.Path> pathFromURI(java.lang.String uriString, java.net.URI uri)
-
isRemote
public static boolean isRemote(java.net.URI uri)
Answer if the given URL is on the local system or remote
-
getDefaultPort
public static int getDefaultPort(java.lang.String scheme)
-
-