use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.
the class ResolveCommand method _query.
public void _query(QueryOptions options) throws Exception {
List<String> args = options._arguments();
String bsn = args.remove(0);
String version = null;
if (!args.isEmpty())
version = args.remove(0);
ProjectResolver pr = new ProjectResolver(bnd.getProject(options.project()));
addClose(pr);
IdentityCapability resource = pr.getResource(bsn, version);
bnd.out.printf("%-30s %-20s %s\n", resource.osgi_identity(), resource.version(), resource.description(""));
Resource r = resource.getResource();
FilterParser p = new FilterParser();
if (r != null) {
List<Requirement> requirements = resource.getResource().getRequirements(null);
if (!requirements.isEmpty()) {
bnd.out.println("Requirements:");
for (Requirement req : requirements) {
Expression parse = p.parse(req);
bnd.out.printf(" %-20s %s\n", req.getNamespace(), parse);
}
}
List<Capability> capabilities = resource.getResource().getCapabilities(null);
if (!capabilities.isEmpty()) {
bnd.out.println("Capabilities:");
for (Capability cap : capabilities) {
Map<String, Object> attrs = new HashMap<String, Object>(cap.getAttributes());
Object id = attrs.remove(cap.getNamespace());
Object vv = attrs.remove("version");
if (vv == null)
vv = attrs.remove("bundle-version");
bnd.out.printf(" %-20s %-40s %-20s attrs=%s dirs=%s\n", cap.getNamespace(), id, vv, attrs, cap.getDirectives());
}
}
}
}
use of aQute.bnd.osgi.resource.FilterParser.Expression in project bndtools by bndtools.
the class RequirementLabelProvider method requirementToUrl.
/**
* This method return a query string (on jpm) based on a filter. This is not exact, but should in general give a
* list to work from
*
* @param req
* The requirement searched
* @return a query string where p: is for package and bsn: is for bundle symbolic name.
*/
public static String requirementToUrl(Requirement req) throws IOException {
FilterParser fp = new FilterParser();
Expression expression = fp.parse(req);
String s = expression.query();
return "http://jpm4j.org/#!/search?q=" + URLEncoder.encode(s, "UTF-8");
}
use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.
the class PermissionGenerator method getReferencedServices.
public static Set<String> getReferencedServices(Builder builder) {
Set<String> referencedServices = new TreeSet<>();
for (Entry<String, Attrs> entry : builder.getRequireCapability().entrySet()) {
if (Processor.removeDuplicateMarker(entry.getKey()).equals("osgi.service")) {
Attrs attrs = entry.getValue();
String filter = attrs.get("filter:");
if (filter != null && !filter.isEmpty()) {
FilterParser filterParser = new FilterParser();
Expression expr = filterParser.parse(filter);
referencedServices.addAll(expr.visit(new FindReferencedServices()));
}
}
}
if (referencedServices.contains(MATCH_ALL)) {
return Collections.singleton(MATCH_ALL);
} else {
return referencedServices;
}
}
use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.
the class FilterParserTest method testBundleRange.
public void testBundleRange() throws Exception {
Expression expression = fp.parse("(&(osgi.wiring.bundle=B)(bundle-version>=1.0.0)(!(bundle-version>=2.0.0)))");
assertTrue(expression instanceof WithRangeExpression);
assertEquals("[1.0.0,2.0.0)", ((WithRangeExpression) expression).getRangeExpression().getRangeString());
}
use of aQute.bnd.osgi.resource.FilterParser.Expression in project bnd by bndtools.
the class FilterParserTest method testReduce.
public void testReduce() throws IOException {
Expression exp = fp.parse("(&(osgi.wiring.package=package)(!(version>=2.0.0))(version>=1.0.0))");
System.out.println(exp);
}
Aggregations