+

Search Tips   |   Advanced Search

 PREV CLASS   NEXT CLASS
Tree 
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

com.ibm.workplace.wcm.api.query
Class Conjunction

java.lang.Object
  extended by com.ibm.workplace.wcm.api.query.CompoundSelector
      extended by com.ibm.workplace.wcm.api.query.Association
          extended by 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

Field Summary
 
Fields inherited from interface com.ibm.workplace.wcm.api.query.Selector
NULL_SELECTOR
 
Constructor Summary
Conjunction()
          Constructor
Conjunction(java.util.Collection<Selector> selectors)
          Constructor
 
Method Summary
 
Methods inherited from class com.ibm.workplace.wcm.api.query.Association
add, add, add, createAssociation, getOperator, getSelectors, toString
 
Methods inherited from class com.ibm.workplace.wcm.api.query.CompoundSelector
getElements, hasElements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Conjunction

public Conjunction()
Constructor

Conjunction

public Conjunction(java.util.Collection<Selector> selectors)
Constructor

Parameters:
selectors - associated selectors
 PREV CLASS   NEXT CLASS
Tree 
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD