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


Java URIUtil类代码示例

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


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

示例1: isPluginJar

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
private boolean isPluginJar(IFile file)
{
	if( "jar".equals(file.getFileExtension()) )
	{
		URI jarURI = URIUtil.toJarURI(file.getLocationURI(), JPFProject.MANIFEST_PATH);
		try
		{
			JarEntry jarFile = ((JarURLConnection) jarURI.toURL().openConnection()).getJarEntry();
			return jarFile != null;
		}
		catch( IOException e )
		{
			// Bad zip
		}
	}
	return false;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:WorkspaceJarModelManager.java

示例2: validateProjectLocation

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
private DataflowProjectValidationStatus validateProjectLocation() {
  if (!customLocation || projectLocation == null) {
    return DataflowProjectValidationStatus.OK;
  }

  File file = URIUtil.toFile(projectLocation);
  if (file == null) {
    return DataflowProjectValidationStatus.LOCATION_NOT_LOCAL;
  }
  if (!file.exists()) {
    return DataflowProjectValidationStatus.NO_SUCH_LOCATION;
  }
  if (!file.isDirectory()) {
    return DataflowProjectValidationStatus.LOCATION_NOT_DIRECTORY;
  }
  return DataflowProjectValidationStatus.OK;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:18,代码来源:DataflowProjectCreator.java

示例3: getPath

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
/**
 * Gets the {@link IPath} from the given {@link IEditorInput}.
 * 
 * @param editorInput
 *            the {@link IEditorInput}
 * @return the {@link IPath} from the given {@link IEditorInput} if any, <code>null</code> otherwise
 */
public static IPath getPath(final IEditorInput editorInput) {
	final IPath path;
	if (editorInput instanceof ILocationProvider) {
		path = ((ILocationProvider)editorInput).getPath(editorInput);
	} else if (editorInput instanceof IURIEditorInput) {
		final URI uri = ((IURIEditorInput)editorInput).getURI();
		if (uri != null) {
			final File osFile = URIUtil.toFile(uri);
			if (osFile != null) {
				path = Path.fromOSString(osFile.getAbsolutePath());
			} else {
				path = null;
			}
		} else {
			path = null;
		}
	} else {
		path = null;
	}
	return path;
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:29,代码来源:UiIdeMappingUtils.java

示例4: getScriptsHome

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
public static String getScriptsHome() throws IOException, URISyntaxException {
  File scriptsHome;

  try {
    URL url = new URL("platform:/plugin/" + PLUGIN_ID + "/scripts");
    URL fileURL = FileLocator.toFileURL(url);
    scriptsHome = new File(URIUtil.toURI(fileURL));
  } catch (MalformedURLException e) {
    // Running without OSGi, make a guess the scripts are relative to the local directory
    scriptsHome = new File("scripts/");
  }
  if (!scriptsHome.exists()) {
    throw new IOException("Failed to find " + PLUGIN_ID + "/scripts, expected it here: " + scriptsHome);
  }
  return scriptsHome.toString();
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:17,代码来源:PythonHelper.java

示例5: getSciSoftPyHome

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
public static String getSciSoftPyHome() throws IOException, URISyntaxException {
  File scriptsHome;

  try {
    URL url = new URL("platform:/plugin/org.eclipse.triquetrum.python.service/scripts");
    URL fileURL = FileLocator.toFileURL(url);
    scriptsHome = new File(URIUtil.toURI(fileURL));
  } catch (MalformedURLException e) {
    // Running without OSGi, make a guess the scripts are relative to the local directory
    scriptsHome = new File("../org.eclipse.triquetrum.python.service/scripts/");
  }
  if (!scriptsHome.exists()) {
    throw new IOException("Failed to find org.eclipse.triquetrum.python.service/scripts, expected it here: " + scriptsHome);
  }
  return scriptsHome.toString();
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:17,代码来源:PythonHelper.java

示例6: 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

示例7: adapt

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
private QLibrary adapt(QJob job, IProject project) {

		try {
			if (!project.isOpen())
				project.open(null);

			IFile file = project.getFile("META-INF/MANIFEST.MF");
			InputStream is = file.getContents();

			Manifest manifest = new Manifest(is);
			Attributes attributes = manifest.getMainAttributes();
			QLibrary lib = QOperatingSystemLibraryFactory.eINSTANCE.createLibrary();
			lib.setLibrary(job.getSystem().getSystemLibrary());
			lib.setName(URIUtil.lastSegment(project.getLocationURI()));
			lib.setText(attributes.getValue("Bundle-Name"));

			is.close();

			return lib;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
 
开发者ID:asupdev,项目名称:asup,代码行数:25,代码来源:JDTSourceManagerImpl.java

示例8: getInputStream

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
@Override
protected InputStream getInputStream() throws CoreException
{
	URI uri = ((IFile) underlyingResource).getLocationURI();
	try
	{
		return URIUtil.toJarURI(uri, JPFProject.MANIFEST_PATH).toURL().openStream();
	}
	catch( IOException e )
	{
		return null;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:JarPluginModelImpl.java

示例9: getInternalIgnoreFile

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
/**
 * Returns path to %workspace%/.metadata/.plugins/%this_plugin%/.pgcodekeeperignore.<br>
 * Handles {@link URISyntaxException} using {@link ExceptionNotifier}.
 *
 * @return path or null in case {@link URISyntaxException} has been handled.
 */
static Path getInternalIgnoreFile() {
    try {
        return Paths.get(URIUtil.toURI(Platform.getInstanceLocation().getURL()))
                .resolve(".metadata").resolve(".plugins").resolve(PLUGIN_ID.THIS) //$NON-NLS-1$ //$NON-NLS-2$
                .resolve(FILE.IGNORED_OBJECTS);
    } catch (URISyntaxException ex) {
        ExceptionNotifier.notifyDefault(Messages.InternalIgnoreList_error_workspace_path, ex);
        return null;
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:17,代码来源:InternalIgnoreList.java

示例10: fixURI

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
/**
 * Fix uris by adding missing // to single file:/ prefix
 */
public static String fixURI(URI uri) {
	if (Platform.OS_WIN32.equals(Platform.getOS())) {
		uri = URIUtil.toFile(uri).toURI();
	}
	String uriString = uri.toString();
	return uriString.replaceFirst("file:/([^/])", "file:///$1");
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:ResourceUtils.java

示例11: toURI

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
public static URI toURI(String uriString) {
	if (uriString == null || uriString.isEmpty()) {
		return null;
	}
	try {
		URI uri = new URI(uriString);
		if (Platform.OS_WIN32.equals(Platform.getOS()) && URIUtil.isFileURI(uri)) {
			uri = URIUtil.toFile(uri).toURI();
		}
		return uri;
	} catch (URISyntaxException e) {
		JavaLanguageServerPlugin.logException("Failed to resolve "+uriString, e);
		return null;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:JDTUtils.java

示例12: getFakeJDKsLocation

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
public static File getFakeJDKsLocation() {
	Bundle bundle = Platform.getBundle(JavaLanguageServerTestPlugin.PLUGIN_ID);
	try {
		URL url = FileLocator.toFileURL(bundle.getEntry(FAKE_JDK));
		File file = URIUtil.toFile(URIUtil.toURI(url));
		return file;
	} catch (IOException | URISyntaxException e) {
		JavaLanguageServerPlugin.logException(e.getMessage(), e);
		return null;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:TestVMType.java

示例13: fromBundle

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
/**
 * Loads the content of a file from within a bundle. Returns null if not found.
 * 
 * @param pathname of the file within the bundle.
 * @return null if not found.
 */
public static String fromBundle(String pathname) {
	Bundle bundle = Platform.getBundle(FluentMkUI.PLUGIN_ID);
	URL url = bundle.getEntry(pathname);
	if (url == null) return null;
	try {
		url = FileLocator.toFileURL(url);
		return read(URIUtil.toFile(URIUtil.toURI(url)));
	} catch (Exception e) {
		Log.error(e);
		return "";
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:19,代码来源:FileUtils.java

示例14: getExampleScriptsHome

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
private String getExampleScriptsHome() throws IOException, URISyntaxException {
  String location = System.getProperty(OVERRIDE_LOCATION_PROPERTY);
  if (location != null) {
    return location;
  }

  URL url = new URL("platform:/plugin/" + PLUGIN_ID + "/scripts");
  URL fileURL = FileLocator.toFileURL(url);
  File exampleScriptsHome = new File(URIUtil.toURI(fileURL));
  if (!exampleScriptsHome.exists()) {
    throw new IOException("Failed to find " + PLUGIN_ID + "/scripts, expected it here: " + exampleScriptsHome);
  }
  return exampleScriptsHome.toString();
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:15,代码来源:TestRunner.java

示例15: getSystemScriptsHome

import org.eclipse.core.runtime.URIUtil; //导入依赖的package包/类
private static String getSystemScriptsHome() throws IOException, URISyntaxException {
  URL url = new URL("platform:/plugin/" + PLUGIN_ID + "/scripts");
  URL fileURL = FileLocator.toFileURL(url);
  File systemScriptsHome = new File(URIUtil.toURI(fileURL));
  if (!systemScriptsHome.exists()) {
    throw new IOException("Failed to find " + PLUGIN_ID + "/scripts, expected it here: " + systemScriptsHome);
  }
  return systemScriptsHome.toString();
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:10,代码来源:PythonService.java


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