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

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

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

Path.segment介绍

[英]The path segments
[中]路径段

代码示例

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

public boolean isValidPath(String path) {
  Path test = new Path(path);
  for (int i = 0, max = test.segmentCount(); i < max; i++)
    if (!isValidSegment(test.segment(i)))
      return false;
  return true;
}

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

public static Object createCodeFormatter(Map<?, ?> options, String workspacePath)
{
 if (options == null)
 {
  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(workspacePath).segment(0));
  if (project != null)
  {
   IJavaProject javaProject = JavaCore.create(project);
   if (javaProject != null)
   {
    options = javaProject.getOptions(true);
   }
  }
 }
 return ToolFactory.createCodeFormatter(options);
}

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

public boolean isValidPath(String path) {
  Path test = new Path(path);
  for (int i = 0, max = test.segmentCount(); i < max; i++)
    if (!isValidSegment(test.segment(i)))
      return false;
  return true;
}

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

public static Object createCodeFormatter(Map<?, ?> options, String workspacePath)
{
 if (options == null)
 {
  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(workspacePath).segment(0));
  if (project != null)
  {
   IJavaProject javaProject = JavaCore.create(project);
   if (javaProject != null)
   {
    options = javaProject.getOptions(true);
   }
  }
 }
 return ToolFactory.createCodeFormatter(options);
}

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

public void save(String filename, Map<String, String> map, HashSet<?> selected) {
  Properties properties = getTracingOptions(map);
  for (Enumeration<?> keys = properties.keys(); keys.hasMoreElements();) {
    String key = keys.nextElement().toString();
    Path path = new Path(key);
    if (path.segmentCount() < 1 || !selected.contains(path.segment(0).toString())) {
      properties.remove(key);
    }
  }
  save(filename, properties);
}

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

if (modelDirectory != null)
 referencedModelProjects.add(workspaceRoot.getProject(new Path(modelDirectory).segment(0)));
 String editDirectory = referencedGenModel.getEditDirectory();
 if (editDirectory != null && !modelDirectory.equals(editDirectory) && !"".equals(editDirectory))
  referencedEditProjects.add(workspaceRoot.getProject(new Path(editDirectory).segment(0)));

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

public void save(String filename, Map map, HashSet selected) {
  Properties properties = getTracingOptions(map);
  for (Enumeration keys = properties.keys(); keys.hasMoreElements();) {
    String key = keys.nextElement().toString();
    Path path = new Path(key);
    if (path.segmentCount() < 1 || !selected.contains(path.segment(0).toString())) {
      properties.remove(key);
    }
  }
  save(filename, properties);
}

代码示例来源:origin: org.eclipse/org.eclipse.jem.util

private static IProject getProject(URI uri) {
  String projectName;
  if (isPlatformResourceURI(uri))
    projectName = uri.segment(1);
  else if (uri.scheme() == null) {
    projectName = new Path(uri.path()).segment(0); //assume project name is first in the URI
  } else
    return null;
  IProject project = getWorkspace().getRoot().getProject(URI.decode(projectName));
  if (project != null && project.isAccessible())
    return project;
  else
    return null;
}

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

/**
 * Returns whether the given string is syntactically correct as a path on
 * the specified file system. The device id is the prefix up to and
 * including the device separator for the specified file system; the path
 * proper is everything to the right of it, or the entire string if there is
 * no device separator. When the specified platform is a file system with no
 * meaningful device separator, the entire string is treated as the path
 * proper. The device id is not checked for validity; the path proper is
 * correct if each of the segments in its canonicalized form is valid.
 *
 * @param path the path to check
 * @param forWindows true if the path is for the Windows file system
 * @return <code>true</code> if the given string is a valid path,
 *    and <code>false</code> otherwise
 * @see #isValidSegment(String, boolean)
 * @since 3.7
 */
private static boolean isValidPath(String path, boolean forWindows) {
  Path test = new Path(path, forWindows);
  for (int i = 0, max = test.segmentCount(); i < max; i++)
    if (!Path.isValidSegment(test.segment(i), forWindows))
      return false;
  return true;
}

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

tpath = menuPath.segment(0);

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

/**
 * Returns whether the given string is syntactically correct as a path on
 * the specified file system. The device id is the prefix up to and
 * including the device separator for the specified file system; the path
 * proper is everything to the right of it, or the entire string if there is
 * no device separator. When the specified platform is a file system with no
 * meaningful device separator, the entire string is treated as the path
 * proper. The device id is not checked for validity; the path proper is
 * correct if each of the segments in its canonicalized form is valid.
 *
 * @param path the path to check
 * @param forWindows true if the path is for the Windows file system
 * @return <code>true</code> if the given string is a valid path,
 *    and <code>false</code> otherwise
 * @see #isValidSegment(String, boolean)
 * @since 3.7
 */
