org.apache.hadoop.fs.Path.hasWindowsDrive()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(87)

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

Path.hasWindowsDrive介绍

暂无

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

private static int startPositionWithoutWindowsDrive(String path) {
 if (hasWindowsDrive(path)) {
  return path.charAt(0) ==  SEPARATOR_CHAR ? 3 : 2;
 } else {
  return 0;
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public String toString() {
 // we can't use uri.toString(), which escapes everything, because we want
 // illegal characters unescaped in the string, for glob processing, etc.
 StringBuilder buffer = new StringBuilder();
 if (uri.getScheme() != null) {
  buffer.append(uri.getScheme());
  buffer.append(":");
 }
 if (uri.getAuthority() != null) {
  buffer.append("//");
  buffer.append(uri.getAuthority());
 }
 if (uri.getPath() != null) {
  String path = uri.getPath();
  if (path.indexOf('/')==0 &&
    hasWindowsDrive(path) &&                // has windows drive
    uri.getScheme() == null &&              // but no scheme
    uri.getAuthority() == null)             // or authority
   path = path.substring(1);                 // remove slash before drive
  buffer.append(path);
 }
 if (uri.getFragment() != null) {
  buffer.append("#");
  buffer.append(uri.getFragment());
 }
 return buffer.toString();
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Normalize a path string to use non-duplicated forward slashes as
 * the path separator and remove any trailing path separators.
 *
 * @param scheme the URI scheme. Used to deduce whether we
 * should replace backslashes or not
 * @param path the scheme-specific part
 * @return the normalized path string
 */
private static String normalizePath(String scheme, String path) {
 // Remove double forward slashes.
 path = StringUtils.replace(path, "//", "/");
 // Remove backslashes if this looks like a Windows path. Avoid
 // the substitution if it looks like a non-local URI.
 if (WINDOWS &&
   (hasWindowsDrive(path) ||
    (scheme == null) ||
    (scheme.isEmpty()) ||
    (scheme.equals("file")))) {
  path = StringUtils.replace(path, "\\", "/");
 }
 
 // trim trailing slash from non-root path (ignoring windows drive)
 int minLength = startPositionWithoutWindowsDrive(path) + 1;
 if (path.length() > minLength && path.endsWith(SEPARATOR)) {
  path = path.substring(0, path.length()-1);
 }
 
 return path;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Construct a Path from components.
 *
 * @param scheme the scheme
 * @param authority the authority
 * @param path the path
 */
public Path(String scheme, String authority, String path) {
 checkPathArg( path );
 // add a slash in front of paths with Windows drive letters
 if (hasWindowsDrive(path) && path.charAt(0) != '/') {
  path = "/" + path;
 }
 // add "./" in front of Linux relative paths so that a path containing
 // a colon e.q. "a:b" will not be interpreted as scheme "a".
 if (!WINDOWS && path.charAt(0) != '/') {
  path = "./" + path;
 }
 initialize(scheme, authority, path, null);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

if (hasWindowsDrive(pathString) && pathString.charAt(0) != '/') {
 pathString = "/" + pathString;

代码示例来源:origin: ch.cern.hadoop/hadoop-common

private static int startPositionWithoutWindowsDrive(String path) {
 if (hasWindowsDrive(path)) {
  return path.charAt(0) ==  SEPARATOR_CHAR ? 3 : 2;
 } else {
  return 0;
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

private static int startPositionWithoutWindowsDrive(String path) {
 if (hasWindowsDrive(path)) {
  return path.charAt(0) ==  SEPARATOR_CHAR ? 3 : 2;
 } else {
  return 0;
 }
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

private static int startPositionWithoutWindowsDrive(String path) {
 if (hasWindowsDrive(path)) {
  return path.charAt(0) ==  SEPARATOR_CHAR ? 3 : 2;
 } else {
  return 0;
 }
}

代码示例来源:origin: io.hops/hadoop-common

private static int startPositionWithoutWindowsDrive(String path) {
 if (hasWindowsDrive(path)) {
  return path.charAt(0) ==  SEPARATOR_CHAR ? 3 : 2;
 } else {
  return 0;
 }
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

/** True if the directory of this path is absolute. */
public boolean isAbsolute() {
 int start = hasWindowsDrive(uri.getPath(), true) ? 3 : 0;
 return uri.getPath().startsWith(SEPARATOR, start);
}

代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core

/** True if the directory of this path is absolute. */
public boolean isAbsolute() {
 int start = hasWindowsDrive(uri.getPath(), true) ? 3 : 0;
 return uri.getPath().startsWith(SEPARATOR, start);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

private String normalizePath(String path) {
 // remove double slashes & backslashes
 path = path.replace("//", "/");
 path = path.replace("\\", "/");
 
 // trim trailing slash from non-root path (ignoring windows drive)
 int minLength = hasWindowsDrive(path, true) ? 4 : 1;
 if (path.length() > minLength && path.endsWith("/")) {
  path = path.substring(0, path.length()-1);
 }
 
 return path;
}

代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core

private String normalizePath(String path) {
 // remove double slashes & backslashes
 path = path.replace("//", "/");
 path = path.replace("\\", "/");
 
 // trim trailing slash from non-root path (ignoring windows drive)
 int minLength = hasWindowsDrive(path, true) ? 4 : 1;
 if (path.length() > minLength && path.endsWith("/")) {
  path = path.substring(0, path.length()-1);
 }
 
 return path;
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

/** Returns the parent of a path or null if at root. */
public Path getParent() {
 String path = uri.getPath();
 int lastSlash = path.lastIndexOf('/');
 int start = hasWindowsDrive(path, true) ? 3 : 0;
 if ((path.length() == start) ||               // empty path
   (lastSlash == start && path.length() == start+1)) { // at root
  return null;
 }
 String parent;
 if (lastSlash==-1) {
  parent = CUR_DIR;
 } else {
  int end = hasWindowsDrive(path, true) ? 3 : 0;
  parent = path.substring(0, lastSlash==end?end+1:lastSlash);
 }
 return new Path(uri.getScheme(), uri.getAuthority(), parent);
}

代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core

/** Returns the parent of a path or null if at root. */
public Path getParent() {
 String path = uri.getPath();
 int lastSlash = path.lastIndexOf('/');
 int start = hasWindowsDrive(path, true) ? 3 : 0;
 if ((path.length() == start) ||               // empty path
   (lastSlash == start && path.length() == start+1)) { // at root
  return null;
 }
 String parent;
 if (lastSlash==-1) {
  parent = CUR_DIR;
 } else {
  int end = hasWindowsDrive(path, true) ? 3 : 0;
  parent = path.substring(0, lastSlash==end?end+1:lastSlash);
 }
 return new Path(uri.getScheme(), uri.getAuthority(), parent);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public String toString() {
 // we can't use uri.toString(), which escapes everything, because we want
 // illegal characters unescaped in the string, for glob processing, etc.
 StringBuffer buffer = new StringBuffer();
 if (uri.getScheme() != null) {
  buffer.append(uri.getScheme());
  buffer.append(":");
 }
 if (uri.getAuthority() != null) {
  buffer.append("//");
  buffer.append(uri.getAuthority());
 }
 if (uri.getPath() != null) {
  String path = uri.getPath();
  if (path.indexOf('/')==0 &&
    hasWindowsDrive(path, true) &&          // has windows drive
    uri.getScheme() == null &&              // but no scheme
    uri.getAuthority() == null)             // or authority
   path = path.substring(1);                 // remove slash before drive
  buffer.append(path);
 }
 return buffer.toString();
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/** Construct a Path from components. */
public Path(String scheme, String authority, String path) {
 checkPathArg( path );
 // add a slash in front of paths with Windows drive letters
 if (hasWindowsDrive(path) && path.charAt(0) != '/') {
  path = "/" + path;
 }
 // add "./" in front of Linux relative paths so that a path containing
 // a colon e.q. "a:b" will not be interpreted as scheme "a".
 if (!WINDOWS && path.charAt(0) != '/') {
  path = "./" + path;
 }
 initialize(scheme, authority, path, null);
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

/** Construct a Path from components. */
public Path(String scheme, String authority, String path) {
 checkPathArg( path );
 // add a slash in front of paths with Windows drive letters
 if (hasWindowsDrive(path) && path.charAt(0) != '/') {
  path = "/" + path;
 }
 // add "./" in front of Linux relative paths so that a path containing
 // a colon e.q. "a:b" will not be interpreted as scheme "a".
 if (!WINDOWS && path.charAt(0) != '/') {
  path = "./" + path;
 }
 initialize(scheme, authority, path, null);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/** Construct a Path from components. */
public Path(String scheme, String authority, String path) {
 checkPathArg( path );
 // add a slash in front of paths with Windows drive letters
 if (hasWindowsDrive(path) && path.charAt(0) != '/') {
  path = "/" + path;
 }
 // add "./" in front of Linux relative paths so that a path containing
 // a colon e.q. "a:b" will not be interpreted as scheme "a".
 if (!WINDOWS && path.charAt(0) != '/') {
  path = "./" + path;
 }
 initialize(scheme, authority, path, null);
}

代码示例来源:origin: io.hops/hadoop-common

/**
 * Construct a Path from components.
 *
 * @param scheme the scheme
 * @param authority the authority
 * @param path the path
 */
public Path(String scheme, String authority, String path) {
 checkPathArg( path );
 // add a slash in front of paths with Windows drive letters
 if (hasWindowsDrive(path) && path.charAt(0) != '/') {
  path = "/" + path;
 }
 // add "./" in front of Linux relative paths so that a path containing
 // a colon e.q. "a:b" will not be interpreted as scheme "a".
 if (!WINDOWS && path.charAt(0) != '/') {
  path = "./" + path;
 }
 initialize(scheme, authority, path, null);
}

相关文章