本文整理汇总了Java中org.eclipse.emf.common.util.URI.segmentCount方法的典型用法代码示例。如果您正苦于以下问题:Java URI.segmentCount方法的具体用法?Java URI.segmentCount怎么用?Java URI.segmentCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.segmentCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInputStream
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
String[] allSegments = new String[uri.segmentCount() + 1];
allSegments[0] = "env";
for (int i = 0; i < uri.segmentCount(); i++) {
allSegments[i + 1] = uri.segment(i);
}
URI classpathURI = URI.createHierarchicalURI(
ClasspathUriUtil.CLASSPATH_SCHEME,
uri.authority(),
uri.device(),
allSegments,
uri.query(),
uri.fragment());
URI resolvedURI = uriResolver.resolve(classLoader, classpathURI);
return original.createInputStream(resolvedURI, options);
}
示例2: getProjectDescription
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public ProjectDescription getProjectDescription(URI location) {
if (!location.isPlatformResource()) {
return null;
}
ProjectDescription existing = cache.get(location);
if (existing == null) {
if (location.isPlatformResource() && location.segmentCount() == DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) {
existing = loadManifest(location.appendSegment(IN4JSProject.N4MF_MANIFEST));
} else {
existing = loadManifest(ArchiveURIUtil.createURI(location, IN4JSProject.N4MF_MANIFEST));
}
if (existing != null) {
cache.put(location, existing);
if (listener != null) {
listener.onDescriptionLoaded(location);
}
}
}
return existing;
}
示例3: getN4JSProject
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public N4JSEclipseProject getN4JSProject(URI location) {
checkArgument(
location.isPlatformResource() || location.isFile(),
"Expected either platform:/resource or file:/ URI. Was: " + location);
if (location.isPlatformResource() && location.segmentCount() != DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) {
checkArgument(
DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT == location.segmentCount(),
"Expected 2 segment counts for platform resource URI. Was " + location.segmentCount());
}
final String projectName = location.lastSegment();
final IProject project;
if (location.isFile()) {
project = externalLibraryWorkspace.getProject(projectName);
checkNotNull(project, "Project does not exist in external workspace. URI: " + location);
} else {
project = workspace.getProject(projectName);
}
return doGetN4JSProject(project, location);
}
示例4: findProjectWith
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI findProjectWith(URI nestedLocation) {
int maxSegments = nestedLocation.segmentCount();
OUTER: for (URI known : projectElementHandles.keySet()) {
if (known.segmentCount() <= maxSegments) {
final URI projectUri = tryFindProjectRecursivelyByManifest(nestedLocation, fromNullable(known));
if (null != projectUri) {
return projectUri;
}
for (int i = 0; i < known.segmentCount(); i++) {
if (!known.segment(i).equals(nestedLocation.segment(i))) {
continue OUTER;
}
}
return known;
}
}
return tryFindProjectRecursivelyByManifest(nestedLocation, Optional.absent());
}
示例5: findN4JSSourceContainerInArchive
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
protected Optional<? extends IN4JSSourceContainer> findN4JSSourceContainerInArchive(URI location,
N4JSArchive archive) {
int maxSegments = location.segmentCount();
OUTER: for (IN4JSSourceContainer sourceContainer : archive.getSourceContainers()) {
URI sourceContainerLocation = sourceContainer.getLocation();
if (sourceContainerLocation.segmentCount() <= maxSegments) {
for (int i = 0; i < sourceContainerLocation.segmentCount(); i++) {
if (!sourceContainerLocation.segment(i).equals(location.segment(i))) {
continue OUTER;
}
}
return Optional.of(sourceContainer);
}
}
return Optional.absent();
}
示例6: findProjectWith
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI findProjectWith(URI nestedLocation) {
if (nestedLocation.isPlatformResource()
&& nestedLocation.segmentCount() >= DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) {
return URI.createPlatformResourceURI(nestedLocation.segment(1), true);
}
return null;
}
示例7: getLocation
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI getLocation(URI projectURI, ProjectReference projectReference,
N4JSSourceContainerType expectedN4JSSourceContainerType) {
if (projectURI.segmentCount() >= DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) {
String expectedProjectName = projectReference.getProject().getProjectId();
if (expectedProjectName != null && expectedProjectName.length() > 0) {
IProject existingProject = workspace.getProject(expectedProjectName);
if (existingProject.isAccessible()) {
if (expectedN4JSSourceContainerType == N4JSSourceContainerType.ARCHIVE) {
return null;
} else {
return URI.createPlatformResourceURI(expectedProjectName, true);
}
} else if (expectedN4JSSourceContainerType == N4JSSourceContainerType.ARCHIVE) {
for (String libFolder : getLibraryFolders(projectURI)) {
IFile archiveFile = workspace.getFile(new Path(projectURI.segment(1) + "/" + libFolder
+ "/"
+ expectedProjectName
+ IN4JSArchive.NFAR_FILE_EXTENSION_WITH_DOT));
if (archiveFile.exists()) {
return URI.createPlatformResourceURI(archiveFile.getFullPath().toString(), true);
}
}
}
}
}
return null;
}
示例8: getFolderIterator
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public UnmodifiableIterator<URI> getFolderIterator(URI folderLocation) {
final IContainer container;
if (DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT == folderLocation.segmentCount()) {
container = workspace.getProject(folderLocation.lastSegment());
} else {
container = workspace.getFolder(new Path(folderLocation.toPlatformString(true)));
}
if (container != null && container.exists()) {
final List<URI> result = Lists.newLinkedList();
try {
container.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource.getType() == IResource.FILE) {
result.add(URI.createPlatformResourceURI(resource.getFullPath().toString(), true));
}
return true;
}
});
return Iterators.unmodifiableIterator(result.iterator());
} catch (CoreException e) {
return Iterators.unmodifiableIterator(result.iterator());
}
}
return Iterators.emptyIterator();
}
示例9: onDescriptionLoaded
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
void onDescriptionLoaded(URI location) {
if (location.isPlatformResource() && location.segmentCount() == 2) {
IN4JSEclipseProject n4project = eclipseCore.create(location);
IProject eclipseProject = n4project.getProject();
updateProjectReferencesIfNecessary(eclipseProject);
}
}
示例10: pathStartsWithFolder
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private boolean pathStartsWithFolder(URI nestedLocation, URI containerLocation) {
int maxSegments = containerLocation.segmentCount();
if (nestedLocation.segmentCount() >= maxSegments) {
for (int i = 0; i < maxSegments; i++) {
if (!nestedLocation.segment(i).equals(containerLocation.segment(i))) {
return false;
}
}
return true;
}
return false;
}