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