Package org.eclipse.equinox.p2.query
Class QueryUtil
java.lang.Object
org.eclipse.equinox.p2.query.QueryUtil
Helper class for query related tasks.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IQuery<IInstallableUnit> static final Stringstatic final IQuery<IInstallableUnit> static final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> IQueryable<T> compoundQueryable(Collection<? extends IQueryable<T>> queryables) Creates a queryable that combines the given collection of input queryablesstatic <T> IQueryable<T> compoundQueryable(IQueryable<T> query1, IQueryable<T> query2) Creates a queryable that combines the two provided input queryablesstatic <T> IQuery<T> createCompoundQuery(Collection<? extends IQuery<? extends T>> queries, boolean and) Creates a compound query that combines the given queries.static <T> IQuery<T> createCompoundQuery(IQuery<? extends T> query1, IQuery<T> query2, boolean and) Creates a compound query that combines the two queries.static IQuery<IInstallableUnit> Returns a query that matches allInstallableUnitelementsstatic IQuery<IInstallableUnit> createIUCategoryMemberQuery(IInstallableUnit category) Creates a new query that will return the members of the givencategory.static IQuery<IInstallableUnit> Creates a query matching everyIInstallableUnitthat is a category.static IQuery<IInstallableUnit> Creates a query matching everyIInstallableUnitthat is a group.static IQuery<IInstallableUnit> Creates anIInstallableUnitthat will match all patches.static IQuery<IInstallableUnit> Creates anIInstallableUnitthat will match all products.static IQuery<IInstallableUnit> createIUPropertyQuery(String propertyName, String propertyValue) Creates a query that searches forIInstallableUnitinstances that have a property whose value matches the provided value.static IQuery<IInstallableUnit> createIUQuery(String id) Creates a query that will match anyIInstallableUnitwith the given id, regardless of version.static IQuery<IInstallableUnit> createIUQuery(String id, Version version) Creates a query that will match anyIInstallableUnitwith the given id and version.static IQuery<IInstallableUnit> createIUQuery(String id, VersionRange range) Creates a query that will match anyIInstallableUnitwith the given id, and whose version falls in the provided range.static IQuery<IInstallableUnit> createIUQuery(IVersionedId versionedId) Creates a query that will match anyIInstallableUnitwith the given id and version.static IQuery<IInstallableUnit> Creates a query that returns the latest version for each unique id of anIVersionedId.static <T extends IVersionedId>
IQuery<T> createLatestQuery(IQuery<T> query) Creates a query that returns the latest version for each unique id of anIVersionedIdfrom the collection produced byquery.static <T> IQuery<T> createLimitQuery(IQuery<T> query, int limit) Creates a limit query that can be used to limit the number of query results returned.static <T> IQuery<T> createMatchQuery(Class<? extends T> matchingClass, String matchExpression, Object... parameters) Parses thematchExpressionand creates an query that will iterate over all candidates and discriminate all candidates that are not instances ofmatchingClassor for which the booleanmatchExpressionreturns false.static <T> IQuery<T> createMatchQuery(Class<? extends T> matchingClass, IExpression matchExpression, Object... parameters) Creates an query that will iterate over all candidates and discriminate all candidates that are not instances ofmatchingClassor for which the booleanmatchExpressionreturns false.static IQuery<IInstallableUnit> createMatchQuery(String matchExpression, Object... parameters) Parses thematchExpressionand creates anIInstallableUnitquery that will iterate over all candidates and discriminate by applying the booleanmatchExpressionon each candidate.static IQuery<IInstallableUnit> createMatchQuery(IExpression matchExpression, Object... parameters) Creates anIInstallableUnitquery that will iterate over all candidates and discriminate by applying the booleanmatchExpressionon each candidate.static <T> IQuery<T> createPipeQuery(Collection<? extends IQuery<? extends T>> queries) Creates a piped query based on the provided input queries.static <T> IQuery<T> createPipeQuery(IQuery<? extends T> query1, IQuery<? extends T> query2) Creates a piped query based on the provided input queries.static <T> IQuery<T> createQuery(Class<? extends T> matchingClass, String expression, Object... parameters) Parses theexpressionand creates a query that will limit the result to instances of thematchingClass.static <T> IQuery<T> createQuery(Class<? extends T> matchingClass, IExpression expression, Object... parameters) Creates a query that will limit the result to instances of thematchingClass.static IQuery<IInstallableUnit> createQuery(String expression, Object... parameters) Parses theexpressionand creates anIInstallableUnitquery.static IQuery<IInstallableUnit> createQuery(IExpression expression, Object... parameters) Creates anIInstallableUnitquery based on anexpressionthat uses all candidates as input.static booleanTest if theIInstallableUnitis a category.static booleanTest if theIInstallableUnitis a fragment.static booleanTest if theIInstallableUnitis a group.static booleanTest if theIInstallableUnitis a patch.static booleanTest if theIInstallableUnitis a product.
-
Field Details
-
ALL_UNITS
-
ANY
- See Also:
-
NO_UNITS
-
PROP_TYPE_CATEGORY
- See Also:
-
PROP_TYPE_GROUP
- See Also:
-
PROP_TYPE_PATCH
- See Also:
-
-
Constructor Details
-
QueryUtil
public QueryUtil()
-
-
Method Details
-
compoundQueryable
Creates a queryable that combines the given collection of input queryables- Parameters:
queryables- The collection of queryables to be combined
-
compoundQueryable
Creates a queryable that combines the two provided input queryables- Parameters:
query1- The first queryablequery2- The second queryable
-
createCompoundQuery
public static <T> IQuery<T> createCompoundQuery(Collection<? extends IQuery<? extends T>> queries, boolean and) Creates a compound query that combines the given queries. If all queries are candidate match queries, then the queries will be concatenated as a boolean 'and' or a boolean 'or' expression depending on theandflag. If at least one query is a full query, all queries will instead be evaluated using intersection whenandistrueor a union.- Parameters:
queries- The queries to performand-trueif this query represents an intersection or a logical 'and', andfalseif this query represents a union or a logical 'or'.- Returns:
- A compound query
-
createCompoundQuery
public static <T> IQuery<T> createCompoundQuery(IQuery<? extends T> query1, IQuery<T> query2, boolean and) Creates a compound query that combines the two queries. If both queries are candidate match queries, then the queries will be concatenated as a boolean 'and' or a boolean 'or' expression depending on theandflag. If at least one query is a full query, all queries will instead be evaluated using intersection whenandistrueor a union.- Parameters:
query1- the first queryquery2- the second queryand-trueif this query represents an intersection or a logical 'and', andfalseif this query represents a union or a logical 'or'.- Returns:
- A compound query
-
createIUAnyQuery
Returns a query that matches allInstallableUnitelements -
createIUCategoryMemberQuery
Creates a new query that will return the members of the givencategory. If the specifiedIInstallableUnitis not a category, then no installable unit will satisfy the query.- Parameters:
category- The category- Returns:
- A query that returns category members
-
createIUCategoryQuery
Creates a query matching everyIInstallableUnitthat is a category.- Returns:
- The query that matches categories
- Since:
- 2.0
-
createIUGroupQuery
Creates a query matching everyIInstallableUnitthat is a group.- Returns:
- a query that matches all groups
-
createIUPatchQuery
Creates anIInstallableUnitthat will match all patches.- Returns:
- The created query
-
createIUProductQuery
Creates anIInstallableUnitthat will match all products.- Returns:
- The created query
- Since:
- 2.2
-
createIUPropertyQuery
public static IQuery<IInstallableUnit> createIUPropertyQuery(String propertyName, String propertyValue) Creates a query that searches forIInstallableUnitinstances that have a property whose value matches the provided value. If no property name is specified, then allIInstallableUnitinstances are accepted.- Parameters:
propertyName- The key of the property to match ornullto match allpropertyValue- The value of the property. Can beANYto match all values exceptnull- Returns:
- The query matching properties
-
createIUQuery
Creates a query that will match anyIInstallableUnitwith the given id and version.- Parameters:
versionedId- The precise id/version combination that a matching unit must have- Returns:
- a query that matches IU's by id and version
-
createIUQuery
Creates a query that will match anyIInstallableUnitwith the given id, regardless of version.- Parameters:
id- The installable unit id to match, ornullto match any id- Returns:
- a query that matches IU's by id
-
createIUQuery
Creates a query that will match anyIInstallableUnitwith the given id and version.- Parameters:
id- The installable unit id to match, ornullto match any idversion- The precise version that a matching unit must have ornullto match any version- Returns:
- a query that matches IU's by id and version
-
createIUQuery
Creates a query that will match anyIInstallableUnitwith the given id, and whose version falls in the provided range.- Parameters:
id- The installable unit id to match, ornullto match any idrange- The version range to match ornullto match any range.- Returns:
- a query that matches IU's by id and range
-
createLatestIUQuery
Creates a query that returns the latest version for each unique id of anIVersionedId. All other elements are discarded.- Returns:
- A query matching the latest version for each id.
-
createLatestQuery
Creates a query that returns the latest version for each unique id of anIVersionedIdfrom the collection produced byquery. All other elements are discarded.- Parameters:
query- The query that precedes the latest query when evaluating.- Returns:
- A query matching the latest version for each id.
-
createLimitQuery
Creates a limit query that can be used to limit the number of query results returned. Once the limit is reached, the query is terminated.- Parameters:
query- The query that should be limitedlimit- A positive integer denoting the limit- Returns:
- A limited query
- Since:
- 2.0
-
createMatchQuery
public static IQuery<IInstallableUnit> createMatchQuery(IExpression matchExpression, Object... parameters) Creates anIInstallableUnitquery that will iterate over all candidates and discriminate by applying the booleanmatchExpressionon each candidate.- Parameters:
matchExpression- The boolean expression used for filtering one candidateparameters- Values for parameter substitution- Returns:
- The created query
-
createMatchQuery
public static IQuery<IInstallableUnit> createMatchQuery(String matchExpression, Object... parameters) Parses thematchExpressionand creates anIInstallableUnitquery that will iterate over all candidates and discriminate by applying the booleanmatchExpressionon each candidate.- Parameters:
matchExpression- The boolean expression used for filtering one candidateparameters- Values for parameter substitution- Returns:
- The created query
-
createMatchQuery
public static <T> IQuery<T> createMatchQuery(Class<? extends T> matchingClass, IExpression matchExpression, Object... parameters) Creates an query that will iterate over all candidates and discriminate all candidates that are not instances ofmatchingClassor for which the booleanmatchExpressionreturns false.- Parameters:
matchingClass- The class that matching candidates must be an instance ofmatchExpression- The boolean expression used for filtering one candidateparameters- Values for parameter substitution- Returns:
- The created query
-
createMatchQuery
public static <T> IQuery<T> createMatchQuery(Class<? extends T> matchingClass, String matchExpression, Object... parameters) Parses thematchExpressionand creates an query that will iterate over all candidates and discriminate all candidates that are not instances ofmatchingClassor for which the booleanmatchExpressionreturns false.- Type Parameters:
T- The type of input object that the created query accepts- Parameters:
matchingClass- The class that matching candidates must be an instance ofmatchExpression- The boolean expression used for filtering one candidateparameters- Values for parameter substitution- Returns:
- The created query
-
createPipeQuery
Creates a piped query based on the provided input queries.
A pipe is a composite query in which each sub-query is executed in succession. The results from the ith sub-query are piped as input into the i+1th sub-query. The query will short-circuit if any query returns an empty result set.
- Parameters:
queries- the ordered list of queries to perform- Returns:
- A query pipe
-
createPipeQuery
Creates a piped query based on the provided input queries.
A pipe is a composite query in which each sub-query is executed in succession. The results from the ith sub-query are piped as input into the i+1th sub-query. The query will short-circuit if any query returns an empty result set.
- Parameters:
query1- the first queryquery2- the second query- Returns:
- A query pipe
-
createQuery
Creates anIInstallableUnitquery based on anexpressionthat uses all candidates as input.- Parameters:
expression- The query expressionparameters- Values for parameter substitution- Returns:
- The created query
-
createQuery
Parses theexpressionand creates anIInstallableUnitquery. Theexpressionis expected to use all candidates as input.- Parameters:
expression- The query expressionparameters- Values for parameter substitution- Returns:
- The created query
-
createQuery
public static <T> IQuery<T> createQuery(Class<? extends T> matchingClass, IExpression expression, Object... parameters) Creates a query that will limit the result to instances of thematchingClass. Theexpressionis expected to use all candidates as input.- Parameters:
matchingClass- The class used as discriminator for the resultexpression- The query expressionparameters- Values for parameter substitution- Returns:
- The created query
-
createQuery
public static <T> IQuery<T> createQuery(Class<? extends T> matchingClass, String expression, Object... parameters) Parses theexpressionand creates a query that will limit the result to instances of thematchingClass. Theexpressionis expected to use all candidates as input.- Parameters:
matchingClass- The class used as discriminator for the resultexpression- The query expressionparameters- Values for parameter substitution- Returns:
- The created query
-
isCategory
Test if theIInstallableUnitis a category.- Parameters:
iu- the element being tested.- Returns:
trueif the parameter is a category.
-
isFragment
Test if theIInstallableUnitis a fragment.- Parameters:
iu- the element being tested.- Returns:
trueif the parameter is a fragment.
-
isGroup
Test if theIInstallableUnitis a group.- Parameters:
iu- the element being tested.- Returns:
trueif the parameter is a group.
-
isProduct
Test if theIInstallableUnitis a product.- Parameters:
iu- the element being tested.- Returns:
trueif the parameter is a group.- Since:
- 2.2
-
isPatch
Test if theIInstallableUnitis a patch.- Parameters:
iu- the element being tested.- Returns:
trueif the parameter is a patch.
-