eu.xtreemos.xosd.resmng.data
Class ConditionTreeOperator

java.lang.Object
  extended by eu.xtreemos.xosd.resmng.data.ConditionTreeOperator
All Implemented Interfaces:
IConditionTreeNode

public class ConditionTreeOperator
extends java.lang.Object
implements IConditionTreeNode

A class for the condition tree node that represents an operator. The operator is either && or ||, and the operands - the children of the node - is a list of either members of ConditionTreeCondition or members of ConditionTreeOperator.

Author:
matej.artac@xlab.si

Field Summary
static int AND
          A constant denoting the operator &&.
protected  java.util.ArrayList<IConditionTreeNode> children
          The nodes that descend from this node in the condition tree.
protected  boolean defaultValue
          The value returned by default when the node has not been evaluated (e.g. when the values to test against do not arrive).
protected  boolean hasBeenEvaluated
          True if a call to evaluateNode() has been performed, and false otherwise.
(package private) static org.apache.log4j.Logger logger
           
protected  int operator
          The operator to be used when evaluating the condition node.
static int OR
          A constant denoting the operator ||.
 
Constructor Summary
ConditionTreeOperator(int operator)
           
 
Method Summary
 boolean evaluateNode(ResourceDescriptorRecord resource)
          Evaluates the node according to the operator and the descending nodes.
protected  boolean evaluateNodeAnd(ResourceDescriptorRecord resource)
          Evaluate the && node of the tree.
protected  boolean evaluateNodeOr(ResourceDescriptorRecord resource)
          Evaluate the || node of the tree.
 double evaluateScore(ResourceDescriptorRecord resource)
          Check the compliance of the input resource with the node of the condition subtree originating from this node, and evaluate the score of the resource.
 double evaluateScore(ResourceDescriptorRecord resource, java.util.Hashtable<java.lang.Integer,java.lang.Double> attributeWeight)
          Check the compliance of the input resource with the node of the condition subtree originating from this node, and evaluate the score of the resource.
 java.util.ArrayList<IConditionTreeNode> getChildren()
          Retrieves the collection of nodes that descend from this node in the condition tree.
 boolean getDefaultValue()
           
 boolean getHasBeenEvaluated()
           
 int getOperator()
           
 boolean getSubtreeScorekeeper(ResourceDescriptorRecord resource, java.util.Hashtable<java.lang.Integer,AttributeScorekeeper> scorekeepers)
          The method builds a hash table of AttributeScorekeeper instances for each of the attribute that takes part in the subtree of the condition tree that starts at the provided node.
protected  boolean getSubtreeScorekeeperNodeAnd(ResourceDescriptorRecord resource, java.util.Hashtable<java.lang.Integer,AttributeScorekeeper> scorekeepers)
           
