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


Java URI.segmentCount方法代码示例

本文整理汇总了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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:BuiltInSchemeRegistrar.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:EclipseBasedN4JSWorkspace.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:N4JSEclipseModel.java

示例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());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:FileBasedWorkspace.java

示例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();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:N4JSModel.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:EclipseBasedN4JSWorkspace.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:30,代码来源:EclipseBasedN4JSWorkspace.java

示例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();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:28,代码来源:EclipseBasedN4JSWorkspace.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:8,代码来源:ProjectDescriptionLoadListener.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:N4JSModel.java


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