当前位置: 首页>>代码示例>>Java>>正文


Java URI.equals方法代码示例

本文整理汇总了Java中java.net.URI.equals方法的典型用法代码示例。如果您正苦于以下问题:Java URI.equals方法的具体用法?Java URI.equals怎么用?Java URI.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.URI的用法示例。


在下文中一共展示了URI.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: urisEqualAfterPortNormalization

import java.net.URI; //导入方法依赖的package包/类
/**
 * Compares two URIs for equality, ignoring default port numbers for selected protocols.
 * 
 * By default, {@link URI#equals(Object)} doesn't take into account default port numbers, so http://server:80/resource is a different
 * URI than http://server/resource.
 * 
 * And URLs should not be used for comparison, as written here:
 * http://stackoverflow.com/questions/3771081/proper-way-to-check-for-url-equality
 * 
 * @param uri1
 *            URI 1 to be compared.
 * @param uri2
 *            URI 2 to be compared.
 * 
 * @return True if both URIs are equal.
 */
public static boolean urisEqualAfterPortNormalization(final URI uri1, final URI uri2) {
    if (uri1 == null && uri2 == null) {
        return true;
    }
    if (uri1 == null || uri2 == null) {
        return false;
    }
    
    try {
        URI normalizedUri1 = normalizePortNumbersInUri(uri1);
        URI normalizedUri2 = normalizePortNumbersInUri(uri2);
        boolean eq = normalizedUri1.equals(normalizedUri2);
        return eq;
    } catch (URISyntaxException use) {
        logger.error("Cannot compare 2 URIs.", use);
        return false;    
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:35,代码来源:UriUtils.java

示例2: processCharacters

import java.net.URI; //导入方法依赖的package包/类
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map)
        throws PolicyException {
    if (chars.isWhiteSpace()) {
        return;
    }
    else {
        final String data = chars.getData();
        if ((currentElement != null) && URI.equals(currentElement.getName())) {
            processUri(chars, map);
            return;
        } else {
            throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation())));
        }

    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:ExternalAttachmentsUnmarshaller.java

示例3: saveExtendedUri

