@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); } }
while ((mp = member.getPath()).startsWith(DOT_DOT_SEPARATOR)) { parent = parent(parent); member = new UriBuilder(member) .path(mp.substring(3)) .getUri(); : pu.getPath() + mp.substring(0, mpl); this.root = new FsPath( new UriBuilder() .scheme(pu.getScheme()) .authority(ma) .path(p) .getUri()); mp = mp.substring(mpl); } else {
private static URI fixChecked(final URI uri) { final String ssp = uri.getSchemeSpecificPart(); final String a = uri.getAuthority(); if (null == ssp // URI bug: null == new URI("foo").resolve(new URI("..")).getRawSchemeSpecificPart() || null == a && ssp.startsWith(SEPARATOR + SEPARATOR)) // empty authority return new UriBuilder(uri).toUri(); return uri; }
@Override public URI toUri() { URI n = getName(); String s = n.getScheme(); return new UriBuilder(getAddress().toHierarchicalUri()) .scheme(null != s ? s : TFileSystemProvider.get(n).getScheme()) .toUri(); }
builder.setUri(u); assertEquals(test[1], builder.getScheme()); assertEquals(test[2], builder.getAuthority()); assertEquals(test[3], builder.getPath()); assertEquals(test[4], builder.getQuery()); assertEquals(test[5], builder.getFragment()); assertEquals(test[0], builder.toString()); builder .clear() .scheme(test[1]) .authority(test[2]) .path(test[3]) .query(test[4]) .fragment(test[5]); assertEquals(test[0], builder.toString()); assertEquals(u, builder.toUri()); assertEquals(u, builder.uri(u).toUri());
}) { builder .clear() .scheme(test[0]) .authority(test[1]) .path(test[2]) .query(test[3]) .fragment(test[4]); try { builder.getString(); fail(); } catch (URISyntaxException expected) { builder.toString(); fail(); } catch (IllegalStateException expected) { builder.getUri(); fail(); } catch (URISyntaxException expected) { builder.toUri(); fail(); } catch (IllegalStateException expected) { builder.uri(URI.create("")); assertEquals("", builder.toString()); assertEquals(URI.create(""), builder.toUri());
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);
p = cutTrailingSeparators(p, l); try { final UriBuilder ub = new UriBuilder(); if (0 < l) { if (SEPARATOR_CHAR != p.charAt(l - 1)) if (-1 != j) { ub.setAuthority(p.substring(2, j)); // "host" return ub.path(p).getUri(); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex);
@Test public void testDefaults() { assertNull(builder.getScheme()); assertNull(builder.getAuthority()); assertNull(builder.getPath()); assertNull(builder.getQuery()); assertNull(builder.getFragment()); assertEquals("", builder.toString()); assertEquals(URI.create(""), builder.toUri()); }
@Before public void setUp() { builder = new UriBuilder(); }
/** * 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); } }
try { this.enclEntryName = new FsEntryName( new UriBuilder() .path( 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); }
continue; final FsEntryName entryName = new FsEntryName( new UriBuilder().path(cen).getUri()); assertEquals(cen, entryName.getPath()); assertEquals(cen, fileSystem.getEntry(entryName).getName());