public CertificateDescription unmarshall(JsonUnmarshallerContext context) throws Exception { CertificateDescription certificateDescription = new CertificateDescription(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("certificateArn")) { certificateDescription.setCertificateArn( StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("certificateId")) { certificateDescription.setCertificateId( StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("status")) { certificateDescription.setStatus(StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("certificatePem")) { certificateDescription.setCertificatePem( StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("ownedBy")) { certificateDescription.setOwnedBy(StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("creationDate")) { certificateDescription.setCreationDate( DateJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("lastModifiedDate")) { certificateDescription.setLastModifiedDate( DateJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return certificateDescription; }
public DeviceType unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } DeviceType deviceType = new DeviceType(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("DeviceKey")) { deviceType.setDeviceKey(StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("DeviceAttributes")) { deviceType.setDeviceAttributes( new ListUnmarshaller<AttributeType>(AttributeTypeJsonUnmarshaller.getInstance()) .unmarshall(context)); } else if (name.equals("DeviceCreateDate")) { deviceType.setDeviceCreateDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("DeviceLastModifiedDate")) { deviceType.setDeviceLastModifiedDate( DateJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("DeviceLastAuthenticatedDate")) { deviceType.setDeviceLastAuthenticatedDate( DateJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return deviceType; }
public KeySchemaElement unmarshall(JsonUnmarshallerContext context) throws Exception { KeySchemaElement keySchemaElement = new KeySchemaElement(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("AttributeName")) { keySchemaElement.setAttributeName(StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("KeyType")) { keySchemaElement.setKeyType(StringJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return keySchemaElement; }
public Label unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } Label label = new Label(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("Name")) { label.setName(StringJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("Confidence")) { label.setConfidence(FloatJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return label; }
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; }
@Test public void testStringJsonUnmarshaller() throws Exception { StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("s"); jw.value("String"); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller sUnmarshaller = SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance(); assertEquals(sUnmarshaller.unmarshall(context), "String"); }
public ListCertificatesByCAResult unmarshall(JsonUnmarshallerContext context) throws Exception { ListCertificatesByCAResult listCertificatesByCAResult = new ListCertificatesByCAResult(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("certificates")) { listCertificatesByCAResult.setCertificates( new ListUnmarshaller<Certificate>(CertificateJsonUnmarshaller.getInstance()) .unmarshall(context)); } else if (name.equals("nextMarker")) { listCertificatesByCAResult.setNextMarker( StringJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return listCertificatesByCAResult; }
public StreamSpecification unmarshall(JsonUnmarshallerContext context) throws Exception { StreamSpecification streamSpecification = new StreamSpecification(); AwsJsonReader reader = context.getReader(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("StreamEnabled")) { streamSpecification.setStreamEnabled( BooleanJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("StreamViewType")) { streamSpecification.setStreamViewType( StringJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return streamSpecification; }
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; }
@Test public void testBigIntegerJsonUnmarshaller() throws Exception { BigInteger bi = new BigInteger("13459712934871293847891231293874"); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("bi"); jw.value(bi.toString()); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.BigIntegerJsonUnmarshaller biUnmarshaller = SimpleTypeJsonUnmarshallers.BigIntegerJsonUnmarshaller.getInstance(); BigInteger unmarshalledBI = biUnmarshaller.unmarshall(context); assertEquals(unmarshalledBI.toString(), bi.toString()); }
@Test public void testBooleanJsonUnmarshaller() throws Exception { StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("boolean"); jw.value("true"); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.BooleanJsonUnmarshaller bUnmarshaller = SimpleTypeJsonUnmarshallers.BooleanJsonUnmarshaller.getInstance(); Boolean unmarshalledB = bUnmarshaller.unmarshall(context); assertTrue(unmarshalledB); }
public Pose unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } Pose pose = new Pose(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("Roll")) { pose.setRoll(FloatJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("Yaw")) { pose.setYaw(FloatJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("Pitch")) { pose.setPitch(FloatJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return pose; }
@Test public void testBigDecimalJsonUnmarshaller() throws Exception { BigDecimal bd = new BigDecimal("1.5"); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("bd"); jw.value(bd.toPlainString()); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.BigDecimalJsonUnmarshaller bdUnmarshaller = SimpleTypeJsonUnmarshallers.BigDecimalJsonUnmarshaller.getInstance(); BigDecimal unmarshalledBD = bdUnmarshaller.unmarshall(context); assertEquals(unmarshalledBD.toPlainString(), bd.toPlainString()); }
@Test public void testIntegerJsonUnmarshaller() throws Exception { Integer i = new Integer(5); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("i"); jw.value(i); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.IntegerJsonUnmarshaller iUnmarshaller = SimpleTypeJsonUnmarshallers.IntegerJsonUnmarshaller.getInstance(); Integer unmarshalledI = iUnmarshaller.unmarshall(context); assertEquals(unmarshalledI.intValue(), 5); }
@Test public void testLongJsonUnmarshaller() throws Exception { Long l = new Long(5L); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("l"); jw.value(l); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.LongJsonUnmarshaller lUnmarshaller = SimpleTypeJsonUnmarshallers.LongJsonUnmarshaller.getInstance(); Long unmarshalledL = lUnmarshaller.unmarshall(context); assertEquals(unmarshalledL.longValue(), 5L); }
@Test public void testFloatJsonUnmarshaller() throws Exception { Float f = new Float(5.5); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("f"); jw.value(f); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.FloatJsonUnmarshaller fUnmarshaller = SimpleTypeJsonUnmarshallers.FloatJsonUnmarshaller.getInstance(); Float unmarshalledF = fUnmarshaller.unmarshall(context); assertEquals(unmarshalledF.floatValue(), 5.5, .001); }
@Test public void testDoubleJsonUnmarshaller() throws Exception { Double dub = new Double(5.5); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("dub"); jw.value(dub); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.DoubleJsonUnmarshaller dubUnmarshaller = SimpleTypeJsonUnmarshallers.DoubleJsonUnmarshaller.getInstance(); Double unmarshalledDub = dubUnmarshaller.unmarshall(context); assertEquals(unmarshalledDub.doubleValue(), 5.5, .001); }
public ProvisionedThroughput unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("ReadCapacityUnits")) { provisionedThroughput.setReadCapacityUnits( LongJsonUnmarshaller.getInstance().unmarshall(context)); } else if (name.equals("WriteCapacityUnits")) { provisionedThroughput.setWriteCapacityUnits( LongJsonUnmarshaller.getInstance().unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return provisionedThroughput; }
@Test public void testByteJsonUnmarshaller() throws Exception { StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("b"); jw.value(Byte.valueOf("127")); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.ByteJsonUnmarshaller bUnmarshaller = SimpleTypeJsonUnmarshallers.ByteJsonUnmarshaller.getInstance(); Byte unmarshalledB = bUnmarshaller.unmarshall(context); Byte expected = Byte.valueOf("127"); assertTrue(unmarshalledB.equals(expected)); }
@Test public void testByteBufferJsonUnmarshaller() throws Exception { StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("bb"); jw.value(Base64.encodeAsString("byte".getBytes())); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.ByteBufferJsonUnmarshaller bbUnmarshaller = SimpleTypeJsonUnmarshallers.ByteBufferJsonUnmarshaller.getInstance(); ByteBuffer unmarshalledBb = bbUnmarshaller.unmarshall(context); ByteBuffer expected = ByteBuffer.wrap("byte".getBytes()); assertTrue(unmarshalledBb.equals(expected)); }
@Test public void testDateJsonUnmarshaller() throws Exception { Date date = new Date(); date.setTime(1000); StringWriter sw = new StringWriter(); AwsJsonWriter jw = JsonUtils.getJsonWriter(sw); jw.beginObject(); jw.name("date"); jw.value(date); jw.endObject(); String json = sw.toString(); StringReader sr = new StringReader(json); AwsJsonReader jr = JsonUtils.getJsonReader(sr); JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr); context.getReader().beginObject(); context.getReader().nextName(); SimpleTypeJsonUnmarshallers.DateJsonUnmarshaller dateUnmarshaller = SimpleTypeJsonUnmarshallers.DateJsonUnmarshaller.getInstance(); Date unmarshalledDate = dateUnmarshaller.unmarshall(context); assertEquals(unmarshalledDate.getTime(), date.getTime()); }