Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] classes deleted from provisional API

Some comments in-line.

On 01/23/2010 12:34 AM, Ian Bull wrote:
Actually, regarding Capability queries, I think (don't quote me ;)), you can
just take the existing required capability that you have and call
getMatches(). This will return a query that when executed will find all IUs
that provide a capability that matches your requirement.

The canonical form of an IRequrement is an expression that is matched against an IInstallableUnit. Consequently, the IRequrement.getMatches() returns an expression. An expression can be transformed into a query using an ExpressionQuery. Thus the former:

 new CapabilityQuery(cap);

can be written as:

 new ExpressionQuery(IInstallableUnit.class, cap.getMatches());

or, using Java 5 generics:

new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, cap.getMatches());


2. IUPropertyQuery. We're not sure what's going to happen to this yet,
that's why it's still internal.  But you should be able to use the p2ql for
this.

  QLMatchQuery qlMatchQuery = new QLMatchQuery(IInstallableUnit.class,
"properties['foo'] == 'true'");
This will match all IUs with a property key == foo, with a value == true.
  Or, more generally:
QLMatchQuery qlMatchQuery = new QLMatchQuery(IInstallableUnit.class,
"properties[$0] == $1", new String[] {"foo", "true"});

Notice the use of parameters here.

The p2QL is an extension to the more generic IExpression used by the metadata package. It adds collection processing like arrays, select/collect/latest/first/flatten/traverse, and translation support to the expression language. Unless you need that you can use the expressions directly and avoid the extra bundle:

Java 5 syntax:

 new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class,
    ExpressionUtil.parse("properties[$0] == $1"), "foo", "true");

without generics and varargs:

 new ExpressionQuery(IInstallableUnit.class,
ExpressionUtil.parse("properties[$0] == $1"), new Object[] {"foo", "true"});


3. CapabilityQuery. This one I'm not so sure about. Pascal was doing some
work using Expressions&  queries to compute capabilities.  Pascal, can you
help out here?

The details behind the current API are explained here:

 https://bugs.eclipse.org/bugs/show_bug.cgi?id=298604#c13

Regards,
Thomas Hallgren



Back to the top