Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle WebCenter Portal
11g Release 1 (11.1.1.6.0)
E15995-04


oracle.webcenter.search.util
Class PredicateUtils

java.lang.Object
  extended by oracle.webcenter.search.util.PredicateUtils


public class PredicateUtils
extends java.lang.Object

This class provides some utility methods around Predicates that developers may find useful.

Since:
11.1.1.0.0 Beta 2

Constructor Summary
PredicateUtils()
           

 

Method Summary
static
<T> Predicate
addAttributePredicate(Predicate predicate, QName attrName, java.lang.String comparator, T attrValue)
          Joins new attribute predicates with an existing one, returning the joined result.
static
<T> Predicate
addAttributePredicate(Predicate predicate, QName attrName, java.lang.String comparator, T attrValue, ComplexPredicate.ConjunctionOp conjunctionOp)
          Joins new attribute predicates with an existing one, returning the joined result.
static void convertAllSinceNumDaysComparator(Predicate predicate, java.util.TimeZone timeZone)
          Convert all SinceNumDays comparators and their operands in the predicate tree
static void filterTextPredicate(Predicate predicate, java.lang.String filterString)
          Filter text predicate by the filterString which is a regular expression.
static
<T extends Predicate>
java.util.List<T>
findPredicates(java.lang.Class<T> type, Predicate predicate)
          Returns a list of Predicates that matches the class passed in.
static void flatten(ComplexPredicate predicate)
          Compacts the ComplexPredicate by flattening.
static java.util.List<ComplexPredicate> getAttributePredicateParents(Predicate predicate, QName attributeName)
          Returns a list of parents of the given attribute predicate
static
<T extends Predicate>
Predicate
getFirst(java.lang.Class<T> type, Predicate predicate)
          Extracts the first Predicate it finds in the descendents of a Predicate that matches the type passed in.
static java.lang.String getFirstKeywordsFromPredicate(Predicate predicate)
          Extracts the first keywords it finds in the Predicate by looking into TextPredicates.
static java.lang.String getQueryPredicateScope(Predicate predicate)
          Get scope from query predicate.
static boolean isQueryPredicateExecutable(Predicate predicate, java.lang.String serviceId, boolean singleScope)
          Determine if the query is executable by analyzing the Query Predicate predicate top predicate of the query serviceId service Id to see if there is match in the service Id attribute predicate singleScope boolean to specify if only single scope is supported

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

PredicateUtils

public PredicateUtils()

Method Detail

getFirstKeywordsFromPredicate

public static final java.lang.String getFirstKeywordsFromPredicate(Predicate predicate)
Extracts the first keywords it finds in the Predicate by looking into TextPredicates.
Parameters:
predicate - a Predicate that can be either Text of Complex.
Returns:
the first string in navigating down the Predicate.

getFirst

public static final <T extends Predicate> Predicate getFirst(java.lang.Class<T> type,
                                                             Predicate predicate)
Extracts the first Predicate it finds in the descendents of a Predicate that matches the type passed in.
Parameters:
type - The Class object we want to match from the descendents of the passed in predicate
predicate - the Predicate whose descendents (via ComplexPredicate) we wish to discover Predicates of the type passed in
Returns:
the first item in a List of Predicates that matches the type criterion

getAttributePredicateParents

public static final java.util.List<ComplexPredicate> getAttributePredicateParents(Predicate predicate,
                                                                                  QName attributeName)
Returns a list of parents of the given attribute predicate

findPredicates

public static final <T extends Predicate> java.util.List<T> findPredicates(java.lang.Class<T> type,
                                                                           Predicate predicate)
Returns a list of Predicates that matches the class passed in.
Parameters:
type - The Class object we want to match from the descendents of the passed in predicate
predicate - the Predicate whose descendents (via ComplexPredicate) we wish to discover Predicates of the type passed in
Returns:
a List of Predicates that matches the type criterion

flatten

