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

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

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

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

  @Override
  public String isValid(String newText) {
    if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$
      return INVALID_NAME_NO_MESSAGE;
    if (res.getParent().findMember(newText) != null)
      return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
    if (! res.getParent().getFullPath().isValidSegment(newText))
      return ReorgMessages.ReorgQueries_invalidNameMessage;
    IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType());
    if (status.getSeverity() == IStatus.ERROR)
      return status.getMessage();
    if (res.getName().equalsIgnoreCase(newText))
      return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;
    return null;
  }
};
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

  @Override
  public String isValid(String newText) {
    if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$
      return INVALID_NAME_NO_MESSAGE;
    if (res.getParent().findMember(newText) != null)
      return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
    if (! res.getParent().getFullPath().isValidSegment(newText))
      return ReorgMessages.ReorgQueries_invalidNameMessage;
    IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType());
    if (status.getSeverity() == IStatus.ERROR)
      return status.getMessage();
    if (res.getName().equalsIgnoreCase(newText))
      return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;
    return null;
  }
};
origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.common

@Override
public IPath append(IPath tail) {
  //optimize some easy cases
  if (tail == null || tail.segmentCount() == 0)
    return this;
  //these call chains look expensive, but in most cases they are no-ops
  //the tail must be for the same platform as this instance
  if (this.isEmpty() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$
    return tail.setDevice(device).makeRelative().makeUNC(isUNC());
  if (this.isRoot() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$
    return tail.setDevice(device).makeAbsolute().makeUNC(isUNC());
  //concatenate the two segment arrays
  int myLen = segments.length;
  int tailLen = tail.segmentCount();
  String[] newSegments = new String[myLen + tailLen];
  System.arraycopy(segments, 0, newSegments, 0, myLen);
  for (int i = 0; i < tailLen; i++) {
    newSegments[myLen + i] = tail.segment(i);
  }
  //use my leading separators and the tail's trailing separator
  Path result = new Path(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0));
  String tailFirstSegment = newSegments[myLen];
  if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
    result.canonicalize();
  }
  return result;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.equinox.common

@Override
public IPath append(IPath tail) {
  //optimize some easy cases
  if (tail == null || tail.segmentCount() == 0)
    return this;
  //these call chains look expensive, but in most cases they are no-ops
  //the tail must be for the same platform as this instance
  if (this.isEmpty() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$
    return tail.setDevice(device).makeRelative().makeUNC(isUNC());
  if (this.isRoot() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$
    return tail.setDevice(device).makeAbsolute().makeUNC(isUNC());
  //concatenate the two segment arrays
  int myLen = segments.length;
  int tailLen = tail.segmentCount();
  String[] newSegments = new String[myLen + tailLen];
  System.arraycopy(segments, 0, newSegments, 0, myLen);
  for (int i = 0; i < tailLen; i++) {
    newSegments[myLen + i] = tail.segment(i);
  }
  //use my leading separators and the tail's trailing separator
  Path result = new Path(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0));
  String tailFirstSegment = newSegments[myLen];
  if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
    result.canonicalize();
  }
  return result;
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
public RefactoringStatus checkNewElementName(String newName) throws CoreException {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  if (! newName.trim().equals(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank);
  IContainer c=     fSourceFolder.getResource().getParent();
  if (! c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name);
  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER));
  if (result.hasFatalError())
    return result;
  result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER)));
  if (result.hasFatalError())
    return result;
  IJavaProject project= fSourceFolder.getJavaProject();
  IPath p= project.getProject().getFullPath().append(newName);
  if (project.findPackageFragmentRoot(p) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists);
  if (project.getProject().findMember(new Path(newName)) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists);
  return result;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

@Override
public RefactoringStatus checkNewElementName(String newName) throws CoreException {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  if (! newName.trim().equals(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank);
  IContainer c=     fSourceFolder.getResource().getParent();
  if (! c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name);
  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER));
  if (result.hasFatalError())
    return result;
  result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER)));
  if (result.hasFatalError())
    return result;
  IJavaProject project= fSourceFolder.getJavaProject();
  IPath p= project.getProject().getFullPath().append(newName);
  if (project.findPackageFragmentRoot(p) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists);
  if (project.getProject().findMember(new Path(newName)) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists);
  return result;
}
origin: org.eclipse/org.eclipse.jdt.ui

public RefactoringStatus checkNewElementName(String newName) throws CoreException {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  if (! newName.trim().equals(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank); 
  
  IContainer c=     fSourceFolder.getResource().getParent();
  if (! c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name); 
  
  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER));
  if (result.hasFatalError())
    return result;		
      
  result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER)));        
  if (result.hasFatalError())
    return result;
    
  IJavaProject project= fSourceFolder.getJavaProject();
  IPath p= project.getProject().getFullPath().append(newName);
  if (project.findPackageFragmentRoot(p) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists); 
  
  if (project.getProject().findMember(new Path(newName)) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists); 
  return result;		
}

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

public RefactoringStatus checkNewElementName(String newName) throws JavaModelException {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  IContainer c= fResource.getParent();
  if (c == null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_Internal_Error);
  if (c.findMember(newName) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_alread_exists);
  if (!c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_invalidName);
  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
  if (!result.hasFatalError())
    result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
  return result;
}
origin: org.eclipse/org.eclipse.wst.xsd.ui

public RefactoringStatus checkNewElementName(String newName)  {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  IContainer c= fResource.getParent();
  if (c == null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.Internal_Error")); //$NON-NLS-1$
          
  if (c.findMember(newName) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.alread_exists")); //$NON-NLS-1$
    
  if (!c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.invalidName")); //$NON-NLS-1$

  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
  if (! result.hasFatalError())
    result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));        
  return result;		
}

origin: org.eclipse.platform/org.eclipse.ltk.core.refactoring

/**
 * Validates if the a name is valid. This method does not change the name settings on the refactoring. It is intended to be used
 * in a wizard to validate user input.
 *
 * @param newName the name to validate
 * @return returns the resulting status of the validation
 */
public RefactoringStatus validateNewElementName(String newName) {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  IContainer c= fResource.getParent();
  if (c == null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_no_parent);
  if (!c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_invalid_name);
  if (c.findMember(newName) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_resource_already_exists);
  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
  if (!result.hasFatalError())
    result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
  return result;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.ltk.core.refactoring

/**
 * Validates if the a name is valid. This method does not change the name settings on the refactoring. It is intended to be used
 * in a wizard to validate user input.
 *
 * @param newName the name to validate
 * @return returns the resulting status of the validation
 */
public RefactoringStatus validateNewElementName(String newName) {
  Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
  IContainer c= fResource.getParent();
  if (c == null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_no_parent);
  if (!c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_invalid_name);
  if (c.findMember(newName) != null)
    return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameResourceProcessor_error_resource_already_exists);
  RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
  if (!result.hasFatalError())
    result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
  return result;
}
org.eclipse.core.runtimeIPathisValidSegment

Javadoc

Returns whether the given string is valid as a segment in a path. The rules for valid segments are as follows:
  • the empty string is not valid
  • any string containing the slash character ('/') is not valid
  • any string containing segment or device separator characters on the local file system, such as the backslash ('\') and colon (':') on some file systems.

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
  • Best IntelliJ 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