Java 类org.apache.hadoop.fs.XAttr.NameSpace 实例源码

项目:hadoop    文件:XAttrHelper.java   
/**
 * Build <code>XAttr</code> from name with prefix and value.
 * Name can not be null. Value can be null. The name and prefix 
 * are validated.
 * Both name and namespace are case sensitive.
 */
public static XAttr buildXAttr(String name, byte[] value) {
  Preconditions.checkNotNull(name, "XAttr name cannot be null.");

  final int prefixIndex = name.indexOf(".");
  if (prefixIndex < 3) {// Prefix length is at least 3.
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  } else if (prefixIndex == name.length() - 1) {
    throw new HadoopIllegalArgumentException("XAttr name cannot be empty.");
  }

  NameSpace ns;
  final String prefix = name.substring(0, prefixIndex);
  if (StringUtils.equalsIgnoreCase(prefix, NameSpace.USER.toString())) {
    ns = NameSpace.USER;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.TRUSTED.toString())) {
    ns = NameSpace.TRUSTED;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SYSTEM.toString())) {
    ns = NameSpace.SYSTEM;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SECURITY.toString())) {
    ns = NameSpace.SECURITY;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.RAW.toString())) {
    ns = NameSpace.RAW;
  } else {
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  }
  XAttr xAttr = (new XAttr.Builder()).setNameSpace(ns).setName(name.
      substring(prefixIndex + 1)).setValue(value).build();

  return xAttr;
}
项目:aliyun-oss-hadoop-fs    文件:XAttrHelper.java   
/**
 * Build <code>XAttr</code> from name with prefix and value.
 * Name can not be null. Value can be null. The name and prefix
 * are validated.
 * Both name and namespace are case sensitive.
 */
public static XAttr buildXAttr(String name, byte[] value) {
  Preconditions.checkNotNull(name, "XAttr name cannot be null.");

  final int prefixIndex = name.indexOf(".");
  if (prefixIndex < 3) {// Prefix length is at least 3.
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  } else if (prefixIndex == name.length() - 1) {
    throw new HadoopIllegalArgumentException("XAttr name cannot be empty.");
  }

  NameSpace ns;
  final String prefix = name.substring(0, prefixIndex);
  if (StringUtils.equalsIgnoreCase(prefix, NameSpace.USER.toString())) {
    ns = NameSpace.USER;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.TRUSTED.toString())) {
    ns = NameSpace.TRUSTED;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SYSTEM.toString())) {
    ns = NameSpace.SYSTEM;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SECURITY.toString())) {
    ns = NameSpace.SECURITY;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.RAW.toString())) {
    ns = NameSpace.RAW;
  } else {
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  }

  return (new XAttr.Builder()).setNameSpace(ns).setName(name.
      substring(prefixIndex + 1)).setValue(value).build();
}
项目:big-c    文件:XAttrHelper.java   
/**
 * Build <code>XAttr</code> from name with prefix and value.
 * Name can not be null. Value can be null. The name and prefix 
 * are validated.
 * Both name and namespace are case sensitive.
 */
public static XAttr buildXAttr(String name, byte[] value) {
  Preconditions.checkNotNull(name, "XAttr name cannot be null.");

  final int prefixIndex = name.indexOf(".");
  if (prefixIndex < 3) {// Prefix length is at least 3.
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  } else if (prefixIndex == name.length() - 1) {
    throw new HadoopIllegalArgumentException("XAttr name cannot be empty.");
  }

  NameSpace ns;
  final String prefix = name.substring(0, prefixIndex);
  if (StringUtils.equalsIgnoreCase(prefix, NameSpace.USER.toString())) {
    ns = NameSpace.USER;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.TRUSTED.toString())) {
    ns = NameSpace.TRUSTED;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SYSTEM.toString())) {
    ns = NameSpace.SYSTEM;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SECURITY.toString())) {
    ns = NameSpace.SECURITY;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.RAW.toString())) {
    ns = NameSpace.RAW;
  } else {
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  }
  XAttr xAttr = (new XAttr.Builder()).setNameSpace(ns).setName(name.
      substring(prefixIndex + 1)).setValue(value).build();

  return xAttr;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:XAttrHelper.java   
/**
 * Build <code>XAttr</code> from name with prefix and value.
 * Name can not be null. Value can be null. The name and prefix 
 * are validated.
 * Both name and namespace are case sensitive.
 */
public static XAttr buildXAttr(String name, byte[] value) {
  Preconditions.checkNotNull(name, "XAttr name cannot be null.");

  final int prefixIndex = name.indexOf(".");
  if (prefixIndex < 3) {// Prefix length is at least 3.
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  } else if (prefixIndex == name.length() - 1) {
    throw new HadoopIllegalArgumentException("XAttr name cannot be empty.");
  }

  NameSpace ns;
  final String prefix = name.substring(0, prefixIndex).toLowerCase();
  if (prefix.equals(NameSpace.USER.toString().toLowerCase())) {
    ns = NameSpace.USER;
  } else if (prefix.equals(NameSpace.TRUSTED.toString().toLowerCase())) {
    ns = NameSpace.TRUSTED;
  } else if (prefix.equals(NameSpace.SYSTEM.toString().toLowerCase())) {
    ns = NameSpace.SYSTEM;
  } else if (prefix.equals(NameSpace.SECURITY.toString().toLowerCase())) {
    ns = NameSpace.SECURITY;
  } else if (prefix.equals(NameSpace.RAW.toString().toLowerCase())) {
    ns = NameSpace.RAW;
  } else {
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  }
  XAttr xAttr = (new XAttr.Builder()).setNameSpace(ns).setName(name.
      substring(prefixIndex + 1)).setValue(value).build();

  return xAttr;
}
项目:FlexMap    文件:XAttrHelper.java   
/**
 * Build <code>XAttr</code> from name with prefix and value.
 * Name can not be null. Value can be null. The name and prefix 
 * are validated.
 * Both name and namespace are case sensitive.
 */
public static XAttr buildXAttr(String name, byte[] value) {
  Preconditions.checkNotNull(name, "XAttr name cannot be null.");

  final int prefixIndex = name.indexOf(".");
  if (prefixIndex < 3) {// Prefix length is at least 3.
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  } else if (prefixIndex == name.length() - 1) {
    throw new HadoopIllegalArgumentException("XAttr name cannot be empty.");
  }

  NameSpace ns;
  final String prefix = name.substring(0, prefixIndex).toLowerCase();
  if (prefix.equals(NameSpace.USER.toString().toLowerCase())) {
    ns = NameSpace.USER;
  } else if (prefix.equals(NameSpace.TRUSTED.toString().toLowerCase())) {
    ns = NameSpace.TRUSTED;
  } else if (prefix.equals(NameSpace.SYSTEM.toString().toLowerCase())) {
    ns = NameSpace.SYSTEM;
  } else if (prefix.equals(NameSpace.SECURITY.toString().toLowerCase())) {
    ns = NameSpace.SECURITY;
  } else if (prefix.equals(NameSpace.RAW.toString().toLowerCase())) {
    ns = NameSpace.RAW;
  } else {
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  }
  XAttr xAttr = (new XAttr.Builder()).setNameSpace(ns).setName(name.
      substring(prefixIndex + 1)).setValue(value).build();

  return xAttr;
}
项目:aliyun-oss-hadoop-fs    文件:XAttrHelper.java   
public static String getPrefixedName(XAttr.NameSpace ns, String name) {
  return StringUtils.toLowerCase(ns.toString()) + "." + name;
}