public DeleteEnvironmentConfigurationResult unmarshall(StaxUnmarshallerContext context) throws Exception { DeleteEnvironmentConfigurationResult deleteEnvironmentConfigurationResult = new DeleteEnvironmentConfigurationResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return deleteEnvironmentConfigurationResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return deleteEnvironmentConfigurationResult; } } } }
private static StaxUnmarshallerContext payloadUnmarshaller(Message message) throws XMLStreamException { InputStream payloadStream = new ByteArrayInputStream(message.getPayload()); XMLEventReader xmlEventReader = XmlUtils.getXmlInputFactory().createXMLEventReader(payloadStream); return new StaxUnmarshallerContext(xmlEventReader); } }
@Override protected void registerAdditionalMetadataExpressions(StaxUnmarshallerContext unmarshallerContext) { unmarshallerContext.registerMetadataExpression("ResponseMetadata/BoxUsage", 2, SimpleDBResponseMetadata.BOX_USAGE); }
public ReceiptRuleSetMetadata unmarshall(StaxUnmarshallerContext context) throws Exception { ReceiptRuleSetMetadata receiptRuleSetMetadata = new ReceiptRuleSetMetadata(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("Name", targetDepth)) { receiptRuleSetMetadata.setName(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; } if (context.testExpression("CreatedTimestamp", targetDepth)) { receiptRuleSetMetadata.setCreatedTimestamp(DateStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return receiptRuleSetMetadata; }
public T unmarshall(StaxUnmarshallerContext context) throws Exception { while (context.nextEvent().isEndDocument() == false); return null; } }
private StaxUnmarshallerContext getContext(String elementData) throws XmlPullParserException, IOException { XmlPullParser xpp = xmlPullParserFactory.newPullParser(); String xml = "<tag>" + elementData + "</tag>"; StringReader sr = new StringReader(xml); xpp.setInput(sr); StaxUnmarshallerContext suc = new StaxUnmarshallerContext(xpp); suc.nextEvent(); return suc; } }
StaxUnmarshallerContext unmarshallerContext = new StaxUnmarshallerContext(eventReader, response.getHeaders()); unmarshallerContext.registerMetadataExpression("ResponseMetadata/RequestId", 2, ResponseMetadata.AWS_REQUEST_ID); unmarshallerContext.registerMetadataExpression("requestId", 2, ResponseMetadata.AWS_REQUEST_ID); registerAdditionalMetadataExpressions(unmarshallerContext); awsResponse.setResult(result); Map<String, String> metadata = unmarshallerContext.getMetadata(); Map<String, String> responseHeaders = response.getHeaders(); if (responseHeaders != null) {
protected boolean handleXmlEvent(QueueConfiguration queueConfig, StaxUnmarshallerContext context, int targetDepth) throws Exception { if (context.testExpression("Queue", targetDepth)) { queueConfig.setQueueARN(StringStaxUnmarshaller.getInstance().unmarshall(context)); return true; } return false; }
@Test public void testMetadata() throws Exception { String key = "AWS_REQUEST_ID"; context = getContext(XML_STRING, null); context.registerMetadataExpression("ResponseMetadata/RequestId", 2, key); context.registerMetadataExpression("requestId", 2, key); while (context.nextEvent() != XmlPullParser.END_DOCUMENT) ; assertNotNull(context.getMetadata().get(key)); assertEquals("request id", "12345", context.getMetadata().get(key)); }
public TemplateMetadata unmarshall(StaxUnmarshallerContext context) throws Exception { TemplateMetadata templateMetadata = new TemplateMetadata(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("Name", targetDepth)) { templateMetadata.setName(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; } if (context.testExpression("CreatedTimestamp", targetDepth)) { templateMetadata.setCreatedTimestamp(DateStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return templateMetadata; }
private StaxUnmarshallerContext getContext(String elementData) throws XmlPullParserException, IOException { XmlPullParser xpp = xmlPullParserFactory.newPullParser(); String xml = "<tag>" + elementData + "</tag>"; StringReader sr = new StringReader(xml); xpp.setInput(sr); StaxUnmarshallerContext suc = new StaxUnmarshallerContext(xpp); suc.nextEvent(); return suc; }
StaxUnmarshallerContext unmarshallerContext = new StaxUnmarshallerContext(xpp, response.getHeaders()); unmarshallerContext.registerMetadataExpression("ResponseMetadata/RequestId", 2, ResponseMetadata.AWS_REQUEST_ID); unmarshallerContext.registerMetadataExpression("requestId", 2, ResponseMetadata.AWS_REQUEST_ID); registerAdditionalMetadataExpressions(unmarshallerContext); awsResponse.setResult(result); Map<String, String> metadata = unmarshallerContext.getMetadata(); Map<String, String> responseHeaders = response.getHeaders(); if (responseHeaders != null) {
protected boolean handleXmlEvent(TopicConfiguration topicConfig, StaxUnmarshallerContext context, int targetDepth) throws Exception { if (context.testExpression("Topic", targetDepth)) { topicConfig.setTopicARN(StringStaxUnmarshaller.getInstance().unmarshall(context)); return true; } return false; }
public RemoveListenerCertificatesResult unmarshall(StaxUnmarshallerContext context) throws Exception { RemoveListenerCertificatesResult removeListenerCertificatesResult = new RemoveListenerCertificatesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return removeListenerCertificatesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return removeListenerCertificatesResult; } } } }
public InstanceStatusDetails unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceStatusDetails instanceStatusDetails = new InstanceStatusDetails(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return instanceStatusDetails; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("name", targetDepth)) { instanceStatusDetails.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("status", targetDepth)) { instanceStatusDetails.setStatus(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("impairedSince", targetDepth)) { instanceStatusDetails.setImpairedSince(DateStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return instanceStatusDetails; } } } }
StaxUnmarshallerContext unmarshallerContext = new StaxUnmarshallerContext(eventReader, response.getHeaders()); unmarshallerContext.registerMetadataExpression("ResponseMetadata/RequestId", 2, ResponseMetadata.AWS_REQUEST_ID); unmarshallerContext.registerMetadataExpression("requestId", 2, ResponseMetadata.AWS_REQUEST_ID); registerAdditionalMetadataExpressions(unmarshallerContext); awsResponse.setResult(result); Map<String, String> metadata = unmarshallerContext.getMetadata(); Map<String, String> responseHeaders = response.getHeaders(); if (responseHeaders != null) {
private StaxUnmarshallerContext getContext(String xml, Map<String, String> headers) throws Exception { XmlPullParser xpp = factory.newPullParser(); Reader reader = new StringReader(xml); xpp.setInput(reader); return new StaxUnmarshallerContext(xpp, headers); }
@Override protected void registerAdditionalMetadataExpressions(StaxUnmarshallerContext unmarshallerContext) { unmarshallerContext.registerMetadataExpression("ResponseMetadata/BoxUsage", 2, SimpleDBResponseMetadata.BOX_USAGE); }
public DeleteTargetGroupResult unmarshall(StaxUnmarshallerContext context) throws Exception { DeleteTargetGroupResult deleteTargetGroupResult = new DeleteTargetGroupResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return deleteTargetGroupResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return deleteTargetGroupResult; } } } }
public GetPasswordDataResult unmarshall(StaxUnmarshallerContext context) throws Exception { GetPasswordDataResult getPasswordDataResult = new GetPasswordDataResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return getPasswordDataResult; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("instanceId", targetDepth)) { getPasswordDataResult.setInstanceId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("timestamp", targetDepth)) { getPasswordDataResult.setTimestamp(DateStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("passwordData", targetDepth)) { getPasswordDataResult.setPasswordData(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return getPasswordDataResult; } } } }