protected  boolean getSubtreeScorekeeperNodeOr(ResourceDescriptorRecord resource, java.util.Hashtable<java.lang.Integer,AttributeScorekeeper> scorekeepers)
           
 void setChildren(java.util.ArrayList<IConditionTreeNode> children)
          Assigns a new collection of nodes to descend from this node in the condition tree.
 void setDefaultValue(boolean defaultValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger

AND

public static final int AND
A constant denoting the operator &&.

See Also:
Constant Field Values

OR

public static final int OR
A constant denoting the operator ||.

See Also:
Constant Field Values

operator

protected int operator
The operator to be used when evaluating the condition node.


children

protected java.util.ArrayList<IConditionTreeNode> children
The nodes that descend from this node in the condition tree.


defaultValue

protected boolean defaultValue
The value returned by default when the node has not been evaluated (e.g. when the values to test against do not arrive).


hasBeenEvaluated

protected boolean hasBeenEvaluated
True if a call to evaluateNode() has been performed, and false otherwise.

Constructor Detail

ConditionTreeOperator

public ConditionTreeOperator(int operator)
                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException
Method Detail

getChildren

public java.util.ArrayList<IConditionTreeNode> getChildren()
Retrieves the collection of nodes that descend from this node in the condition tree.

Returns:
The arrayList representing the descending nodes (children) of this node.

setChildren

public void setChildren(java.util.ArrayList<IConditionTreeNode> children)
Assigns a new collection of nodes to descend from this node in the condition tree.

Parameters:
children - The new collection representing the descending nodes (children) of this node.

evaluateNodeAnd

protected boolean evaluateNodeAnd(ResourceDescriptorRecord resource)
Evaluate the && node of the tree.

Parameters:
resource - The resource to check for compliance with the condition subtree originating from this node.
Returns:
True if the resource fits the conditions of the condition subtree, and false otherwise.

evaluateNodeOr

protected boolean evaluateNodeOr(ResourceDescriptorRecord resource)
Evaluate the || node of the tree.

Parameters:
resource - The resource to check for compliance with the condition subtree originating from this node.
Returns:
True if the resource fits the conditions of the condition subtree, and false otherwise.

evaluateNode

public boolean evaluateNode(ResourceDescriptorRecord resource)
                     throws java.lang.IllegalArgumentException
Evaluates the node according to the operator and the descending nodes.

Specified by:
evaluateNode in interface IConditionTreeNode
Parameters:
resource - The resource to check the compliance of.
Returns:
Throws:
java.lang.IllegalArgumentException

evaluateScore

public double evaluateScore(ResourceDescriptorRecord resource)
                     throws java.lang.IllegalArgumentException
Check the compliance of the input resource with the node of the condition subtree originating from this node, and evaluate the score of the resource. Higher values of the score mean better compliance with the query.

Specified by:
evaluateScore in interface IConditionTreeNode
Parameters:
resource - The resource to check the compliance of.
Returns:
The score of the resource. The higher the score, the better the resource fits the query. Returns -1 for resources that do not fit the conditions of the query.
Throws:
java.lang.IllegalArgumentException

evaluateScore

public double evaluateScore(ResourceDescriptorRecord resource,
                            java.util.Hashtable<java.lang.Integer,java.lang.Double> attributeWeight)
                     throws java.lang.IllegalArgumentException
Description copied from interface: IConditionTreeNode
Check the compliance of the input resource with the node of the condition subtree originating from this node, and evaluate the score of the resource. Higher values of the score mean better compliance with the query. The attributes have uniform influence to the score.

Specified by:
evaluateScore in interface IConditionTreeNode
Parameters:
resource - The resource to check the compliance of.
attributeWeight - A hash table of pairs (attribute identifier, the weight)
Returns:
The score of the resource. The higher the score, the better the resource fits the query. Returns -1 for resources that do not fit the conditions of the query.
Throws:
java.lang.IllegalArgumentException

getSubtreeScorekeeperNodeAnd

protected boolean getSubtreeScorekeeperNodeAnd(ResourceDescriptorRecord resource,
                                               java.util.Hashtable<java.lang.Integer,AttributeScorekeeper> scorekeepers)

getSubtreeScorekeeperNodeOr

protected boolean getSubtreeScorekeeperNodeOr(ResourceDescriptorRecord resource,
                                              java.util.Hashtable<java.lang.Integer,AttributeScorekeeper> scorekeepers)

getSubtreeScorekeeper

public boolean getSubtreeScorekeeper(ResourceDescriptorRecord resource,
                                     java.util.Hashtable<java.lang.Integer,AttributeScorekeeper> scorekeepers)
Description copied from interface: IConditionTreeNode
The method builds a hash table of AttributeScorekeeper instances for each of the attribute that takes part in the subtree of the condition tree that starts at the provided node. The caller function should pass an already initialised Hashtable. The implementations of the method should ensure that at the end of its execution the hash table will contain the entries for all attributes ecountered in the subtree. If the condition subtree evaluates as false, then the attributes in the subtree that have no entries in the hash table before the call should appear in the hash table with negative scores and zero occurence counts.

Specified by:
getSubtreeScorekeeper in interface IConditionTreeNode
Parameters:
resource - The resource record to get the scores of.
scorekeepers - The hash table that receives the attribute's scores. The contents of the hash table will change during the call execution. If the subtree yields that the record complies with the respective subpart of the query, then the hash table should be updated with the scores computed at the leaf nodes. If it yields non-complience, then the attribute entries already in the hash table should be left intact, and those encountered in the subtree that do not appear in the hash table have to be tagged with negative scores and zero occurence counts.
Returns:
True if the resource fits the conditions of the condition subtree, and false otherwise.

getDefaultValue

public boolean getDefaultValue()

setDefaultValue

public void setDefaultValue(boolean defaultValue)

getHasBeenEvaluated

public boolean getHasBeenEvaluated()

getOperator

public int getOperator()