congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
IPath.segments
Code IndexAdd Tabnine to your IDE (free)

How to use
segments
method
in
org.eclipse.core.runtime.IPath

Best Java code snippets using org.eclipse.core.runtime.IPath.segments (Showing top 20 results out of 315)

origin: org.eclipse.jdt/org.eclipse.jdt.ui

private boolean isJREContainer(IPath path) {
  if (path == null)
    return false;
  String[] segments= path.segments();
  for (String seg : segments) {
    if (seg.equals(JavaRuntime.JRE_CONTAINER)) {
      return true;
    }
  }
  return false;
}

origin: org.eclipse/org.eclipse.jst.jsp.core

private boolean isHiddenResource(IPath p) {
  String[] segments = p.segments();
  for (int i = 0; i < segments.length; i++) {
    if (segments[i].startsWith(".")) //$NON-NLS-1$
      return true;
  }
  return false;
}
origin: org.eclipse/org.eclipse.compare

private static boolean greaterThan(IFile f1, IFile f2) {
  String[] ss1= f1.getFullPath().segments();
  String[] ss2= f2.getFullPath().segments();
  int l1= ss1.length;
  int l2= ss2.length;
  int n= Math.max(l1, l2);
  
  for (int i= 0; i < n; i++) {
    String s1= i < l1 ? ss1[i] : ""; //$NON-NLS-1$
    String s2= i < l2 ? ss2[i] : ""; //$NON-NLS-1$
    int rc= s1.compareToIgnoreCase(s2);
    if (rc != 0)
      return rc < 0;
  }
  return false;
}

origin: org.eclipse.platform/org.eclipse.compare

private static boolean greaterThan(IFile f1, IFile f2) {
  String[] ss1= f1.getFullPath().segments();
  String[] ss2= f2.getFullPath().segments();
  int l1= ss1.length;
  int l2= ss2.length;
  int n= Math.max(l1, l2);
  for (int i= 0; i < n; i++) {
    String s1= i < l1 ? ss1[i] : ""; //$NON-NLS-1$
    String s2= i < l2 ? ss2[i] : ""; //$NON-NLS-1$
    int rc= s1.compareToIgnoreCase(s2);
    if (rc != 0)
      return rc < 0;
  }
  return false;
}
origin: eclipse/aCute

private IContainer getContainer(ILaunchConfiguration configuration) throws CoreException {
  String projectPath = configuration.getAttribute(DotnetRunDelegate.PROJECT_FOLDER, ""); //$NON-NLS-1$
  if (projectPath == null) {
    return null;
  }
  IPath location = new Path(projectPath);
  if (location.toFile().isDirectory()) {
    return ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(location);
  } else if (location.segmentCount() == 1) {
    return ResourcesPlugin.getWorkspace().getRoot().getProject(location.segments()[0]);
  } else {
    return ResourcesPlugin.getWorkspace().getRoot().getFolder(location);
  }
}
origin: org.eclipse.platform/org.eclipse.debug.ui

  public static String getQualifiedName(IPath path) {
    StringBuffer buffer = new StringBuffer();
    String[] segments = path.segments();
    if (segments.length > 0) {
      buffer.append(path.lastSegment());
      if (segments.length > 1) {
        buffer.append(" - "); //$NON-NLS-1$
        if (path.getDevice() != null) {
          buffer.append(path.getDevice());
        }
        for (int i = 0; i < segments.length - 1; i++) {
          buffer.append(File.separatorChar);
          buffer.append(segments[i]);
        }
      }
      return buffer.toString();
    }
    return IInternalDebugCoreConstants.EMPTY_STRING;
  }
}
origin: org.eclipse/org.eclipse.jdt.ui

public Object findElement(IPath path) {
  String[] segments= path.segments();
  
  Object elem= fProvider.getRoot();
  for (int i= 0; i < segments.length && elem != null; i++) {
    List list= fProvider.getChildren(elem);
    String name= segments[i];
    elem= null;
    for (int k= 0; k < list.size(); k++) {
      Object curr= list.get(k);
      if (fProvider.isFolder(curr) && name.equals(fProvider.getLabel(curr))) {
        elem= curr;
        break;
      }
    }
  }
  return elem;
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

public Object findElement(IPath path) {
  String[] segments= path.segments();
  Object elem= fProvider.getRoot();
  for (int i= 0; i < segments.length && elem != null; i++) {
    List<?> list= fProvider.getChildren(elem);
    String name= segments[i];
    elem= null;
    for (int k= 0; k < list.size(); k++) {
      Object curr= list.get(k);
      if (fProvider.isFolder(curr) && name.equals(fProvider.getLabel(curr))) {
        elem= curr;
        break;
      }
    }
  }
  return elem;
}
origin: org.testeditor/org.testeditor.dsl.common

@VisibleForTesting
protected String packageForPath(final IPath path, final IPath classpath) {
 if ((classpath == null)) {
  ClasspathUtil.logger.error("Could not find corresponding classpath entry for path=\'{}\', using default package instead.", path);
  return null;
 }
 final int start = path.matchingFirstSegments(classpath);
 int _segmentCount = classpath.segmentCount();
 boolean _notEquals = (start != _segmentCount);
 if (_notEquals) {
  throw new RuntimeException("illegal path for classpath");
 }
 final String result = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(path.removeFirstSegments(start).segments())), ".");
 ClasspathUtil.logger.debug("Inferred package for originPath=\'{}\' is \'{}\'.", path, result);
 return result;
}

