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

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

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

Path.lastSegment介绍

暂无

代码示例

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

/**
 * Returns the last segment of the given URI. For a hierarchical URL this returns
 * the last segment of the path. For opaque URIs this treats the scheme-specific
 * part as a path and returns the last segment. Returns <code>null</code> for
 * a hierarchical URI with an empty path, and for opaque URIs whose scheme-specific
 * part cannot be interpreted as a path.
 */
public static String lastSegment(URI location) {
  String path = location.getPath();
  if (path == null)
    return new Path(location.getSchemeSpecificPart()).lastSegment();
  return new Path(path).lastSegment();
}

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

/**
 * Returns the last segment of the given URI. For a hierarchical URL this returns
 * the last segment of the path. For opaque URIs this treats the scheme-specific
 * part as a path and returns the last segment. Returns <code>null</code> for
 * a hierarchical URI with an empty path, and for opaque URIs whose scheme-specific
 * part cannot be interpreted as a path.
 */
public static String lastSegment(URI location) {
  String path = location.getPath();
  if (path == null)
    return new Path(location.getSchemeSpecificPart()).lastSegment();
  return new Path(path).lastSegment();
}

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

/**
 * Returns the last segment of the given URI. For a hierarchical URL this returns
 * the last segment of the path. For opaque URIs this treats the scheme-specific
 * part as a path and returns the last segment. Returns <code>null</code> for
 * a hierarchical URI with an empty path, and for opaque URIs whose scheme-specific
 * part cannot be interpreted as a path.
 */
public static String lastSegment(URI location) {
  String path = location.getPath();
  if (path == null)
    return new Path(location.getSchemeSpecificPart()).lastSegment();
  return new Path(path).lastSegment();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
public String getLabel(Object element) {
  if (element.equals(root)) {
    return ((ZipEntry) element).getName();
  }
  return new Path(((ZipEntry) element).getName()).lastSegment();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
public String getLabel(Object element) {
  if (element.equals(root)) {
    return ((ZipEntry) element).getName();
  }
  return stripPath(new Path(((ZipEntry) element).getName()).lastSegment());
}

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

protected String validateAntCombo() {
  String path = new Path(fAntCombo.getText()).lastSegment();
  if ("build.xml".equals(path)) //$NON-NLS-1$
    return PDEUIMessages.ExportOptionsTab_antReservedMessage;
  return null;
}

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

protected String getFileName() {
  if (fArchiveFileButton.getSelection()) {
    String path = fArchiveCombo.getText();
    if (path != null && path.length() > 0) {
      String fileName = new Path(path).lastSegment();
      if (!fileName.endsWith(ZIP_EXTENSION)) {
        fileName += ZIP_EXTENSION;
      }
      return fileName;
    }
  }
  return null;
}

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

protected String getFileName() {
  if (fArchiveFileButton.getSelection()) {
    String path = fArchiveCombo.getText();
    if (path != null && path.length() > 0) {
      String fileName = new Path(path).lastSegment();
      if (!fileName.endsWith(ZIP_EXTENSION)) {
        fileName += ZIP_EXTENSION;
      }
      return fileName;
    }
  }
  return null;
}

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

protected String getFileName() {
  if (fArchiveFileButton.getSelection()) {
    String path = fArchiveCombo.getText();
    if (path != null && path.length() > 0) {
      String fileName = new Path(path).lastSegment();
      if (!fileName.endsWith(ZIP_EXTENSION) && !fileName.endsWith(WAR_EXTENSION)) {
        fileName += ZIP_EXTENSION;
      }
      return fileName;
    }
  }
  return null;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Returns the simple name of the feature image file.
 *
 * @return the simple name of the feature image file,
 * or <code>null</code> if none
 */
public String getFeatureImageName() {
  if (bundleGroupProperties == null) {
    return null;
  }
  URL url = bundleGroupProperties.getFeatureImageUrl();
  return url == null ? null : new Path(url.getPath()).lastSegment();
}

代码示例来源:origin: eclipse/aCute

private boolean isProjectFile(Path path) {
  if (path == null || path.isEmpty()) {
    return false;
  } else if (!path.lastSegment().matches("(.*\\.csproj|project.json)")) { //$NON-NLS-1$
    return false;
  } else if (!path.toFile().isFile()) {
    return false;
  }
  return true;
}

代码示例来源:origin: eclipse/aCute

private boolean isProjectFile(Path path) {
  if (path == null || path.isEmpty()) {
    return false;
  } else if (!path.lastSegment().matches("(.*\\.csproj|project.json)")) { //$NON-NLS-1$
    return false;
  } else if (!path.toFile().isFile()) {
    return false;
  }
  return true;
}

代码示例来源: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.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.ui.ide

@Override
public String getLabel(Object element) {
  if (element.equals(root)) {
    return ((TarEntry) element).getName();
  }
  return stripPath(new Path(((TarEntry) element).getName()).lastSegment());
}

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

private Image getEditorImage(StagingEntry diff) {
  if (diff.isSubmodule())
    return SUBMODULE;
  Image image = DEFAULT;
  String name = new Path(diff.getPath()).lastSegment();
  if (name != null) {
    ImageDescriptor descriptor = PlatformUI.getWorkbench()
        .getEditorRegistry().getImageDescriptor(name);
    image = (Image) this.resourceManager.get(descriptor);
  }
  return image;
}

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

public ImageDescriptor getImageDescriptor(Object object) {
  String name = new org.eclipse.core.runtime.Path(path).lastSegment();
  if (name != null) {
    return PlatformUI.getWorkbench().getEditorRegistry()
        .getImageDescriptor(name);
  } else
    return PlatformUI.getWorkbench().getSharedImages()
        .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
}

代码示例来源:origin: sdbg/sdbg

public String getName() {
 if (getMarker().getResource() instanceof IFile) {
  return ((IFile) getMarker().getResource()).getName();
 }
 try {
  Path path = new Path((String) getMarker().getAttribute(FILE_PATH));
  return path.lastSegment();
 } catch (CoreException e) {
  SDBGDebugCorePlugin.logError(e);
 }
 return null;
}

相关文章