/** * A template method which derives the URI which represents the mount point * of the given file system model as the base resource URI for looking up * {@link KeyProvider}s. * <p> * The implementation in the class {@link ZipDriver} returns the * expression {@code model.getMountPoint().toHierarchicalUri()} * in order to improve the readability of the URI in comparison to the * expression {@code model.getMountPoint().toUri()}. * * @param model the file system model. * @return The URI which represents the file system model's mount point. * @see <a href="http://java.net/jira/browse/TRUEZIP-72">#TRUEZIP-72</a> */ public URI mountPointUri(FsModel model) { return model.getMountPoint().toHierarchicalUri(); }
@Override public Iterable<Path> getRootDirectories() { return Collections.singleton((Path) new TPath(getMountPoint().toHierarchicalUri().resolve(SEPARATOR))); }
@SuppressWarnings("LeakingThisInConstructor") private TFile( final FsMountPoint mountPoint, final TArchiveDetector detector) { super(mountPoint.toHierarchicalUri()); this.file = new File(super.getPath()); this.detector = detector; final FsPath mpp = mountPoint.getPath(); if (null == mpp) { assert !mountPoint.toUri().isOpaque(); this.enclArchive = null; this.enclEntryName = null; this.innerArchive = null; } else { assert mountPoint.toUri().isOpaque(); if (mpp.toUri().isOpaque()) { this.enclArchive = new TFile(mpp.getMountPoint(), detector); this.enclEntryName = mpp.getEntryName(); } else { this.enclArchive = null; this.enclEntryName = null; } this.innerArchive = this; this.controller = getController(mountPoint); } assert invariants(); }
@Test public void testHierarchicalize() { for (final String[] params : new String[][] { { "foo:bar:baz:/x/bö%20m?plö%20k!/bä%20g?zö%20k!/", "baz:/x/bö%20m/bä%20g?zö%20k" }, { "foo:bar:baz:/x/bööm?plönk!/bäng?zönk!/", "baz:/x/bööm/bäng?zönk" }, { "foo:bar:baz:/boom?plonk!/bang?zonk!/", "baz:/boom/bang?zonk" }, { "foo:bar:baz:/boom!/bang!/", "baz:/boom/bang" }, { "foo:bar:/baz?boom!/", "bar:/baz?boom" }, { "foo:bar:/baz!/", "bar:/baz" }, { "foo:/bar/", "foo:/bar/" }, }) { final FsMountPoint mp = FsMountPoint.create(URI.create(params[0])); final URI hmp = mp.toHierarchicalUri(); final FsPath p = FsPath.create(URI.create(params[0])); final URI hp = p.toHierarchicalUri(); assertThat(hmp, equalTo(URI.create(params[1]))); assertThat(hmp, equalTo(hp)); } } }