public DescribeTableResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    DescribeTableResult describeTableResult = new DescribeTableResult();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.currentToken;
    if (token == null) token = context.nextToken();
    if (token == VALUE_NULL) return null;

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("Table", targetDepth)) {
          context.nextToken();
          describeTableResult.setTable(
              TableDescriptionJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getLastParsedParentElement() == null
            || context.getLastParsedParentElement().equals(currentParentElement)) {
          if (context.getCurrentDepth() <= originalDepth) break;
        }
      }

      token = context.nextToken();
    }

    return describeTableResult;
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof DescribeTableResult == false) return false;
    DescribeTableResult other = (DescribeTableResult) obj;

    if (other.getTable() == null ^ this.getTable() == null) return false;
    if (other.getTable() != null && other.getTable().equals(this.getTable()) == false) return false;
    return true;
  }
示例#3
0
  /*
   * Retrieves the table description and returns the table status as a string.
   */
  public static String getTestTableStatus() {

    try {
      /*AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
      .ddb();*/
      AmazonDynamoDBClient ddb = LoginActivity.clientManager.ddb();
      DescribeTableRequest request =
          new DescribeTableRequest().withTableName(PropertyLoader.getInstance().getTestTableName());
      DescribeTableResult result = ddb.describeTable(request);

      String status = result.getTable().getTableStatus();
      return status == null ? "" : status;

    } catch (ResourceNotFoundException e) {
    } catch (AmazonServiceException ex) {
      LoginActivity.clientManager.wipeCredentialsOnAuthError(ex);
    }

    return "";
  }
示例#4
0
  private int describe(Options opts)
      throws IOException, XMLStreamException, SaxonApiException, CoreException {

    String tableName = opts.getOptStringRequired("table");

    DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(tableName);

    traceCall("describeTable");
    DescribeTableResult result = null;
    try {
      result = getAWSClient().describeTable(describeTableRequest);
    } catch (AmazonClientException e) {
      return handleException(e);
    }
    startResult();
    writeTableDescription(result.getTable());
    endResult();

    return 0;
  }