/**
   * Returns the Amazon S3 {@link StorageClass} enumeration value representing the specified Amazon
   * S3 <code>StorageClass</code> ID string. If the specified string doesn't map to a known Amazon
   * S3 storage class, an <code>IllegalArgumentException</code> is thrown.
   *
   * @param s3StorageClassString The Amazon S3 storage class ID string.
   * @return The Amazon S3 <code>StorageClass</code> enumeration value representing the specified
   *     Amazon S3 storage class ID.
   * @throws IllegalArgumentException If the specified value does not map to one of the known Amazon
   *     S3 storage classes.
   */
  public static StorageClass fromValue(String s3StorageClassString)
      throws IllegalArgumentException {
    for (StorageClass storageClass : StorageClass.values()) {
      if (storageClass.toString().equals(s3StorageClassString)) return storageClass;
    }

    throw new IllegalArgumentException(
        "Cannot create enum from " + s3StorageClassString + " value!");
  }
Example #2
0
  @Override
  public String toString() {
    if (getStorageClass() == StorageClass.REG) {
      return "[0x"
          + Integer.toHexString(num)
          + " "
          + (type == null ? "*" : type.toString())
          + " () *]";
    }

    StringBuilder b = new StringBuilder(256);
    b.append("[");
    b.append(name == null ? "*" : name);
    b.append(" ");
    b.append(stg_class == null ? "*" : stg_class.toXcodeString());
    b.append(" ");
    b.append(type == null ? "*" : type.toString());
    b.append(" ");
    b.append(value == null ? "()" : value.toString());

    /* bit_field, bit_field_expr, enum_value are exclusively set */
    b.append(" ");
    if (bit_field != 0 || bit_field_expr != null) {
      if (bit_field != 0) b.append(bit_field);
      else b.append(bit_field_expr.toString());
    } else if (enum_value != null) {
      b.append(" ");
      b.append(enum_value.toString());
    } else {
      b.append("*");
    }

    b.append(declared ? " D" : "");

    if (gcc_attrs != null) {
      b.append(" ");
      b.append(gcc_attrs.toString());
    }

    b.append("]");

    return b.toString();
  }