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; }
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; }
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; }
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; }