origin: eclipse/buildship

/**
 * Calculates the absolute path from a base to a relative target location.
 *
 * @param base the base path
 * @param relativePath the relative path from the base to the target
 * @return the absolute path to the target location
 * @throws NullPointerException if an argument is {@code null}
 * @throws IllegalArgumentException if a) the base path does not denote an absolute path b) the
 *             target path does not denote a relative path, or c) the relative path is invalid
 *             (i.e. points above the root folder)
 */
public static IPath getAbsolutePath(IPath base, IPath relativePath) {
  Preconditions.checkNotNull(base);
  Preconditions.checkNotNull(relativePath);
  Preconditions.checkArgument(base.isAbsolute());
  Preconditions.checkArgument(!relativePath.isAbsolute());
  IPath result = base;
  for (String segment : relativePath.segments()) {
    IPath newResult = result.append(segment);
    // Appending a '..' segment to the root path does not fail but returns a new path object
    // see org.eclipse.core.runtime.Path.removeLastSegment(int)
    if (segment.equals("..") && newResult.segmentCount() >= result.segmentCount()) {
      throw new IllegalArgumentException(String.format("Relative path can't point beyond the root (base=%s, relativePath=%s).", base, relativePath));
    }
    result = newResult;
  }
  return result;
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

public Object findElement(IPath path) {
  String[] segments= path.segments();
  Object elem= fProvider.getRoot();
  for (int i= 0; i < segments.length && elem != null; i++) {
    List<?> list= fProvider.getChildren(elem);
    String name= segments[i];
    elem= null;
    for (int k= 0; k < list.size(); k++) {
      Object curr= list.get(k);
      if (fProvider.isFolder(curr) && name.equals(fProvider.getLabel(curr))) {
        elem= curr;
        break;
      }
    }
  }
  return elem;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 * Fuzzy search for Java project in the workspace that matches
 * the given path.
 *
 * @param path the path to match
 * @return the matching Java project or <code>null</code>
 * @since 3.2
 */
private IJavaProject findJavaProject(IPath path) {
  if (path == null)
    return null;
  String[] pathSegments= path.segments();
  IJavaModel model= JavaCore.create(JavaPlugin.getWorkspace().getRoot());
  IJavaProject[] projects;
  try {
    projects= model.getJavaProjects();
  } catch (JavaModelException e) {
    return null; // ignore - use default JRE
  }
  for (int i= 0; i < projects.length; i++) {
    IPath projectPath= projects[i].getProject().getFullPath();
    String projectSegment= projectPath.segments()[0];
    for (int j= 0; j < pathSegments.length; j++)
      if (projectSegment.equals(pathSegments[j]))
        return projects[i];
  }
  return null;
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 * Fuzzy search for Java project in the workspace that matches
 * the given path.
 *
 * @param path the path to match
 * @return the matching Java project or <code>null</code>
 * @since 3.2
 */
private IJavaProject findJavaProject(IPath path) {
  if (path == null)
    return null;
  String[] pathSegments= path.segments();
  IJavaModel model= JavaCore.create(JavaPlugin.getWorkspace().getRoot());
  IJavaProject[] projects;
  try {
    projects= model.getJavaProjects();
  } catch (JavaModelException e) {
    return null; // ignore - use default JRE
  }
  for (int i= 0; i < projects.length; i++) {
    IPath projectPath= projects[i].getProject().getFullPath();
    String projectSegment= projectPath.segments()[0];
    for (int j= 0; j < pathSegments.length; j++)
      if (projectSegment.equals(pathSegments[j]))
        return projects[i];
  }
  return null;
}
origin: org.eclipse.pde/org.eclipse.pde.ui

private void createParents(IProject fragmentProject, IPath parent) throws CoreException {
  try {
  String[] segments = parent.segments();
  String path = ""; //$NON-NLS-1$
  File dest = fragmentProject.getFullPath().toFile();
  String destCanonicalPath = dest.getCanonicalPath();
  for (String segment : segments) {
    path += SLASH + segment;
    IFolder folder = fragmentProject.getFolder(path);
    File file = folder.getFullPath().toFile();
    String canonicalFilePath = file.getCanonicalPath();
    if (!canonicalFilePath.startsWith(destCanonicalPath + File.separator)) {
      throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(),
          MessageFormat.format("Entry is outside of the target dir: : {0}", file.getName()), null)); //$NON-NLS-1$
    }
    if (!folder.exists()) {
      folder.create(true, true, getProgressMonitor());
    }
  }
  }
  catch (IOException e) {
    throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(),
        MessageFormat.format("IOException while processing: {0}", fragmentProject.getName()), //$NON-NLS-1$
        null));
  }
}
origin: org.eclipse/org.eclipse.jdt.ui

