cz.cuni.versatile.core
Class PropertyOperators

java.lang.Object
  extended bycz.cuni.versatile.core.PropertyOperators
All Implemented Interfaces:
PropertyOperator

public class PropertyOperators
extends java.lang.Object
implements PropertyOperator

A default implementation of the PropertyOperator interface as well as an enumeration of all built-in (pre-defined) property operators. The set of operators can be easily extended, however, it always depends on the individual implementation of the ResourceProvider interface which operators it recognizes. The operators listed below are mandatory for all compliant ResourceProvider implementations.

OperatorIntrinsicAssertiveApplicable
=yesyesProperty
>yesyesProperty
<yesyesProperty
>=yesyesProperty
<=yesyesProperty
assertnoyesRelationalProperty
assertInvnoyesRelationalProperty
assertLevelnoyesTaxonomy
equivalentnoyesEquivalence
comparablenoyesOrderProperty
isParentnoyesTaxonomy
isChildnoyesTaxonomy
isAncestornoyesTaxonomy
isDescendantnoyesTaxonomy
bestMatchnonoTaxonomy

Author:
Jaroslav Gergic
See Also:
QueryTemplate

Field Summary
static PropertyOperator ASSERT
          assert extrinsic assertive operator.
static PropertyOperator ASSERT_INV
          assertInv extrinsic assertive operator.
static PropertyOperator ASSERT_LEVEL
          assertLevel extrinsic assertive operator.
protected  boolean assertive
          Flag whether the operator is assertive or whether it allows for an approximate matching (fall-back, constraint relaxing).
static PropertyOperator BEST_MATCH
          bestMatch extrinsic constraint-relaxing operator.
static PropertyOperator COMPARABLE
          comparable extrinsic assertive operator.
static PropertyOperator EQ
          Equals intrinsic assertive operator.
static PropertyOperator EQUIVALENT
          equivalent extrinsic assertive operator.
static PropertyOperator GE
          Greater than or equal to (>=) intrinsic assertive operator.
static PropertyOperator GT
          Greater-than (>) intrinsic assertive operator.
protected  int id
          The unique ID of the operator.
