org.eclipse.core.runtime.Path.getFileExtension()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(14.5k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中org.eclipse.core.runtime.Path.getFileExtension()方法的一些代码示例,展示了Path.getFileExtension()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.getFileExtension()方法的具体详情如下:
包路径:org.eclipse.core.runtime.Path
类名称:Path
方法名:getFileExtension

Path.getFileExtension介绍

暂无

代码示例

代码示例来源:origin: jbosstools/m2e-apt

public static boolean isJar(File file){
 return file.isFile() && "jar".equals(new Path(file.getAbsolutePath()).getFileExtension());
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.publisher.eclipse

private static ExecutablesDescriptor createUnixDescriptor(String os, String executable, File location) {
  ExecutablesDescriptor result = new ExecutablesDescriptor(os, executable, location, null);
  File[] files = location.listFiles();
  for (int i = 0; files != null && i < files.length; i++) {
    String extension = new Path(files[i].getName()).getFileExtension();
    if (files[i].isFile() && (extension == null || extension.equals("so"))) //$NON-NLS-1$
      result.addFile(files[i]);
  }
  result.iniFile = new File(location, executable + ".ini"); //$NON-NLS-1$
  return result;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.publisher.eclipse

private static ExecutablesDescriptor createUnixDescriptor(String os, String executable, File location) {
  ExecutablesDescriptor result = new ExecutablesDescriptor(os, executable, location, null);
  File[] files = location.listFiles();
  for (int i = 0; files != null && i < files.length; i++) {
    String extension = new Path(files[i].getName()).getFileExtension();
    if (files[i].isFile() && (extension == null || extension.equals("so"))) //$NON-NLS-1$
      result.addFile(files[i]);
  }
  result.iniFile = new File(location, executable + ".ini"); //$NON-NLS-1$
  return result;
}

代码示例来源:origin: org.eclipse.osgi/org.eclipse.equinox.p2.publisher.eclipse

private static ExecutablesDescriptor createUnixDescriptor(String os, String executable, File location) {
  ExecutablesDescriptor result = new ExecutablesDescriptor(os, executable, location, null);
  File[] files = location.listFiles();
  for (int i = 0; files != null && i < files.length; i++) {
    String extension = new Path(files[i].getName()).getFileExtension();
    if (files[i].isFile() && (extension == null || extension.equals("so"))) //$NON-NLS-1$
      result.addFile(files[i]);
  }
  result.iniFile = new File(location, executable + ".ini"); //$NON-NLS-1$
  return result;
}

代码示例来源:origin: org.eclipse.osgi/org.eclipse.equinox.p2.publisher.eclipse

public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) {
  Map<Locale, Map<String, String>> localizations;
  Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
  String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX];
  if (hostBundleLocalization == null)
    return null;
  if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
      bundleLocation.isFile()) {
    localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
    //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
  } else {
    localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
    // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
  }
  return localizations;
}

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.api.tools

/**
 * Returns a URL describing a file inside a bundle.
 *
 * @param bundleLocation root location of the bundle. May be a directory or
 *            a file (jar)
 * @param filePath bundle relative path to desired file
 * @return URL to the file
 * @throws MalformedURLException
 */
protected URL getFileInBundle(File bundleLocation, String filePath) throws MalformedURLException {
  String extension = new Path(bundleLocation.getName()).getFileExtension();
  StringBuilder urlSt = new StringBuilder();
  if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$
    urlSt.append("jar:file:"); //$NON-NLS-1$
    urlSt.append(bundleLocation.getAbsolutePath());
    urlSt.append("!/"); //$NON-NLS-1$
    urlSt.append(filePath);
  } else {
    urlSt.append("file:"); //$NON-NLS-1$
    urlSt.append(bundleLocation.getAbsolutePath());
    urlSt.append(File.separatorChar);
    urlSt.append(filePath);
  }
  return new URL(urlSt.toString());
}

代码示例来源:origin: org.eclipse.equinox/common

public IPath removeFileExtension() {
  String extension = getFileExtension();
  if (extension == null || extension.equals("")) { //$NON-NLS-1$
    return this;
  }
  String lastSegment = lastSegment();
  int index = lastSegment.lastIndexOf(extension) - 1;
  return removeLastSegments(1).append(lastSegment.substring(0, index));
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.equinox.common

public IPath removeFileExtension() {
  String extension = getFileExtension();
  if (extension == null || extension.equals("")) { //$NON-NLS-1$
    return this;
  }
  String lastSegment = lastSegment();
  int index = lastSegment.lastIndexOf(extension) - 1;
  return removeLastSegments(1).append(lastSegment.substring(0, index));
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.publisher.eclipse

public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) {
  Map<Locale, Map<String, String>> localizations;
  Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
  String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX];
  if (hostBundleLocalization == null)
    return null;
  if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
      bundleLocation.isFile()) {
    localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
    //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
  } else {
    localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
    // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
  }
  return localizations;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.publisher.eclipse