/**
 * Fuzzy search for Java project in the workspace that matches
 * the given path.
 * 
 * @param path the path to match
 * @return the matching Java project or <code>null</code>
 * @since 3.2
 */
private IJavaProject findJavaProject(IPath path) {
  if (path == null)
    return null;
  String[] pathSegments= path.segments();
  IJavaModel model= JavaCore.create(JavaPlugin.getWorkspace().getRoot());
  IJavaProject[] projects;
  try {
    projects= model.getJavaProjects();
  } catch (JavaModelException e) {
    return null; // ignore - use default JRE
  }
  for (int i= 0; i < projects.length; i++) {
    IPath projectPath= projects[i].getProject().getFullPath();
    String projectSegment= projectPath.segments()[0];
    for (int j= 0; j < pathSegments.length; j++)
      if (projectSegment.equals(pathSegments[j]))
        return projects[i];
  }
  return null;
}
origin: org.eclipse/org.eclipse.jdt.debug.ui

public String getLabel(Object o) {
  if (o instanceof PackageFragmentRootSourceContainer) {
    PackageFragmentRootSourceContainer container = (PackageFragmentRootSourceContainer) o;
    IPackageFragmentRoot fragmentRoot = container.getPackageFragmentRoot();
    IPath path = fragmentRoot.getPath();
    if (path.segmentCount() > 0) {
      StringBuffer buffer = new StringBuffer();
      buffer.append(path.lastSegment());
      if (path.segmentCount() > 1) {
        buffer.append(" - "); //$NON-NLS-1$
        if (path.getDevice() != null) {
          buffer.append(path.getDevice());
        }
        String[] segments = path.segments();
        for (int i = 0; i < segments.length - 1; i++) {
          buffer.append(File.separatorChar);
          buffer.append(segments[i]);
        }
      }
      return buffer.toString();
    }
  }
  return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
origin: org.eclipse/org.eclipse.jst.jsp.core

/**
 * @param loader
 * @param entry
 */
private void addVariableEntry(TaglibClassLoader loader, IClasspathEntry entry) {
  if (DEBUG)
    System.out.println(" -> adding variable entry: [" + entry + "]"); //$NON-NLS-1$ //$NON-NLS-2$
  // variable should either be a project or a library entry
  // BUG 169431
  String variableName = entry.getPath().toString();
  IPath variablePath = JavaCore.getResolvedVariablePath(entry.getPath());
  variablePath = JavaCore.getClasspathVariable(variableName);
  // RATLC01076854
  // variable paths may not exist
  // in that case null will be returned
  if (variablePath != null) {
    if (variablePath.segments().length == 1) {
      IProject varProj = ResourcesPlugin.getWorkspace().getRoot().getProject(variablePath.toString());
      if (varProj != null && varProj.exists()) {
        addClasspathEntriesForProject(varProj, loader);
        return;
      }
    }
    addLibraryEntry(loader, variablePath);
  }
}
origin: org.eclipse.tycho/org.eclipse.jdt.core

IFolder f = (IFolder) elements.next();
IPath relativePath = f.getFullPath().removeFirstSegments(segments);
String[] pkgName = relativePath.segments();
IPackageFragment pkg = root.getPackageFragment(pkgName);
if (!Util.isExcluded(pkg))
origin: org.testeditor/org.testeditor.dsl.common

 String _plus = ("found standard path for " + _string);
 ClasspathUtil.logger.debug(_plus);
 return IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(relativePath.removeFirstSegments(3).segments())), ".");
} else {
 String _string_1 = originPath.toString();
origin: org.eclipse.platform/org.eclipse.core.resources

String[] segments = path.segments();
for (String nextSegment : segments) {
org.eclipse.core.runtimeIPathsegments

Javadoc

Returns the segments in this path in order.

Popular methods of IPath

  • toString
    Returns a string representation of this path, including its device id. The same separator, "/", is u
  • toFile
    Returns a java.io.File corresponding to this path.
  • toOSString
    Returns a string representation of this path which uses the platform-dependent path separator define
  • append
    Returns the canonicalized path obtained from the concatenation of the given path's segments to the e
  • segmentCount
    Returns the number of segments in this path. Note that both root and empty paths have 0 segments.
  • removeLastSegments
    Returns a copy of this path with the given number of segments removed from the end. The device id is
  • lastSegment
    Returns the last segment of this path, ornull if it does not have any segments.
  • removeFirstSegments
    Returns a copy of this path with the given number of segments removed from the beginning. The device
  • segment
    Returns the specified segment of this path, ornull if the path does not have such a segment.
  • equals
    Returns whether this path equals the given object. Equality for paths is defined to be: same sequenc
  • isAbsolute
    Returns whether this path is an absolute path (ignoring any device id). Absolute paths start with a
  • isPrefixOf
    Returns whether this path is a prefix of the given path. To be a prefix, this path's segments must a
  • isAbsolute,
  • isPrefixOf,
  • toPortableString,
  • makeRelative,
  • makeAbsolute,
  • getDevice,
  • isEmpty,
  • addTrailingSeparator,
  • getFileExtension,
  • setDevice

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Notification (javax.management)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now