protected  boolean intrinsic
          Flag whether the operator is intrinsic or extrinsic intrinsic operators use methods of the actual property values for comparison, so they rely on the existing methods of Java objects extrinsic operators rely on the relations externally provided by the properties (e.g.
static PropertyOperator IS_ANCESTOR
          isAncestor extrinsic assertive operator.
static PropertyOperator IS_CHILD
          isChild extrinsic assertive operator.
static PropertyOperator IS_DESCENDANT
          isDescendant extrinsic assertive operator.
static PropertyOperator IS_PARENT
          isParent extrinsic assertive operator.
static PropertyOperator LE
          Less than or equal to (<=) intrinsic assertive operator.
static PropertyOperator LT
          Less-than (<) intrinsic assertive operator.
protected  java.lang.String name
          A human-readable name - just for logging and debugging.
 
Constructor Summary
protected PropertyOperators(int id, java.lang.String name, boolean intrinsic, boolean assertive)
          Protected Constructor - can be re-used by subclasses extending the set of supported operators.
 
Method Summary
 int getId()
          The unique ID of the property operator.
 java.lang.String getName()
          A human-readable property operator name - just for logging and debugging.
 boolean isAssertive()
          Flag whether the operator is assertive or whether it allows for an approximate matching (fall-back, constraint relaxing)
 boolean isExtrinsic()
          Flag whether the operator is extrinsic Extrinsic operators rely on the relations externally provided by the properties (e.g.
 boolean isIntrinsic()
          Flag whether the operator is intrinsic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected int id
The unique ID of the operator.


name

protected java.lang.String name
A human-readable name - just for logging and debugging.


intrinsic

protected boolean intrinsic
Flag whether the operator is intrinsic or extrinsic

assertive

protected boolean assertive
Flag whether the operator is assertive or whether it allows for an approximate matching (fall-back, constraint relaxing).

See Also:
PropertyOperator.isAssertive()

EQ

public static final PropertyOperator EQ
Equals intrinsic assertive operator. When comparing two values, it invokes Object.equals() method.

See Also:
Object.equals(java.lang.Object), QueryTemplate.add_Equal(String)

GT

public static final PropertyOperator GT
Greater-than (>) intrinsic assertive operator. When comparing two values, it invokes Comparable.compareTo() method.

Remarks: Requires the objects to implement the Comparable interface.

See Also:
Comparable.compareTo(java.lang.Object), QueryTemplate.add_GT(String)

LT

public static final PropertyOperator LT
Less-than (<) intrinsic assertive operator. When comparing two values, it invokes Comparable.compareTo() method.

Remarks: Requires the objects to implement the Comparable interface.

See Also:
Comparable.compareTo(java.lang.Object), QueryTemplate.add_LT(String)

GE

public static final PropertyOperator GE
Greater than or equal to (>=) intrinsic assertive operator. When comparing two values, it invokes Comparable.compareTo() method.

Remarks: Requires the objects to implement the Comparable interface.

See Also:
Comparable.compareTo(java.lang.Object), QueryTemplate.add_GE(String)

LE

public static final PropertyOperator LE
Less than or equal to (<=) intrinsic assertive operator. When comparing two values, it invokes Comparable.compareTo() method.

Remarks: Requires the objects to implement the Comparable interface.

See Also:
Comparable.compareTo(java.lang.Object), QueryTemplate.add_LE(String)

ASSERT

public static final PropertyOperator ASSERT
assert extrinsic assertive operator. When matching two values, it invokes RelationalProperty.contains(x, y).

Remarks:

See Also:
RelationalProperty.contains(Object, Object), QueryTemplate.addAssert(String)

ASSERT_INV

public static final PropertyOperator ASSERT_INV
assertInv extrinsic assertive operator. When matching two values, it invokes RelationalProperty.contains(y, x), which is equivalent to InverseOf(p:RelationalProperty).contains(x, y).

Remarks:

  • Can only be applied to a RelationalProperty
  • therefore it applies also to OrderProperty, Equivalence and Taxonomy

See Also:
RelationalProperty.contains(Object, Object), InverseOf, QueryTemplate.addAssertInv(String)

ASSERT_LEVEL

public static final PropertyOperator ASSERT_LEVEL
assertLevel extrinsic assertive operator. Similar to assert but applies only to taxonomies. Besides the RelationalProperty.contains(x, y) it imposes an additional constraint on how far are x and y in the classification hierarchy (taxonomy). The additional mandatory parameter level(int) represents the additional constraint as follows:
  • level = 0 - equivalent to assert
  • level > 0 - absolute distance from the root of the taxonomy
  • level < 0 - relative distance from the context node

Remarks:

  • Can only be applied to a Taxonomy property
  • typically used together with the bestMatch operator to implement constrained fall-back search
  • level > 0 makes most sense for fixed-depth taxonomies (e.g. UNSPSC), for example, by combining "bestMatch and assertLevel(2)", we can match all entries which are equal-to or greater-than a given entry, up-to the second level of the 4-level UNSPSC hierarchy: given 43232203 (File versioning software), we generate the following search sequence to find an upper-bound best match:
    43232203 (File versioning software)
    43232200 (Content management software)
    43230000 (Software)
  • The parent entry 43000000 (Information Technology Broadcasting and Telecommunications) wont' match the query given the "assertLevel(2)" condition.
  • level < 0 on the other hand allows to express how many steps of the best match fall-back search we want to allow, given the example above and the query "bestMatch and assertLevel(-1)", only the exact match and optionally one step fall-back occurs:
    43232203 (File versioning software)
    43232200 (Content management software)

See Also:
Taxonomy, BEST_MATCH, QueryTemplate.addAssertLevel(String, int)

COMPARABLE

public static final PropertyOperator COMPARABLE
comparable extrinsic assertive operator. Check wheter two property values are comparable given the particular order property.

Remarks:

  • Can only be applied to an OrderProperty property

See Also:
OrderProperty.comparable(Object, Object), QueryTemplate.addComparable(String)

EQUIVALENT

public static final PropertyOperator EQUIVALENT
equivalent extrinsic assertive operator. Unlike the equals (an intrinsic operator) equivalent relies on Equivalence sub-type of RelationalProperty to decide which values are considered "equal".

Remarks:

  • Can only be applied to an Equivalence property

See Also:
Equivalence, QueryTemplate.addEquivalent(String)

IS_PARENT

public static final PropertyOperator IS_PARENT
isParent extrinsic assertive operator. Please refer to Taxonomy API for details.

Remarks:

  • Can only be applied to a Taxonomy property

See Also:
Taxonomy.isParent(Object, Object), QueryTemplate.addIsParent(String)

IS_CHILD

public static final PropertyOperator IS_CHILD
isChild extrinsic assertive operator. Please refer to Taxonomy API for details.

Remarks:

  • Can only be applied to a Taxonomy property

See Also:
Taxonomy.isChild(Object, Object), QueryTemplate.addIsChild(String)

IS_ANCESTOR

public static final PropertyOperator IS_ANCESTOR
isAncestor extrinsic assertive operator. Please refer to Taxonomy API for details.

Remarks:

  • Can only be applied to a Taxonomy property

See Also:
Taxonomy.isAncestor(Object, Object), QueryTemplate.addIsAncestor(String)

IS_DESCENDANT

public static final PropertyOperator IS_DESCENDANT
isDescendant extrinsic assertive operator. Please refer to Taxonomy API for details.

Remarks:

  • Can only be applied to a Taxonomy property
  • It is equivalent to RelationalProperty.contains() in case of Taxonomy.

See Also:
Taxonomy.isDescendant(Object, Object), QueryTemplate.addIsDescendant(String)

BEST_MATCH

public static final PropertyOperator BEST_MATCH
bestMatch extrinsic constraint-relaxing operator. Probably the most powerful and useful Versatile operator: it starts with a given context node = the actual property value obtained from its ValueProvider and tries to perform an exact match, if no resource is found, it uses Taxonomy#getAncestorIterator() to generate a sequence of candidates in ascending order, leveraging the classification hierarchy of the taxonomy. With properly designed taxonomies in place, one can thus easily implement quite sophisticated fall-back strategies using hierarchical defaulting (constraint relaxing).

Remarks:

  • Can only be applied to a Taxonomy property
  • An example using UNSPSC taxonomy: given 43232203 (File versioning software) we generate the following search sequence to find the closest match:
    43232203 (File versioning software)
    43232200 (Content management software)
    43230000 (Software)
    43000000 (Information Technology Broadcasting and Telecommunications)
    / (root = property value not set = universal concept)

See Also:
ASSERT_LEVEL, Taxonomy.getAncestorIterator(Object, java.util.Comparator), QueryTemplate.addBestMatch(String)
Constructor Detail

PropertyOperators

protected PropertyOperators(int id,
                            java.lang.String name,
                            boolean intrinsic,
                            boolean assertive)
Protected Constructor - can be re-used by subclasses extending the set of supported operators.

Parameters:
id - unique operator ID used for processing query predicates
name - human readable equivalent for debugging and logging
intrinsic - intrinsic/extrinsic flag
Method Detail

getId

public int getId()
Description copied from interface: PropertyOperator
The unique ID of the property operator. Used for manipulating the property predicates programmatically (to support switch/case statement).

Specified by:
getId in interface PropertyOperator
Returns:
the unique ID of the property operator
See Also:
PropertyOperator.getId()

getName

public java.lang.String getName()
Description copied from interface: PropertyOperator
A human-readable property operator name - just for logging and debugging.

Specified by:
getName in interface PropertyOperator
Returns:
a human-readable property operator name.
See Also:
PropertyOperator.getName()

isIntrinsic

public boolean isIntrinsic()
Description copied from interface: PropertyOperator
Flag whether the operator is intrinsic. Intrinsic operators use methods of the actual property values for comparison, so they rely on the existing methods of Java objects (e.g. Object.equals() or Comparable.compareTo())

Remarks: An operator is either intrinsic or extrinsic, never both.

Specified by:
isIntrinsic in interface PropertyOperator
Returns:
true is the property operator is intrinsic
See Also:
PropertyOperator.isIntrinsic()

isExtrinsic

public boolean isExtrinsic()
Description copied from interface: PropertyOperator
Flag whether the operator is extrinsic Extrinsic operators rely on the relations externally provided by the properties (e.g. OrderProperty, Equivalence)

Remarks: An operator is either intrinsic or extrinsic, never both.

Specified by:
isExtrinsic in interface PropertyOperator
Returns:
true is the property operator is extrinsic
See Also:
PropertyOperator.isExtrinsic()

isAssertive

public boolean isAssertive()
Description copied from interface: PropertyOperator
Flag whether the operator is assertive or whether it allows for an approximate matching (fall-back, constraint relaxing)

Specified by:
isAssertive in interface PropertyOperator
Returns:
true if the operator does not allow for any constraint relaxing