コード例 #1
0
  public Key unmarshall(JsonUnmarshallerContext context) throws Exception {
    Key key = new Key();

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

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

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

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("HashKeyElement", targetDepth)) {
          context.nextToken();
          key.setHashKeyElement(AttributeValueJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("RangeKeyElement", targetDepth)) {
          context.nextToken();
          key.setRangeKeyElement(AttributeValueJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }
      token = context.nextToken();
    }

    return key;
  }
コード例 #2
0
  public QueryResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    QueryResult queryResult = new QueryResult();

    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("Items", targetDepth)) {
          context.nextToken();
          queryResult.setItems(
              new ListUnmarshaller<java.util.Map<String, AttributeValue>>(
                      new MapUnmarshaller<String, AttributeValue>(
                          StringJsonUnmarshaller.getInstance(),
                          AttributeValueJsonUnmarshaller.getInstance()))
                  .unmarshall(context));
        }
        if (context.testExpression("Count", targetDepth)) {
          context.nextToken();
          queryResult.setCount(IntegerJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("ScannedCount", targetDepth)) {
          context.nextToken();
          queryResult.setScannedCount(IntegerJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("LastEvaluatedKey", targetDepth)) {
          context.nextToken();
          queryResult.setLastEvaluatedKey(
              new MapUnmarshaller<String, AttributeValue>(
                      StringJsonUnmarshaller.getInstance(),
                      AttributeValueJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("ConsumedCapacity", targetDepth)) {
          context.nextToken();
          queryResult.setConsumedCapacity(
              ConsumedCapacityJsonUnmarshaller.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 queryResult;
  }
コード例 #3
0
  public PutItemResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    PutItemResult putItemResult = new PutItemResult();

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

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

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

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("Attributes", targetDepth)) {
          putItemResult.setAttributes(
              new MapUnmarshaller<String, AttributeValue>(
                      StringJsonUnmarshaller.getInstance(),
                      AttributeValueJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("ConsumedCapacityUnits", targetDepth)) {
          context.nextToken();
          putItemResult.setConsumedCapacityUnits(
              DoubleJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }
      token = context.nextToken();
    }

    return putItemResult;
  }
コード例 #4
0
  public BatchResponse unmarshall(JsonUnmarshallerContext context) throws Exception {
    BatchResponse batchResponse = new BatchResponse();

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

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

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

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("Items", targetDepth)) {
          batchResponse.setItems(
              new ListUnmarshaller<java.util.Map<String, AttributeValue>>(
                      new MapUnmarshaller<String, AttributeValue>(
                          StringJsonUnmarshaller.getInstance(),
                          AttributeValueJsonUnmarshaller.getInstance()))
                  .unmarshall(context));
        }
        if (context.testExpression("ConsumedCapacityUnits", targetDepth)) {
          context.nextToken();
          batchResponse.setConsumedCapacityUnits(
              DoubleJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }

      token = context.nextToken();
    }

    return batchResponse;
  }
コード例 #5
0
  public DeleteRequest unmarshall(JsonUnmarshallerContext context) throws Exception {
    DeleteRequest deleteRequest = new DeleteRequest();

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

    JsonToken token = context.getCurrentToken();
    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("Key", targetDepth)) {
          context.nextToken();
          deleteRequest.setKey(
              new MapUnmarshaller<String, AttributeValue>(
                      StringJsonUnmarshaller.getInstance(),
                      AttributeValueJsonUnmarshaller.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 deleteRequest;
  }
コード例 #6
0
 public PutRequest unmarshall(JsonUnmarshallerContext context) throws Exception {
   AwsJsonReader reader = context.getReader();
   if (!reader.isContainer()) {
     reader.skipValue();
     return null;
   }
   PutRequest putRequest = new PutRequest();
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("Item")) {
       putRequest.setItem(
           new MapUnmarshaller<AttributeValue>(AttributeValueJsonUnmarshaller.getInstance())
               .unmarshall(context));
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return putRequest;
 }
コード例 #7
0
  public GetItemResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    GetItemResult getItemResult = new GetItemResult();

    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("Item", targetDepth)) {
          context.nextToken();
          getItemResult.setItem(
              new MapUnmarshaller<String, AttributeValue>(
                      StringJsonUnmarshaller.getInstance(),
                      AttributeValueJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("ConsumedCapacity", targetDepth)) {
          context.nextToken();
          getItemResult.setConsumedCapacity(
              ConsumedCapacityJsonUnmarshaller.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 getItemResult;
  }
  public ItemCollectionMetrics unmarshall(JsonUnmarshallerContext context) throws Exception {
    ItemCollectionMetrics itemCollectionMetrics = new ItemCollectionMetrics();

    AwsJsonReader reader = context.getReader();
    reader.beginObject();
    while (reader.hasNext()) {
      String name = reader.nextName();

      if (name.equals("ItemCollectionKey")) {
        itemCollectionMetrics.setItemCollectionKey(
            new MapUnmarshaller<AttributeValue>(AttributeValueJsonUnmarshaller.getInstance())
                .unmarshall(context));
      } else if (name.equals("SizeEstimateRangeGB")) {
        itemCollectionMetrics.setSizeEstimateRangeGB(
            new ListUnmarshaller<Double>(DoubleJsonUnmarshaller.getInstance()).unmarshall(context));
      } else {
        reader.skipValue();
      }
    }
    reader.endObject();

    return itemCollectionMetrics;
  }