de.fuberlin.wiwiss.wiqa.count
Class CountConstraint

java.lang.Object
  extended byde.fuberlin.wiwiss.wiqa.count.CountConstraint

public class CountConstraint
extends Object

A constraint on the number of distinct values for a variable. Is used to implement the COUNT feature of WIQA. Occurrences of the constrained variable will be counted and compared to a fixed integer value with a comparision operator.

The supported operators are encoded as strings:

Version:
$Id: CountConstraint.java,v 1.3 2006/06/12 16:19:29 cyganiak Exp $
Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
CountConstraint(String variableName, String operator, int value, ElementNamedGraph element)
          Creates a new count constraint for a specific graph pattern.
 
Method Summary
 ElementNamedGraph element()
           
 boolean isMatchingCount(int count)
          Compares an actual number of occurrences of the constrained variable to the fixed value.
 String operator()
           
 int value()
           
 String variableName()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountConstraint

public CountConstraint(String variableName,
                       String operator,
                       int value,
                       ElementNamedGraph element)
Creates a new count constraint for a specific graph pattern.

Parameters:
variableName - The name of the constrained variable, for example "GRAPH"
operator - Must be one of the supported comparision operators
value - The actual count will be compared to this number.
Method Detail

variableName

public String variableName()
Returns:
The name of the constrained variable, for example "GRAPH"

operator

public String operator()
Returns:
The comparision operator of the constraint

value

public int value()
Returns:
The fixed value to be tested against

element

public ElementNamedGraph element()
Returns:
The graph pattern on which the constraint is defined, or null if on the root

isMatchingCount

public boolean isMatchingCount(int count)
Compares an actual number of occurrences of the constrained variable to the fixed value.

Parameters:
count - The number of occurrences of the variable
Returns:
true if it is in the accepted range