public static final void flatten(ComplexPredicate predicate)
Compacts the ComplexPredicate by flattening. This means, collapsing any unnecessary hierarchies of ANDs and ORs if they are the same.
Parameters:
predicate - the ComplexPredicate to be flattened

convertAllSinceNumDaysComparator

public static void convertAllSinceNumDaysComparator(Predicate predicate,
                                                    java.util.TimeZone timeZone)
Convert all SinceNumDays comparators and their operands in the predicate tree
Parameters:
predicate - of the query

filterTextPredicate

public static void filterTextPredicate(Predicate predicate,
                                       java.lang.String filterString)
Filter text predicate by the filterString which is a regular expression. For example, in the SearchServiceRowQueryFederator, the filterString used is WILDCARD_PUNCTUATION_SYMBOLS which is [\\*].
Parameters:
predicate - of the query
filterString - the regular expression String to filter the text in the predicate by.

addAttributePredicate

public static <T> Predicate addAttributePredicate(Predicate predicate,
                                                  QName attrName,
                                                  java.lang.String comparator,
                                                  T attrValue)
Joins new attribute predicates with an existing one, returning the joined result. Example: Calling addAttributePredicate with an AttributePredicate(DCMI_MODIFIED, ComparatorConstants.EQUALS, someDate), DCMI_CREATOR, ComparatorConstants.CONTAINS, and "foo" will create and return a top level ComplexPredicate with ComplexPredicate.ConjunctionOp.And that contains two children, one the original AttributePredicate(DCMI_MODIFIED, ComparatorConstants.EQUALS, someDate), and the other AttributePredicate(DCMI_CREATOR, ComparatorConstants.CONTAINS, "foo")
Parameters:
predicate - The existing predicate to add this new attribute predicate to
attrName - the name of the attribute
comparator - the comparator of the predicate
attrValue - the value used in the predicate one
Returns:
a ComplexPredicate joining the new attribute predicate and an old or just the new attribute predicate if the old one is null

addAttributePredicate

public static <T> Predicate addAttributePredicate(Predicate predicate,
                                                  QName attrName,
                                                  java.lang.String comparator,
                                                  T attrValue,
                                                  ComplexPredicate.ConjunctionOp conjunctionOp)
Joins new attribute predicates with an existing one, returning the joined result. Example: Calling addAttributePredicate with an AttributePredicate(DCMI_MODIFIED, ComparatorConstants.EQUALS, someDate), DCMI_CREATOR, ComparatorConstants.CONTAINS, "foo", ComplexPredicate.ConjunctionOp.Or will create and return a top level ComplexPredicate with ComplexPredicate.ConjunctionOp.Or that contains two children, one the original AttributePredicate(DCMI_MODIFIED, ComparatorConstants.EQUALS, someDate), and the other AttributePredicate(DCMI_CREATOR, ComparatorConstants.CONTAINS, "foo")
Parameters:
predicate - The existing predicate to add this new attribute predicate to
attrName - the name of the attribute
comparator - the comparator of the predicate
attrValue - the value used in the predicate
conjunctionOp - how to join the new attribute predicate with the old one
Returns:
a ComplexPredicate joining the new attribute predicate and an old or just the new attribute predicate if the old one is null

isQueryPredicateExecutable

public static boolean isQueryPredicateExecutable(Predicate predicate,
                                                 java.lang.String serviceId,
                                                 boolean singleScope)
Determine if the query is executable by analyzing the Query Predicate predicate top predicate of the query serviceId service Id to see if there is match in the service Id attribute predicate singleScope boolean to specify if only single scope is supported

getQueryPredicateScope

public static java.lang.String getQueryPredicateScope(Predicate predicate)
Get scope from query predicate.

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle WebCenter Portal
11g Release 1 (11.1.1.6.0)
E15995-04


Copyright © 2009, 2011, Oracle and/or its affiliates. All rights reserved.