org.caleigo.core
Class CompositeQualifier

java.lang.Object
  extended byorg.caleigo.core.Qualifier
      extended byorg.caleigo.core.CompositeQualifier
All Implemented Interfaces:
java.io.Serializable

public class CompositeQualifier
extends Qualifier

The CompositeQualifier is a Qualifier that contains a collection of other Qualifiers wrapping them as a single Qalifier effectively implementing the "Composite" design pattern. A CompositeQualifier can form either a union or an intersection of the contained Qualifiers which is defined at the creation.

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
protected static class CompositeQualifier.UniqueQualifierVisitor
           
 
Nested classes inherited from class org.caleigo.core.Qualifier
Qualifier.RelayListener
 
Field Summary
static int INTERSECTION
          Used to state that all contained Qualifiers defines a intersection which means that they should be combined using using logical "AND".
static int UNION
          Used to state that all contained Qualifiers defines a union which means that they should be combined using using logical "OR".
 
Constructor Summary
CompositeQualifier()
          Default constructor that creates a new CompositeQualifier forming an intersection of any added Qualifiers.
CompositeQualifier(int unionType)
          Creates a new CompositeQualifier forming either an intersection or a union depending on the provided of the union type constant.
CompositeQualifier(Qualifier qualifier1, Qualifier qualifier2)
          Creates a new CompositeQualifier forming an intersection of the two provided Qualifiers.
CompositeQualifier(Qualifier qualifier1, Qualifier qualifier2, int unionType)
          Creates a new CompositeQualifier forming either an intersection or a union depending on the defined of the unionType two provided Qualifiers.
 
Method Summary
 void add(Qualifier qualifier)
          Adds a new Qulifier to contained collection of Qualifiers.
 void addQualifierListener(IQualifierListener listener)
          Adds an IQualifierListener to receive notifications of contents and structure changes from the Qualifier object.
 boolean canDirectlyQualify(IEntityDescriptor entityDescriptor)
          This abstract method must return true if the qualifier can select entities of the type defined by the provided entity descriptor without the nead of any complementary data.
 boolean canQualify(IEntityDescriptor entityDescriptor)
          This method returns true if the qualifier can select entities of the type defined by the provided entity descriptor.
 boolean canUniquelyQualify(IEntityDescriptor entityDescriptor)
          This method returns true if the qualifier can uniquely select entities of the type defined by the provided entity descriptor.
 boolean doesQualify(IEntity entity)
          This method returns true if the qualifier does select the provided entity object.
 Qualifier getQualifier(int index)
          Access method that returns the indexed contained Qualifier.
 int getQualifierCount()
          Access method that returns the count of the contained Qualifiers.
 java.util.Iterator getQualifiers()
          Access method that returns an Iterator object for the cotained collection of Qualifier objects.
 int getUnionType()
          Access method that returns the Qualifiers union defined by one of the constants UNION or INTERSECTION.
 java.lang.String toString()
          The toString method returns an "abstract" expression of what the qualifier selects.
 
Methods inherited from class org.caleigo.core.Qualifier
and, and, and, combine, create, create, fireContentChangedEvent, fireQualifierEvent, fireStructureChangedEvent, negate, or, or, or, removeQualifierListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNION

public static final int UNION
Used to state that all contained Qualifiers defines a union which means that they should be combined using using logical "OR".

See Also:
Constant Field Values

INTERSECTION

public static final int INTERSECTION
Used to state that all contained Qualifiers defines a intersection which means that they should be combined using using logical "AND".

See Also:
Constant Field Values
Constructor Detail

CompositeQualifier

public CompositeQualifier()
Default constructor that creates a new CompositeQualifier forming an intersection of any added Qualifiers.


CompositeQualifier

public CompositeQualifier(int unionType)
Creates a new CompositeQualifier forming either an intersection or a union depending on the provided of the union type constant.


CompositeQualifier

public CompositeQualifier(Qualifier qualifier1,
                          Qualifier qualifier2)
Creates a new CompositeQualifier forming an intersection of the two provided Qualifiers.


CompositeQualifier

public CompositeQualifier(Qualifier qualifier1,
                          Qualifier qualifier2,
                          int unionType)
Creates a new CompositeQualifier forming either an intersection or a union depending on the defined of the unionType two provided Qualifiers.

Method Detail

doesQualify

public boolean doesQualify(IEntity entity)
This method returns true if the qualifier does select the provided entity object.

Specified by:
doesQualify in class Qualifier

canQualify

public boolean canQualify(IEntityDescriptor entityDescriptor)
This method returns true if the qualifier can select entities of the type defined by the provided entity descriptor.

Specified by:
canQualify in class Qualifier

canDirectlyQualify

public boolean canDirectlyQualify(IEntityDescriptor entityDescriptor)
This abstract method must return true if the qualifier can select entities of the type defined by the provided entity descriptor without the nead of any complementary data. No other information than can be accessed through the provided entity descriptor should be neaded if this method returns true. This validates that the doesQualify method can be called for the called qualifier.

Specified by:
canDirectlyQualify in class Qualifier

canUniquelyQualify

public boolean canUniquelyQualify(IEntityDescriptor entityDescriptor)
This method returns true if the qualifier can uniquely select entities of the type defined by the provided entity descriptor. If that is the case then the qualifier is an identity qualifier and can never qualify more then a single entity instance of the specified type.

Specified by:
canUniquelyQualify in class Qualifier

addQualifierListener

public void addQualifierListener(IQualifierListener listener)
Adds an IQualifierListener to receive notifications of contents and structure changes from the Qualifier object. The CompositeQualifier overrides this method to know when to listen to the contained qualifiers.

Overrides:
addQualifierListener in class Qualifier

toString

public java.lang.String toString()
The toString method returns an "abstract" expression of what the qualifier selects. Note that this expresion is only intended for visual aid and is not a valid SQL expresion.


add

public void add(Qualifier qualifier)
Adds a new Qulifier to contained collection of Qualifiers. The added Qualifier will be joined as union or intersection depending of the set union type defined for the CompositeQualifier.


getUnionType

public int getUnionType()
Access method that returns the Qualifiers union defined by one of the constants UNION or INTERSECTION.


getQualifierCount

public int getQualifierCount()
Access method that returns the count of the contained Qualifiers.


getQualifier

public Qualifier getQualifier(int index)
Access method that returns the indexed contained Qualifier.

Throws:
java.lang.IndexOutOfBoundsException

getQualifiers

public java.util.Iterator getQualifiers()
Access method that returns an Iterator object for the cotained collection of Qualifier objects.



Copyright © 2005 Caleigo. All Rights Reserved.