/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
@Test public void testPersistenceUnitRootUrlWithJar() throws Exception { ClassPathResource archive = new ClassPathResource("/org/springframework/orm/jpa/jpa-archive.jar"); String newRoot = "jar:" + archive.getURL().toExternalForm() + "!/META-INF/persist.xml"; Resource insideArchive = new UrlResource(newRoot); // make sure the location actually exists assertTrue(insideArchive.exists()); URL url = PersistenceUnitReader.determinePersistenceUnitRootUrl(insideArchive); assertTrue("the archive location should have been returned", archive.getURL().sameFile(url)); }
/** * Check if this jar:file: resource is contained in the * named resource. Eg <code>jar:file:///a/b/c/foo.jar!/x.html</code> isContainedIn <code>file:///a/b/c/foo.jar</code> * @param resource the resource to test for * @return true if resource is contained in the named resource * @throws MalformedURLException if unable to process is contained due to invalid URL format */ @Override public boolean isContainedIn (Resource resource) throws MalformedURLException { String string = _urlString; int index = string.lastIndexOf("!/"); if (index > 0) string = string.substring(0,index); if (string.startsWith("jar:")) string = string.substring(4); URL url = new URL(string); return url.sameFile(resource.getURI().toURL()); } }
public int get(Object args) { URL given = asURL(args); if (SX.isNotSet(given)) { return -1; } int n = 0; for (URL path : pathList) { if (given.sameFile(path)) { return n; } n++; } return -1; }
URL requestedURL; synchronized (rp) { if ((this.url != null) && this.url.sameFile(url)) { Document doc = swingBrowser.getDocument();
/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
/** * Indicates whether this package is sealed with respect to the specified * URL. * * @param url * the URL to check. * @return {@code true} if this package is sealed with {@code url}; {@code * false} otherwise */ public boolean isSealed(URL url) { return sealBase != null && sealBase.sameFile(url); }
public static boolean sameFile(URL url, URL other) { return url.sameFile(other); }
@Override public int compare(URL o1, URL o2) { if (o1.sameFile(o2)) return 0; else return o1.toString().compareTo(o2.toString()); } }
private boolean sameFile(final URL urlToCheck, final URL mapViewUrl) { if (mapViewUrl == null) { return false; } if (urlToCheck.getProtocol().equals("file") && mapViewUrl.getProtocol().equals("file")) { return (new File(urlToCheck.getFile())).equals(new File(mapViewUrl.getFile())); } return urlToCheck.sameFile(mapViewUrl); }
>URL url1 = new URL("http://stackoverflow.com/foo"); >URL url2 = new URL("http://stackoverflow.com/foo/"); >System.out.println(url1.sameFile(url2)); // this is suggested by Joachim Sauer >URI uri = new URI("http://stackoverflow.com/foo/"); >System.out.println(uri.equals("http://stackoverflow.com/foo")); // Both are giving same result
public boolean is(Header header) { try { return header.getLocation().sameFile(this.file.toURI().toURL()); } catch (Exception e) { throw new IllegalStateException("Error comparing document " + this.file + " with file " + file + ". Cause: " + e.getMessage(), e); } }
/** * Gets the template object using the given url as backend. * * @param url the url * @return the template object, {@literal null} if not found */ private ThymeLeafTemplateImplementation getTemplateByURL(URL url) { Collection<ThymeLeafTemplateImplementation> list = registrations.keySet(); for (ThymeLeafTemplateImplementation template : list) { if (template.getURL().sameFile(url)) { return template; } } return null; }
private static boolean hasClassPathesIdenticEntries(ClassPath cp1, ClassPath cp2) { if (cp1.entries().size() != cp2.entries().size()) { return false; } for (int i = 0; i < cp1.entries().size(); i++) { if (!cp1.entries().get(i).getURL().sameFile(cp2.entries().get(i).getURL())) { return false; } } return true; }
@Test public void shouldBeAbleToReturnURL() throws Exception { final URL url = getThreadContextClassLoader().getResource(EXISTING_RESOURCE); final Asset asset = new UrlAsset(url); Assert.assertTrue(url.sameFile(((UrlAsset)asset).getSource())); }
private boolean isAlreadyLoadedByAncestor( final URL url, HtmlPage page ) { WebWindow window = page.getEnclosingWindow(); while (window != null) { if (url.sameFile(window.getEnclosedPage().getWebResponse().getWebRequest().getUrl())) { return true; } if (window == window.getParentWindow()) { window = null; } else { window = window.getParentWindow(); } } return false; }