本文整理汇总了Java中org.eclipse.emf.common.util.URI.trimSegments方法的典型用法代码示例。如果您正苦于以下问题:Java URI.trimSegments方法的具体用法?Java URI.trimSegments怎么用?Java URI.trimSegments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.trimSegments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryFindProjectRecursivelyByManifest
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private URI tryFindProjectRecursivelyByManifest(URI location, Optional<URI> stopUri) {
URI nestedLocation = location;
int segmentCount = 0;
if (nestedLocation.isFile()) { // Here, unlike java.io.File, #isFile can mean directory as well.
File directory = new File(nestedLocation.toFileString());
while (directory != null) {
if (stopUri.isPresent() && stopUri.get().equals(nestedLocation)) {
break;
}
if (directory.isDirectory()) {
if (new File(directory, IN4JSProject.N4MF_MANIFEST).exists()) {
URI projectLocation = URI.createFileURI(directory.getAbsolutePath());
registerProject(projectLocation);
return projectLocation;
}
}
nestedLocation = nestedLocation.trimSegments(segmentCount++);
directory = directory.getParentFile();
}
}
return null;
}
示例2: createProjectUri
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Creates project {@link URI} for the given file system location.
*
* @param location
* file system location to transform
* @return {@link URI} for the provided location
*/
private static URI createProjectUri(File location) {
URI createURI = null;
try {
createURI = URI.createURI(location.toURI().toURL().toString());
// by convention IN4JSProject URI does not end with '/'
// i.e. last segment is not empty
if (Strings.isNullOrEmpty(createURI.lastSegment())) {
createURI = createURI.trimSegments(DANGLING_SEGMENT_COUNT);
}
} catch (MalformedURLException e) {
LOGGER.warn("Exceptions when transforming location: " + location, e);
}
return createURI;
}