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


Java URIUtil.fromString方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.URIUtil.fromString方法的典型用法代码示例。如果您正苦于以下问题:Java URIUtil.fromString方法的具体用法?Java URIUtil.fromString怎么用?Java URIUtil.fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.URIUtil的用法示例。


在下文中一共展示了URIUtil.fromString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getURI

import org.eclipse.core.runtime.URIUtil; //导入方法依赖的package包/类
/**
 * Returns a URI for a specification.
 * 
 * @param spec Specification
 * @param base Base location
 * @return URI or <code>null</code>
 */
protected URI getURI(String spec, URI base) {
	// Bad specification
	if (spec.startsWith("@"))
		return null;
	
	URI uri = null;
	try {
		uri = URIUtil.fromString(spec);
		String uriScheme = uri.getScheme();
		// Handle jar scheme special to support relative paths
		if ((uriScheme != null) && uriScheme.equals("jar")) { //$NON-NLS-1$
			String path = uri.getSchemeSpecificPart().substring("file:".length()); //$NON-NLS-1$
			URI relPath = URIUtil.append(base, path);
			uri = new URI("jar:" + relPath.toString());  //$NON-NLS-1$
		}
		else {
			uri = URIUtil.makeAbsolute(uri, base);
		}
	} catch (URISyntaxException e) {
		LogHelper.log(new Status(IStatus.ERROR, Installer.ID, "Invalid URL in install description: " + spec, e)); //$NON-NLS-1$
	}
	
	return uri;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:32,代码来源:InstallDescription.java

示例2: resolveFile

import org.eclipse.core.runtime.URIUtil; //导入方法依赖的package包/类
/**
 * Resolves an install file.
 * 
 * @param site File URI or <code>null</code>.
 * @param filename File name
 * @return File URI
 * @throws URISyntaxException on invalid syntax
 */
private URI resolveFile(String site, String filename) throws URISyntaxException {
	// If no URL was given from the outside, look for file 
	// relative to where the installer is running.  This allows the installer to be self-contained
	if (site == null)
		site = filename;
	
	URI propsURI = URIUtil.fromString(site);
	if (!propsURI.isAbsolute()) {
		String installerInstallArea = System.getProperty(IInstallConstants.OSGI_INSTALL_AREA);
		if (installerInstallArea == null)
			throw new IllegalStateException(InstallMessages.Error_NoInstallArea);
		
		// Get the locale
		String locale = Platform.getNL();
		// Check for locale installer description
		propsURI = URIUtil.append(URIUtil.fromString(installerInstallArea), locale);
		propsURI = URIUtil.append(propsURI, site);
		File installerDescription = URIUtil.toFile(propsURI);
		// If not found, use default install description
		if (!installerDescription.exists()) {
			propsURI = URIUtil.append(URIUtil.fromString(installerInstallArea), site);
			installerDescription = URIUtil.toFile(propsURI);
			if (!installerDescription.exists()) {
				propsURI = null;
			}
		}
	}
	
	return propsURI;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:39,代码来源:Installer.java

示例3: handleRequest

import org.eclipse.core.runtime.URIUtil; //导入方法依赖的package包/类
private void handleRequest(HttpRequest request, HttpResponse response, boolean head) throws HttpException,
		IOException, CoreException, URISyntaxException
{
	String target = URLDecoder.decode(request.getRequestLine().getUri(), IOUtil.UTF_8);
	URI uri = URIUtil.fromString(target);
	IFileStore fileStore = uriMapper.resolve(uri);
	IFileInfo fileInfo = fileStore.fetchInfo();
	if (fileInfo.isDirectory())
	{
		fileInfo = getIndex(fileStore);
		if (fileInfo.exists())
		{
			fileStore = fileStore.getChild(fileInfo.getName());
		}
	}
	if (!fileInfo.exists())
	{
		response.setStatusCode(HttpStatus.SC_NOT_FOUND);
		response.setEntity(createTextEntity(MessageFormat.format(
				Messages.LocalWebServerHttpRequestHandler_FILE_NOT_FOUND, uri.getPath())));
	}
	else if (fileInfo.isDirectory())
	{
		response.setStatusCode(HttpStatus.SC_FORBIDDEN);
		response.setEntity(createTextEntity(Messages.LocalWebServerHttpRequestHandler_FORBIDDEN));
	}
	else
	{
		response.setStatusCode(HttpStatus.SC_OK);
		if (head)
		{
			response.setEntity(null);
		}
		else
		{
			File file = fileStore.toLocalFile(EFS.NONE, new NullProgressMonitor());
			final File temporaryFile = (file == null) ? fileStore.toLocalFile(EFS.CACHE, new NullProgressMonitor())
					: null;
			response.setEntity(new NFileEntity((file != null) ? file : temporaryFile, getMimeType(fileStore
					.getName()))
			{
				@Override
				public void close() throws IOException
				{
					try
					{
						super.close();
					}
					finally
					{
						if (temporaryFile != null && !temporaryFile.delete())
						{
							temporaryFile.deleteOnExit();
						}
					}
				}
			});
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:61,代码来源:LocalWebServerHttpRequestHandler.java


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