use of aQute.libg.filters.NotFilter in project bndtools by bndtools.
the class BndBuilderCapReqLoader method createVersionFilter.
private static final String createVersionFilter(String ns, String value, String rangeStr, String versionAttr) {
SimpleFilter pkgNameFilter = new SimpleFilter(ns, value);
Filter filter = pkgNameFilter;
if (rangeStr != null) {
VersionRange range = new VersionRange(rangeStr);
Filter left;
if (range.includeLow())
left = new SimpleFilter(versionAttr, Operator.GreaterThanOrEqual, range.getLow().toString());
else
left = new NotFilter(new SimpleFilter(versionAttr, Operator.LessThanOrEqual, range.getLow().toString()));
Filter right;
if (!range.isRange())
right = null;
else if (range.includeHigh())
right = new SimpleFilter(versionAttr, Operator.LessThanOrEqual, range.getHigh().toString());
else
right = new NotFilter(new SimpleFilter(versionAttr, Operator.GreaterThanOrEqual, range.getHigh().toString()));
AndFilter combined = new AndFilter().addChild(pkgNameFilter).addChild(left);
if (right != null)
combined.addChild(right);
filter = combined;
}
return filter.toString();
}
use of aQute.libg.filters.NotFilter in project bnd by bndtools.
the class Filters method fromVersionRange.
/**
* Generate an LDAP-style version filter from a version range, using a
* specific attribute name for the version; for example can be used to
* generate a range using the {@code bundle-version} attribute such as
* {@code (&(bundle-version>=1.0)(!(bundle-version>=2.0))}.
*
* @param range
* @param versionAttr
* @return The generated filter
* @throws IllegalArgumentException If the supplied range is invalid.
*/
public static String fromVersionRange(String range, String versionAttr) throws IllegalArgumentException {
if (range == null)
return null;
VersionRange parsedRange = new VersionRange(range);
Filter left;
if (parsedRange.includeLow())
left = new SimpleFilter(versionAttr, Operator.GreaterThanOrEqual, parsedRange.getLow().toString());
else
left = new NotFilter(new SimpleFilter(versionAttr, Operator.LessThanOrEqual, parsedRange.getLow().toString()));
Filter right;
if (!parsedRange.isRange())
right = null;
else if (parsedRange.includeHigh())
right = new SimpleFilter(versionAttr, Operator.LessThanOrEqual, parsedRange.getHigh().toString());
else
right = new NotFilter(new SimpleFilter(versionAttr, Operator.GreaterThanOrEqual, parsedRange.getHigh().toString()));
Filter result;
if (right != null)
result = new AndFilter().addChild(left).addChild(right);
else
result = left;
return result.toString();
}
Aggregations