com.ibm.workplace.wcm.api.query
Class Conjunction
java.lang.Object
com.ibm.workplace.wcm.api.query.CompoundSelector
com.ibm.workplace.wcm.api.query.Association
com.ibm.workplace.wcm.api.query.Conjunction
- All Implemented Interfaces:
- QueryElement, Selector, java.io.Serializable
-
public final class Conjunction
- extends Association
Conjunction associates Selectors together with the Operator.AND.
Here is an example of how to use create a query with 'AND' and 'OR' conditions by
using Conjunction and Disjunction.
The example will process all content whose name starts with 'news', or whose name starts with 'article'
and has a keyword 'news'.
QueryService queryService = workspace.getQueryService();
Query query = queryService.createQuery(Content.class);
Disjunction or = new Disjunction();
or.add(Selectors.nameLike("news%"));
Conjunction and = new Conjunction();
and.add(Selectors.nameLike("article%"));
and.add(ProfileSelectors.keywordsContain("news"));
or.add(and);
query.addSelector(or);
try
{ ResultIterator resultIterator = queryService.execute(query);
while (resultIterator.hasNext())
{ Content childContent = (Content) resultIterator.next();
if (childContent.hasComponent("myElement"))
{ contentWithMyElement = childContent;
break;
}
}
}
catch (QueryServiceException e)
{ // Handle exception
}
- Since:
- 7.0
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Conjunction
public Conjunction()
- Constructor
Conjunction
public Conjunction(java.util.Collection<Selector> selectors)
- Constructor
- Parameters:
- selectors - associated selectors