use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method addEventsAndFilterCriteria.
private void addEventsAndFilterCriteria(XmlWriter xml, NotificationConfiguration config) {
for (final String event : config.getEvents()) {
xml.start("Event").value(event).end();
}
final Filter filter = config.getFilter();
if (filter != null) {
validateFilter(filter);
xml.start("Filter");
if (filter.getS3KeyFilter() != null) {
validateS3KeyFilter(filter.getS3KeyFilter());
xml.start("S3Key");
for (final FilterRule filterRule : filter.getS3KeyFilter().getFilterRules()) {
xml.start("FilterRule");
xml.start("Name").value(filterRule.getName()).end();
xml.start("Value").value(filterRule.getValue()).end();
xml.end();
}
xml.end();
}
xml.end();
}
}
use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.
the class FilterRuleStaxUnmarshaller method unmarshall.
@Override
public FilterRule unmarshall(StaxUnmarshallerContext context) throws Exception {
final int originalDepth = context.getCurrentDepth();
int targetDepth = originalDepth + 1;
if (context.isStartOfDocument()) {
targetDepth += 2;
}
final FilterRule filter = new FilterRule();
while (true) {
final int xmlEvent = context.nextEvent();
if (xmlEvent == XmlPullParser.END_DOCUMENT) {
break;
} else if (xmlEvent == XmlPullParser.START_TAG) {
if (context.testExpression("Name", targetDepth)) {
filter.setName(StringStaxUnmarshaller.getInstance().unmarshall(context));
} else if (context.testExpression("Value", targetDepth)) {
filter.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context));
}
} else if (xmlEvent == XmlPullParser.END_TAG) {
if (context.getCurrentDepth() < originalDepth) {
return filter;
}
}
}
return filter;
}
use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.
the class S3KeyFilterStaxUnmarshaller method unmarshall.
@Override
public S3KeyFilter unmarshall(StaxUnmarshallerContext context) throws Exception {
final int originalDepth = context.getCurrentDepth();
int targetDepth = originalDepth + 1;
if (context.isStartOfDocument()) {
targetDepth += 1;
}
final S3KeyFilter filter = new S3KeyFilter();
while (true) {
final int xmlEvent = context.nextEvent();
if (xmlEvent == XmlPullParser.END_DOCUMENT) {
break;
} else if (xmlEvent == XmlPullParser.START_TAG) {
if (context.testExpression("FilterRule", targetDepth)) {
filter.addFilterRule(FilterRuleStaxUnmarshaller.getInstance().unmarshall(context));
}
} else if (xmlEvent == XmlPullParser.END_TAG) {
if (context.getCurrentDepth() < originalDepth) {
return filter;
}
}
}
return filter;
}
use of com.amazonaws.services.s3.model.FilterRule in project aws-sdk-android by aws-amplify.
the class BucketNotificationConfigurationStaxUnmarshallerTest method assertFilterRulesUnmarshalledCorrectly.
private void assertFilterRulesUnmarshalledCorrectly(List<FilterRule> rules) {
final FilterRule ruleOne = rules.get(0);
assertThat(ruleOne.getName(), Matchers.equalTo("Prefix"));
assertThat(ruleOne.getValue(), Matchers.equalTo("some-prefix"));
final FilterRule ruleTwo = rules.get(1);
assertThat(ruleTwo.getName(), Matchers.equalTo("Suffix"));
assertThat(ruleTwo.getValue(), Matchers.equalTo("some-suffix"));
}
Aggregations