import java.net.URI; //导入方法依赖的package包/类
public static Element saveExtendedUri(
        final ExtendedUri uri,
        final Element element) {
    final Document document = element.getOwnerDocument();
    
    element.setAttribute("size", Long.toString(uri.getSize()));
    element.setAttribute("md5", uri.getMd5());
    
    // the default uri would be either "local" (if it's present) or the
    // "remote" one
    Element uriElement = document.createElement("default-uri");
    if (uri.getLocal() != null) {
        uriElement.setTextContent(uri.getLocal().toString());
    } else {
        uriElement.setTextContent(uri.getRemote().toString());
    }
    element.appendChild(uriElement);
    
    // if the "local" uri is not null, we should save the "remote" uri as the
    // first alternate, unless it's the same as the local
    if ((uri.getLocal() != null) && !uri.getRemote().equals(uri.getLocal())) {
        uriElement = document.createElement("alternate-uri");
        
        uriElement.setTextContent(uri.getRemote().toString());
        element.appendChild(uriElement);
    }
    
    for (URI alternateUri: uri.getAlternates()) {
        if (!alternateUri.equals(uri.getRemote())) {
            uriElement = document.createElement("alternate-uri");
            
            uriElement.setTextContent(alternateUri.toString());
            element.appendChild(uriElement);
        }
    }
    
    return element;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:XMLUtils.java

示例4: shouldIgnore

import java.net.URI; //导入方法依赖的package包/类
private static synchronized boolean shouldIgnore (
        @NonNull final URI key,
        @NonNull final URI value) {
    if (!key.equals(currentKey)) {
        return false;
    }
    return currentValues.contains(value);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:PathFinders.java

示例5: ignore

import java.net.URI; //导入方法依赖的package包/类
private static synchronized void ignore(
        @NonNull final URI key,
        @NonNull final URI value) {
    if (!key.equals(currentKey)) {
        currentKey = key;
        currentValues = new HashSet<URI>();
    }
    currentValues.add(value);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:PathFinders.java

示例6: areCollocated

import java.net.URI; //导入方法依赖的package包/类
@Override public boolean areCollocated(URI file1, URI file2) {
    if (file1.equals(file2)) {
        return true;
    }
    String f1 = file1.toString();
    if (!f1.endsWith("/")) {
        f1 += "/";
    }
    String f2 = file2.toString();
    if (!f2.endsWith("/")) {
        f2 += "/";
    }
    return f1.startsWith(f2) || f2.startsWith(f1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ParentChildCollocationQuery.java

示例7: test

import java.net.URI; //导入方法依赖的package包/类
void test(String... args) throws IOException {
    File path = test_src.getCanonicalFile();
    File src = new File(new File(path, "."), "T6440333.java");
    JavaFileObject fo = fm.getJavaFileObjects(src).iterator().next();
    URI expect = src.getCanonicalFile().toURI();
    System.err.println("Expect " + expect);
    System.err.println("Found  " + fo.toUri());
    if (!expect.equals(fo.toUri())) {
        throw new AssertionError();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:T6440333.java

示例8: eq0

import java.net.URI; //导入方法依赖的package包/类
static void eq0(URI u, URI v) throws URISyntaxException {
    testCount++;
    if (!u.equals(v))
        throw new RuntimeException("Not equal: " + u + " " + v);
    int uh = u.hashCode();
    int vh = v.hashCode();
    if (uh != vh)
        throw new RuntimeException("Hash codes not equal: "
                                   + u + " " + Integer.toHexString(uh) + " "
                                   + v + " " + Integer.toHexString(vh));
    out.println();
    out.println(u + " == " + v
                + "  [" + Integer.toHexString(uh) + "]");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Test.java

示例9: downloadProfilePicture

import java.net.URI; //导入方法依赖的package包/类
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
        return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
        if (!prefetching) {
            // Setting the tag to the profile ID indicates that we're currently downloading the
            // picture for this profile; we'll set it to the actual picture URL when complete.
            imageView.setTag(profileId);
            imageView.setImageResource(getDefaultPicture());
        }

        ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
                .setCallerTag(this)
                .setCallback(
                        new ImageRequest.Callback() {
                            @Override
                            public void onCompleted(ImageResponse response) {
                                processImageResponse(response, profileId, imageView);
                            }
                        });

        ImageRequest newRequest = builder.build();
        pendingRequests.put(profileId, newRequest);

        ImageDownloader.downloadAsync(newRequest);
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:35,代码来源:GraphObjectAdapter.java

示例10: testUri

import java.net.URI; //导入方法依赖的package包/类
/**
 * Test URI -> Path -> URI
 */
static void testUri(String s) throws Exception {
    URI uri = URI.create(s);
    log.println(uri);
    Path path = Paths.get(uri);
    log.println("  --> " + path);
    URI result = path.toUri();
    log.println("  --> " + result);
    if (!result.equals(uri)) {
        log.println("FAIL: Expected " + uri + ", got " + result);
        failures++;
    }
    log.println();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:UriImportExport.java

示例11: hasAnotherMaster

import java.net.URI; //导入方法依赖的package包/类
@Override
public boolean hasAnotherMaster() {

	//TODO: refactor get connection to not throw illegal arg exceptions
	IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN);

	if(mainCxn != null) {

		// Determine the local URI
		InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress();
		URI localURI = URIUtil.createURI(address.getHostName(), address.getPort());

		for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) {

			// Don't check our own controller connections
			URI uri = entry.getKey();
			if(!localURI.equals(uri)){

				// We only care for the MAIN connection
				Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri);
				OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN);

				if(controllerCxn != null) {
					// If the controller id disconnected or not master we know it is not connected
					if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED
							&& controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){
						return true;
					}
				} else {
					log.warn("Unable to find controller connection with aux id "
							+ "MAIN for switch {} on controller with URI {}.",
							this, uri);
				}
			}
		}
	}
	return false;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:39,代码来源:OFSwitch.java

示例12: remove

import java.net.URI; //导入方法依赖的package包/类
/**
 * Removes a URI from the collection.
 */
public boolean remove(final URI uri) {
    boolean removed = this.unique.remove(uri);
    if (removed) {
        Iterator<URI> it = this.all.iterator();
        while (it.hasNext()) {
            URI current = it.next();
            if (current.equals(uri)) {
                it.remove();
            }
        }
    }
    return removed;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:RedirectLocations.java

示例13: remove

import java.net.URI; //导入方法依赖的package包/类
/**
 * Removes a URI from the collection.
 */
public boolean remove(final URI uri) {
    final boolean removed = this.unique.remove(uri);
    if (removed) {
        final Iterator<URI> it = this.all.iterator();
        while (it.hasNext()) {
            final URI current = it.next();
            if (current.equals(uri)) {
                it.remove();
            }
        }
    }
    return removed;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:17,代码来源:RedirectLocations.java

示例14: ne0

import java.net.URI; //导入方法依赖的package包/类
static void ne0(URI u, URI v) throws URISyntaxException {
    testCount++;
    if (u.equals(v))
        throw new RuntimeException("Equal: " + u + " " + v);
    out.println();
    out.println(u + " != " + v
                + "  [" + Integer.toHexString(u.hashCode())
                + " " + Integer.toHexString(v.hashCode())
                + "]");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:Test.java

示例15: isRoot

import java.net.URI; //导入方法依赖的package包/类
private boolean isRoot(final URI internalURI) {
    return internalURI.equals(rootURI);
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:4,代码来源:LambdoraLdp.java


注:本文中的java.net.URI.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。