Java Utililty Methods URI to Parent URI

List of utility methods to do URI to Parent URI

Description

The list of methods to do URI to Parent URI are organized into topic(s).

Method

MapgetParams(URI uri)
get Params
return getParamsFromQuery(uri.getQuery());
URIgetParent(final URI uri)
Returns the parent of the specified URI.
if (uri == null)
    throw new IllegalArgumentException("The URI cannot be null.");
final String path = uri.toString();
final int finalSeparator = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
final int extension = path.lastIndexOf('.');
if (extension > finalSeparator)
    try {
        return new URI(path.substring(0, finalSeparator + 1)).normalize();
...
StringgetParent(URI path)
get Parent
return getParent(path.normalize().getPath());
URIgetParent(URI uri)
Gets the URI of the directory that contains the resource.
if (uri.toString().startsWith("jar:")) {
    JarURLConnection jarConn = (JarURLConnection) (uri.toURL().openConnection());
    String entryName = jarConn.getEntryName();
    String parentPath = "";
    if (entryName != null) {
        parentPath = (new File(entryName)).getParent();
    String jarUrlStr = "jar:" + jarConn.getJarFileURL().toExternalForm() + "!/";
...
StringgetParentName(URI uri)
get Parent Name
String s = uri.toString();
int pos = s.lastIndexOf('/');
if (pos > -1) {
    return s.substring(0, pos);
} else {
    return null;
ListgetParents(final URI uri)
get Parents
checkNotNull(uri, "URI cannot be null");
Set<URI> parents = Sets.newLinkedHashSet();
parents.add(uri);
if (uri.isAbsolute() && !uri.isOpaque()) {
    URI base = current(uri);
    while (!isRoot(base)) {
        parents.add(base);
        base = parent(base);
...
URIgetParentURI(URI uri)
get Parent URI
URI parent = null;
if (uri != null) {
    String text = uri.toString();
    int index = text.lastIndexOf('/');
    if (index != -1) {
        text = text.substring(0, index);
        parent = URI.create(text);
return parent;
URIgetParentURI(URI uri)
get Parent URI
if (uri == null)
    return uri;
IPath uriPath = Path.fromPortableString(uri.getPath());
if (uriPath.segmentCount() == 0)
    return null;
uriPath = uriPath.removeLastSegments(1).addTrailingSeparator();
try {
    return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
...
URIgetParentURI(URI uri)
get Parent URI
File file = new File(uri.getPath());
File parent = file.getParentFile();
if (parent != null && !parent.getName().isEmpty()) {
    try {
        return changePath(uri, parent.getAbsolutePath());
    } catch (URISyntaxException e) {
return null; 
StringgetParentUriPath(String uriPath)
Calculate the parent URI path of the given URI path.
int idx = uriPath.lastIndexOf('/');
if (uriPath.endsWith("/")) {
    uriPath = uriPath.substring(0, idx); 
    idx = uriPath.lastIndexOf('/'); 
return uriPath.substring(0, idx) + "/";