/** * Resolves the given node name against this path. * * @param nodeName a node name relative to this path. * @return A new path with an absolute URI. */ public FsNodePath resolve(final FsNodeName nodeName) { if (nodeName.isRoot() && null == this.uri.getQuery()) return this; return new FsNodePath( this.mountPoint, new FsNodeName(this.nodeName, nodeName)); }
/** * Constructs a new file system node name by parsing the given URI * after applying the given URI modifier. * This static factory method calls * {@link #FsNodeName(URI, FsUriModifier) new FsNodeName(uri, modifier)} * and wraps any thrown {@link URISyntaxException} in an * {@link IllegalArgumentException}. * * @param uri the {@link #getUri() URI}. * @param modifier the URI modifier. * @throws NullPointerException if {@code uri} or {@code modifier} are * {@code null}. * @throws IllegalArgumentException if {@code uri} still does not conform * to the syntax constraints for file system node names after its * modification. * @return A new file system node name. */ public static FsNodeName create(URI uri, FsUriModifier modifier) { try { return uri.toString().isEmpty() ? ROOT : new FsNodeName(uri, modifier); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
/** * Initialize this file object by scanning its path for archive * files, using the given {@code ancestor} file (i.e. a direct or * indirect parent file) if any. * {@code file} and {@code config} must already be initialized! * Must not be called to re-initialize this object! */ private void scan(final @CheckForNull TFile ancestor) { final String path = super.getPath(); assert ancestor == null || path.startsWith(ancestor.getPath()); assert file.getPath().equals(path); assert null != detector; final StringBuilder nodeNameBuf = new StringBuilder(path.length()); scan(detector, ancestor, 0, path, nodeNameBuf, new PathSplitter(separatorChar, false)); try { nodeName = 0 >= nodeNameBuf.length() ? null : new FsNodeName( new UriBuilder().path(nodeNameBuf.toString()).getUri(), CANONICALIZE); } catch (URISyntaxException ex) { throw new AssertionError(ex); } }
this.innerArchive = this.enclArchive = innerArchive; try { this.nodeName = new FsNodeName( new UriBuilder() .path(
/** * Returns the nullable parent of the given file system node path. * * @param path a file system node path. * @return The parent file system node path or null if {@code path} does * not name a parent. * @throws URISyntaxException */ static @Nullable FsNodePath parent(FsNodePath path) throws URISyntaxException { FsMountPoint mp = path.getMountPoint(); FsNodeName en = path.getNodeName(); if (en.isRoot()) { if (null == mp) return null; path = mp.getPath(); if (null != path) return parent(path); URI mpu = mp.getUri(); URI pu = mpu.resolve(DOT_DOT_URI); if (mpu.getRawPath().length() <= pu.getRawPath().length()) return null; return new FsNodePath(pu); } else { URI pu = en.getUri().resolve(DOT_URI); en = new FsNodeName(pu, CANONICALIZE); return new FsNodePath(mp, en); } } }
.toUri(), modifier); nodeName = new FsNodeName( b.clear() .pathQuery(ssp.substring(i + 2)) nodeName = new FsNodeName(mountPoint.getUri().relativize(uri), modifier); } else { mountPoint = null; nodeName = new FsNodeName(uri, modifier); if (NULL != modifier) uri = nodeName.getUri();
private FsNodePath resolve(final String path) throws URISyntaxException { splitter.split(path); final String pp = splitter.getParentPath(); final FsNodeName nn; final FsNodePath np; if (null != pp) { nn = new FsNodeName( builder.path(splitter.getMemberName()).getUri(), NULL); np = resolve(pp); } else { nn = new FsNodeName( builder.path(path).query(memberQuery).getUri(), CANONICALIZE); np = root; } URI npu; FsNodePath rnp; if (nn.isRoot() || (npu = np.getUri()).isOpaque() || !npu.isAbsolute()) { rnp = np.resolve(nn); } else { final String npup = npu.getPath(); if (!npup.endsWith(SEPARATOR)) npu = new UriBuilder(npu).path(npup + SEPARATOR_CHAR).getUri(); rnp = new FsNodePath(new FsMountPoint(npu), nn); } final FsScheme s = detector.scheme(nn.toString()); if (null != s) rnp = new FsNodePath(new FsMountPoint(s, rnp), ROOT); return rnp; }