public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) {
  Map<Locale, Map<String, String>> localizations;
  Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
  String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX];
  if (hostBundleLocalization == null)
    return null;
  if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
      bundleLocation.isFile()) {
    localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
    //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
  } else {
    localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
    // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
  }
  return localizations;
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.common

@Override
public IPath removeFileExtension() {
  String extension = getFileExtension();
  if (extension == null || extension.equals("")) { //$NON-NLS-1$
    return this;
  }
  String lastSegment = lastSegment();
  int index = lastSegment.lastIndexOf(extension) - 1;
  return removeLastSegments(1).append(lastSegment.substring(0, index));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.equinox.common

@Override
public IPath removeFileExtension() {
  String extension = getFileExtension();
  if (extension == null || extension.equals("")) { //$NON-NLS-1$
    return this;
  }
  String lastSegment = lastSegment();
  int index = lastSegment.lastIndexOf(extension) - 1;
  return removeLastSegments(1).append(lastSegment.substring(0, index));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

/**
   * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
   */
  @Override
  public boolean visit(IResourceProxy proxy) {
    if (proxy.getType() == IResource.FILE) {
      if (ICoreConstants.TARGET_FILE_EXTENSION.equalsIgnoreCase(new Path(proxy.getName()).getFileExtension())) {
        fList.add(proxy.requestResource());
      }
      return false;
    }
    return true;
  }
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.publisher.eclipse

private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) {
  Map<Locale, Map<String, String>> localizations;
  Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
  String[] bundleManifestValues = getManifestCachedValues(manifest);
  String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list
  if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
      bundleLocation.isFile()) {
    localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
    //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
  } else {
    localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
    // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
  }
  return localizations;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.publisher.eclipse

private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) {
  Map<Locale, Map<String, String>> localizations;
  Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
  String[] bundleManifestValues = getManifestCachedValues(manifest);
  String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list
  if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
      bundleLocation.isFile()) {
    localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
    //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
  } else {
    localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
    // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
  }
  return localizations;
}

代码示例来源:origin: org.eclipse.osgi/org.eclipse.equinox.p2.publisher.eclipse

private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) {
  Map<Locale, Map<String, String>> localizations;
  Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
  String[] bundleManifestValues = getManifestCachedValues(manifest);
  String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list
  if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
      bundleLocation.isFile()) {
    localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
    //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
  } else {
    localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
    // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
  }
  return localizations;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

InputStream stream = null;
try {
  String extension = new Path(bundleLocation.getName()).getFileExtension();
  if ("jar".equals(extension) && bundleLocation.isFile()) { //$NON-NLS-1$
    jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);

代码示例来源:origin: org.eclipse/org.eclipse.emf.importer

/**
 * The framework calls this to see if the file is correct.
 */
@Override
protected boolean validatePage()
{
 if (super.validatePage())
 {
  String extension = new Path(getFileName()).getFileExtension();
  if (extension == null || !extension.equals("genmodel"))
  {
   setErrorMessage(ImporterPlugin.INSTANCE.getString("_UI_GeneratorModelFileNameMustEndWithGenModel_message"));
   return false;
  }
  else
  {
   genModelContainerPath = getContainerFullPath();
   genModelFileName = getFileName();
   return true;
  }
 }
 else
 {
  return false;
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.debug.ui

/**
   * Populates the children of the specified parent <code>FileSystemElement</code>
   * @param element
   * @param folderonly
   */
  private void populateElementChildren() {
    FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
    List<File> allchildren = provider.getChildren(this.getFileSystemObject());
    DebugFileSystemElement newelement = null;
    for (File child : allchildren) {
      if(child.isFile()) {
        Path childpath = new Path(child.getAbsolutePath());
        String extension = childpath.getFileExtension();
        if (extension != null && (extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION) || extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION))) {
          newelement = new DebugFileSystemElement(provider.getLabel(child), this, provider.isFolder(child));
          newelement.setFileSystemObject(child);
        }
      }
      else {
        newelement = new DebugFileSystemElement(provider.getLabel(child), this, provider.isFolder(child));
        newelement.setFileSystemObject(child);
      }
    }
    setPopulated();
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui

protected boolean validatePage()
{
 Path newName = new Path(getFileName());
 String fullFileName = getFileName();
 String extension = newName.getFileExtension();
 if (extension == null || !extension.equalsIgnoreCase("xsd")) 
 {
  setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_FILENAME_MUST_END_XSD"));
  return false;
 }
 else 
 {
  setErrorMessage(null);
 }
 // check for file should be case insensitive
 String sameName = existsFileAnyCase(fullFileName);
 if (sameName != null) 
 {
  setErrorMessage(XSDEditorPlugin.getPlugin().getString("_ERROR_FILE_ALREADY_EXISTS", sameName)); //$NON-NLS-1$
  return false;
 }
 return super.validatePage();
}

相关文章