use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class RegexMetadataFilter method include.
/**
* Take a collection of metadata items and filter that collection based on the list of including
* regular expression patterns.
*
* @param metadataCollection the <code>MetadataCollection</code>
* @return A new modified collection.
*/
private MetadataCollection include(MetadataCollection metadataCollection) {
if (getIncludePatterns().size() == 0) {
return metadataCollection;
}
initialisePatterns();
MetadataCollection result = new MetadataCollection();
result.addAll(metadataCollection.stream().filter(e -> matches(e, patternIncludes)).collect(Collectors.toList()));
return result;
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class ExcludeJmsHeaders method removeJmsHdrs.
private MetadataCollection removeJmsHdrs(MetadataCollection metadataCollection) {
MetadataCollection toBeRemoved = new MetadataCollection();
for (MetadataElement element : metadataCollection) {
if (jmsPattern.matcher(element.getKey()).find()) {
toBeRemoved.add(element);
}
}
metadataCollection.removeAll(toBeRemoved);
return metadataCollection;
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class FixedValuesMetadataFilter method filter.
@Override
public MetadataCollection filter(MetadataCollection original) {
MetadataCollection result = new MetadataCollection();
getMetadata().forEach((e) -> {
result.add(new MetadataElement(e.getKey(), e.getValue()));
});
return result;
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class OrderedItemMetadataFilter method filter.
@Override
public MetadataCollection filter(MetadataCollection originalCollection) {
MetadataCollection results = new MetadataCollection();
Map<String, String> original;
if (ignoreCase()) {
original = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
original.putAll(MetadataCollection.asMap(originalCollection));
} else {
original = MetadataCollection.asMap(originalCollection);
}
for (String key : getMetadataKeys()) {
String value = original.get(key);
if (value != null) {
results.add(new MetadataElement(key, value));
} else {
results.add(new MetadataElement(key, ""));
}
}
return results;
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class DiscardValuesTooLongFilterTest method testFilterCollection.
@Test
public void testFilterCollection() throws Exception {
DiscardValuesTooLongFilter filter = new DiscardValuesTooLongFilter(36);
MetadataCollection c = filter.filter(new MetadataCollection(createMessage().getMetadata()));
assertEquals(4, c.size());
}
Aggregations