Here you can find the source of isPrefix(final URI source, final URI other)
Parameter | Description |
---|---|
source | the source URI to check |
other | the URI to check the source against |
public static boolean isPrefix(final URI source, final URI other)
//package com.java2s; /****************************************************************************** * Copyright (c) 2000-2016 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ import java.net.URI; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; public class Main { /**//from w w w .j a v a2 s .c o m * Checks whether the source URI is a prefix of the other URI. * * @param source * the source URI to check * @param other * the URI to check the source against * * @return true if the source is a prefix of the other URI, false * otherwise * */ public static boolean isPrefix(final URI source, final URI other) { if ((source.getScheme() == null && other.getScheme() != null) || !source.getScheme().equals(other.getScheme())) { return false; } final IPath sourcePath = new Path(source.getPath()); final IPath otherPath = new Path(other.getPath()); return sourcePath.isPrefixOf(otherPath); } }