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

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

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

Path.isRoot介绍

暂无

代码示例

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

@Override
public IPath addFileExtension(String extension) {
  if (isRoot() || isEmpty() || hasTrailingSeparator())
    return this;
  int len = segments.length;
  String[] newSegments = new String[len];
  System.arraycopy(segments, 0, newSegments, 0, len - 1);
  newSegments[len - 1] = segments[len - 1] + '.' + extension;
  return new Path(device, newSegments, flags);
}

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

public IPath addFileExtension(String extension) {
  if (isRoot() || isEmpty() || hasTrailingSeparator())
    return this;
  int len = segments.length;
  String[] newSegments = new String[len];
  System.arraycopy(segments, 0, newSegments, 0, len - 1);
  newSegments[len - 1] = segments[len - 1] + '.' + extension;
  return new Path(device, newSegments, separators);
}

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

@Override
public IPath addTrailingSeparator() {
  if (hasTrailingSeparator() || isRoot()) {
    return this;
  }
  //XXX workaround, see 1GIGQ9V
  if (isEmpty()) {
    return new Path(device, segments, (flags & IS_FOR_WINDOWS) | HAS_LEADING);
  }
  return new Path(device, segments, flags | HAS_TRAILING);
}

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

public IPath addTrailingSeparator() {
  if (hasTrailingSeparator() || isRoot()) {
    return this;
  }
  //XXX workaround, see 1GIGQ9V
  if (isEmpty()) {
    return new Path(device, segments, HAS_LEADING);
  }
  return new Path(device, segments, separators | HAS_TRAILING);
}

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

public IPath addTrailingSeparator() {
  if (hasTrailingSeparator() || isRoot()) {
    return this;
  }
  //XXX workaround, see 1GIGQ9V
  if (isEmpty()) {
    return new Path(device, segments, HAS_LEADING);
  }
  return new Path(device, segments, separators | HAS_TRAILING);
}

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

@Override
public IPath addFileExtension(String extension) {
  if (isRoot() || isEmpty() || hasTrailingSeparator())
    return this;
  int len = segments.length;
  String[] newSegments = new String[len];
  System.arraycopy(segments, 0, newSegments, 0, len - 1);
  newSegments[len - 1] = segments[len - 1] + '.' + extension;
  return new Path(device, newSegments, flags);
}

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

@Override
public IPath addTrailingSeparator() {
  if (hasTrailingSeparator() || isRoot()) {
    return this;
  }
  //XXX workaround, see 1GIGQ9V
  if (isEmpty()) {
    return new Path(device, segments, (flags & IS_FOR_WINDOWS) | HAS_LEADING);
  }
  return new Path(device, segments, flags | HAS_TRAILING);
}

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

public IPath addFileExtension(String extension) {
  if (isRoot() || isEmpty() || hasTrailingSeparator())
    return this;
  int len = segments.length;
  String[] newSegments = new String[len];
  System.arraycopy(segments, 0, newSegments, 0, len - 1);
  newSegments[len - 1] = segments[len - 1] + '.' + extension;
  return new Path(device, newSegments, separators);
}

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

public boolean isPrefixOf(IPath anotherPath) {
  if (device == null) {
    if (anotherPath.getDevice() != null) {
      return false;
    }
  } else {
    if (!device.equalsIgnoreCase(anotherPath.getDevice())) {
      return false;
    }
  }
  if (isEmpty() || (isRoot() && anotherPath.isAbsolute())) {
    return true;
  }
  int len = segments.length;
  if (len > anotherPath.segmentCount()) {
    return false;
  }
  for (int i = 0; i < len; i++) {
    if (!segments[i].equals(anotherPath.segment(i)))
      return false;
  }
  return true;
}

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

@Override
public boolean isPrefixOf(IPath anotherPath) {
  if (device == null) {
    if (anotherPath.getDevice() != null) {
      return false;
    }
  } else {
    if (!device.equalsIgnoreCase(anotherPath.getDevice())) {
      return false;
    }
  }
  if (isEmpty() || (isRoot() && anotherPath.isAbsolute())) {
    return true;
  }
  int len = segments.length;
  if (len > anotherPath.segmentCount()) {
    return false;
  }
  for (int i = 0; i < len; i++) {
    if (!segments[i].equals(anotherPath.segment(i)))
      return false;
  }
  return true;
}

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

public boolean isPrefixOf(IPath anotherPath) {
  if (device == null) {
    if (anotherPath.getDevice() != null) {
      return false;
    }
  } else {
    if (!device.equalsIgnoreCase(anotherPath.getDevice())) {
      return false;
    }
  }
  if (isEmpty() || (isRoot() && anotherPath.isAbsolute())) {
    return true;
  }
  int len = segments.length;
  if (len > anotherPath.segmentCount()) {
    return false;
  }
  for (int i = 0; i < len; i++) {
    if (!segments[i].equals(anotherPath.segment(i)))
      return false;
  }
  return true;
}

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

@Override
public boolean isPrefixOf(IPath anotherPath) {
  if (device == null) {
    if (anotherPath.getDevice() != null) {
      return false;
    }
  } else {
    if (!device.equalsIgnoreCase(anotherPath.getDevice())) {
      return false;
    }
  }
  if (isEmpty() || (isRoot() && anotherPath.isAbsolute())) {
    return true;
  }
  int len = segments.length;
  if (len > anotherPath.segmentCount()) {
    return false;
  }
  for (int i = 0; i < len; i++) {
    if (!segments[i].equals(anotherPath.segment(i)))
      return false;
  }
  return true;
}

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

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
  if (this.isEmpty())
    return tail.setDevice(device).makeRelative().makeUNC(isUNC());
  if (this.isRoot())
    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, (separators & (HAS_LEADING | IS_UNC)) | (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.jibx.config.3rdparty.org.eclipse/org.eclipse.equinox.common

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
  if (this.isEmpty())
    return tail.setDevice(device).makeRelative().makeUNC(isUNC());
  if (this.isRoot())
    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, (separators & (HAS_LEADING | IS_UNC)) | (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: 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;
}

相关文章