本文整理匯總了Java中org.eclipse.core.runtime.IPath.matchingFirstSegments方法的典型用法代碼示例。如果您正苦於以下問題:Java IPath.matchingFirstSegments方法的具體用法?Java IPath.matchingFirstSegments怎麽用?Java IPath.matchingFirstSegments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.IPath
的用法示例。
在下文中一共展示了IPath.matchingFirstSegments方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConflictingContainerNameFor
import org.eclipse.core.runtime.IPath; //導入方法依賴的package包/類
/**
* Returns the name of a container with a location that encompasses targetDirectory. Returns null if there is no
* conflict.
*
* @param targetDirectory
* the path of the directory to check.
* @return the conflicting container name or <code>null</code>
*/
private String getConflictingContainerNameFor(String targetDirectory) {
IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
IPath testPath = new Path(targetDirectory);
// cannot export into workspace root
if (testPath.equals(rootPath))
return rootPath.lastSegment();
// Are they the same?
if (testPath.matchingFirstSegments(rootPath) == rootPath.segmentCount()) {
String firstSegment = testPath.removeFirstSegments(rootPath.segmentCount()).segment(0);
if (!Character.isLetterOrDigit(firstSegment.charAt(0)))
return firstSegment;
}
return null;
}