private static boolean isValidPath(String path, boolean forWindows) {
  Path test = new Path(path, forWindows);
  for (int i = 0, max = test.segmentCount(); i < max; i++)
    if (!Path.isValidSegment(test.segment(i), forWindows))
      return false;
  return true;
}

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

public IPath makeAbsolute() {
  if (isAbsolute()) {
    return this;
  }
  Path result = new Path(device, segments, separators | HAS_LEADING);
  //may need canonicalizing if it has leading ".." or "." segments
  if (result.segmentCount() > 0) {
    String first = result.segment(0);
    if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
      result.canonicalize();
    }
  }
  return result;
}

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

public IPath makeAbsolute() {
  if (isAbsolute()) {
    return this;
  }
  Path result = new Path(device, segments, separators | HAS_LEADING);
  //may need canonicalizing if it has leading ".." or "." segments
  if (result.segmentCount() > 0) {
    String first = result.segment(0);
    if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
      result.canonicalize();
    }
  }
  return result;
}

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

@Override
public IPath makeAbsolute() {
  if (isAbsolute()) {
    return this;
  }
  Path result = new Path(device, segments, flags | HAS_LEADING);
  //may need canonicalizing if it has leading ".." or "." segments
  if (result.segmentCount() > 0) {
    String first = result.segment(0);
    if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
      result.canonicalize();
    }
  }
  return result;
}

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

@Override
public IPath makeAbsolute() {
  if (isAbsolute()) {
    return this;
  }
  Path result = new Path(device, segments, flags | HAS_LEADING);
  //may need canonicalizing if it has leading ".." or "." segments
  if (result.segmentCount() > 0) {
    String first = result.segment(0);
    if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
      result.canonicalize();
    }
  }
  return result;
}

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

MElementContainer<MMenuElement> findMenuFromPath(MElementContainer<MMenuElement> menu,
      Path menuPath, int segment) {
    int idx = ContributionsAnalyzer.indexForId(menu, menuPath.segment(segment));
    if (idx == -1) {
      if (segment + 1 < menuPath.segmentCount() || !menuPath.hasTrailingSeparator()) {
        return null;
      }
      return menu;
    }
    MElementContainer<MMenuElement> item = (MElementContainer<MMenuElement>) menu.getChildren()
        .get(idx);
    if (item.getChildren().isEmpty()) {
      if (segment + 1 == menuPath.segmentCount()) {
        return menu;
      }
      return null;
    }
    return findMenuFromPath(item, menuPath, segment + 1);
  }
}

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

private void addExtraPrerequisites(IPluginModelBase model, ArrayList<IPluginModelBase> result) {
  try {
    IBuildModel buildModel = PluginRegistry.createBuildModel(model);
    if (buildModel == null)
      return;
    IBuildEntry entry = buildModel.getBuild().getEntry(IBuildEntry.JARS_EXTRA_CLASSPATH);
    if (entry == null)
      return;
    String[] tokens = entry.getTokens();
    for (String token : tokens) {
      Path path = new Path(token);
      if (path.segmentCount() >= 2 && path.segment(0).equals("..")) { //$NON-NLS-1$
        for (int j = 0; j < fModels.length; j++) {
          if (fModels[j].getPluginBase().getId().equals(path.segment(1)) && !result.contains(fModels[j])) {
            result.add(fModels[j]);
          }
        }
      }
    }
  } catch (CoreException e) {
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.jsp.core

baseResource = workspaceRoot.getProject(baseIPath.segment(0));
project = ResourcesPlugin.getWorkspace().getRoot().getProject(baseIPath.segment(0));
if (project.isAccessible()) {
  ProjectDescription description = createDescription(project);

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

private IStatus copy(String src, IFileStore destinationParent, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException {
  Path srcPath = new Path(src);
  IFileStore source = fileSystem.getStore(srcPath);
  String elementName = srcPath.segment(srcPath.segmentCount() - 1);
  IFileStore destination = destinationParent.getChild(elementName);
  SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
  if (destination.fetchInfo().exists()) {
    return Status.OK_STATUS;
  }
  if (source.fetchInfo().isDirectory()) {
    destination.mkdir(EFS.NONE, new NullProgressMonitor());
  }
  source.copy(destination, EFS.OVERWRITE, subMonitor.split(1));
  return Status.OK_STATUS;
}

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

String positionInParent = "after=" + menuPath.segment(0); //$NON-NLS-1$
int segmentCount = menuPath.segmentCount();
if (segmentCount > 1) {
  parentId = menuPath.segment(segmentCount - 2);
  positionInParent = "after=" + menuPath.segment(segmentCount - 1); //$NON-NLS-1$

相关文章