本文整理汇总了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;
}
示例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;
}
示例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();
}
}
}
});
}
}
}