@edu.umd.cs.findbugs.annotations.SuppressWarnings("ES_COMPARING_STRINGS_WITH_EQ") private static URI name(URI uri) { try { uri = checkFix(uri); final int pl = pathPrefixLength(uri); final String q = uri.getPath(); final String p = cutTrailingSeparators(q, pl); if (p != q) // mind contract of cutTrailingSeparators(String, int) return new UriBuilder(uri).path(p).getUri(); return uri; } 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 detector} 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 enclEntryNameBuf = new StringBuilder(path.length()); scan(ancestor, detector, 0, path, enclEntryNameBuf, new Splitter(separatorChar, false)); try { enclEntryName = 0 >= enclEntryNameBuf.length() ? null : new FsEntryName( new UriBuilder().path(enclEntryNameBuf.toString()).getUri(), CANONICALIZE); } catch (URISyntaxException ex) { throw new AssertionError(ex); } }
return ub.path(p).getUri(); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex);
path.substring(iapl + 1) // cut off leading separatorChar .replace(separatorChar, SEPARATOR_CHAR)) .getUri(), CANONICALIZE); } catch (URISyntaxException ex) {
private TPath resolve(final URI m) { URI n; final String np; if (TPathScanner.isAbsolute(m) || (n = getName()).toString().isEmpty()) { n = m; } else if (m.toString().isEmpty()) { n = getName(); } else if ((np = n.getPath()).endsWith(SEPARATOR)) { n = n.resolve(m); } else { try { n = new UriBuilder(n).path(np + SEPARATOR_CHAR).getUri().resolve(m); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } final TArchiveDetector d = getDefaultArchiveDetector(); final FsPath p = new TPathScanner(d).scan( TPathScanner.isAbsolute(m) ? TFileSystemProvider.get(getName()).getRoot() : getAddress(), m); return new TPath(n, d, p); }
if (null != ps) { men = new FsEntryName( uri.path(splitter.getMemberName()).getUri(), NULL); pp = scan(ps); } else { men = new FsEntryName( uri.path(path).query(memberQuery).getUri(), CANONICALIZE); pp = root; final String pup = ppu.getPath(); if (!pup.endsWith(SEPARATOR)) ppu = new UriBuilder(ppu).path(pup + SEPARATOR_CHAR).getUri(); mp = new FsPath(new FsMountPoint(ppu), men);
builder.getUri(); fail(); } catch (URISyntaxException expected) {
continue; final FsEntryName entryName = new FsEntryName( new UriBuilder().path(cen).getUri()); assertEquals(cen, entryName.getPath()); assertEquals(cen, fileSystem.getEntry(entryName).getName());