org.rapla.entities.dynamictype
Interface ClassificationFilter

All Superinterfaces:
Cloneable

public interface ClassificationFilter
extends Cloneable

A new ClassificationFilter for a classifications belonging to the same DynamicType can be created by the newClassificationFilter of the corresponding DynamicType object.

You can set rules for the attributes of the DynamicType. A Classification (object implementing Classifiable) is matched by the filter when the conditions for each attribute-rule are matched (AND - function).

A condition is an array of size 2, the first field contains the operator of the condition and the second the test value. When an attribute-rule has more than one condition, at least one of the conditions must be matched (OR - function ) .

The following Example matches all classifications with a title-value that contains either "rapla" or "sourceforge" ,a size-value that is > 5 and a category-department-value that is either the departmentA or the departmentB.

       DynamicType eventType = facade.getDynamicType("event");
       ClassificationFilter f = eventType.newClassificationFilter();
       f.addRule(
                 "title"
                 ,new Object {
                    {"contains", "rapla"}
                    ,{"contains", "sourceforge"}
                  });
      f.addRule(
                 "size"
                 ,new Object{
                      {">", new Integer(5)}
                  });

           Category departemntCategory = facade.getRootCategory().getCategory("departments");
       Category departmentA = departmentCategory.getCategory("departmentA");
       Category departmentB = departmentCategory.getCategory("departmentB");
       f.addRule(
                 "department"
                 ,new Object{
                      {"=", departmentA}
                     ,{ "=", departmentB}
                  });
    

See Also:
Classification

Field Summary
static ClassificationFilter[] CLASSIFICATIONFILTER_ARRAY
           
 
Method Summary
 void addEqualsRule(String attributeName, Object object)
          shortcut to f.addRule( attributeName ,new Object{ {"=", object}} });
 void addIsRule(String attributeName, Object object)
          shortcut to f.addRule( attributeName ,new Object{ {"is", object}} });
 void addRule(String attributeName, Object[][] conditions)
          appends a rule.
 Object clone()
           
 DynamicType getType()
           
 boolean matches(Classification classification)
           
 void removeAllRules()
           
 void removeRule(int index)
           
 Iterator ruleIterator()
           
 int ruleSize()
           
 void setRule(int index, Attribute attribute, Object[][] conditions)
           
 void setRule(int index, String attributeName, Object[][] conditions)
          Defines a rule for the passed attribute.
 ClassificationFilter[] toArray()
           
 

Field Detail

CLASSIFICATIONFILTER_ARRAY

static final ClassificationFilter[] CLASSIFICATIONFILTER_ARRAY
Method Detail

getType

DynamicType getType()

setRule

void setRule(int index,
             String attributeName,
             Object[][] conditions)
Defines a rule for the passed attribute.


setRule

void setRule(int index,
             Attribute attribute,
             Object[][] conditions)

addRule

void addRule(String attributeName,
             Object[][] conditions)
appends a rule.

See Also:
setRule(int, java.lang.String, java.lang.Object[][])

addEqualsRule

void addEqualsRule(String attributeName,
                   Object object)
shortcut to
 f.addRule(
                 attributeName
                 ,new Object{
                            {"=", object}}
                  });
 

Parameters:
attributeName -
object -

addIsRule

void addIsRule(String attributeName,
               Object object)
shortcut to
 f.addRule(
                 attributeName
                 ,new Object{
                            {"is", object}}
                  });
 

Parameters:
attributeName -
object -

ruleSize

int ruleSize()

ruleIterator

Iterator ruleIterator()

removeAllRules

void removeAllRules()

removeRule

void removeRule(int index)

matches

boolean matches(Classification classification)

clone

Object clone()

toArray

ClassificationFilter[] toArray()


Copyright 2000-2006 Rapla Team. All Rights Reseserved.