com.iphrase.runtime.query.constraint
Class Conjunction

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--com.iphrase.runtime.query.constraint.Conjunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class Conjunction
extends java.util.Vector

Represent a collection of constraint Disjunction instances ANDed together by this conjunction.

Note that neither ArrayList (nor List) support setSize(), so I've implemented this as a Vector.

See Also:
Serialized Form

Constructor Summary
Conjunction()
           
Conjunction(java.lang.String state)
           
 
Method Summary
 boolean contains(Constraint constraint)
          Determine if the designated constraint is the same as a constraint in one of the disjunctions in this conjunction.
 boolean contains(Disjunction disjunction)
          Determine if the designated disjunction is the same as one of the disjunctions int this conjunction.
 void cull(Conjunction conjunction)
           
 void cull(Disjunction disjunction)
          Cull a disjunction from this conjunction.
 boolean matches(Constraint c)
          Determine whether this conjunction has any constraints that match (as defined by Constraint.matches(com.iphrase.runtime.query.constraint.Constraint)) the designated constraint.
 void merge(Conjunction conjunction)
           
 void merge(Disjunction disjunction)
          Merge a disjunction into this conjunction.
 Disjunction set(int index, java.lang.String state)
          Create a constraint Disjunction from a OneStep serialization String and set the new disjunction to the specified index in this conjunction.
 void swap(Conjunction out, Conjunction in)
           
 void swap(Constraint out, Constraint in)
          Replace all instances of one constraint with another, in place.
 java.lang.String toString()
          Serialize this conjunction using the OneStep serialization format.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

Conjunction

public Conjunction()

Conjunction

public Conjunction(java.lang.String state)
            throws ArgumentError
Method Detail

set

public Disjunction set(int index,
                       java.lang.String state)
                throws ArgumentError
Create a constraint Disjunction from a OneStep serialization String and set the new disjunction to the specified index in this conjunction.
Parameters:
index - int position in this conjunction
state - OneStep serialization String from which a Disjunction can be created
Returns:
disjunction that was originally at the index position, or null This method is public for a protected Query method

toString

public java.lang.String toString()
Serialize this conjunction using the OneStep serialization format. Overrides Object.toString()
Overrides:
toString in class java.util.Vector
Returns:
OneStep serialization String of this conjunction

swap

public void swap(Constraint out,
                 Constraint in)
Replace all instances of one constraint with another, in place. All constraints that match (as defined by matches(com.iphrase.runtime.query.constraint.Constraint)) 'out' will be replaced with 'in'.
Parameters:
out - Constraint to swap out
in - Constraint to swap in

swap

public void swap(Conjunction out,
                 Conjunction in)

merge

public void merge(Disjunction disjunction)
Merge a disjunction into this conjunction. Merge means cull(com.iphrase.runtime.query.constraint.Disjunction), to avoid duplicates, then add the designated disjunction.
Parameters:
disjunction - the designated Disjunction to merge

merge

public void merge(Conjunction conjunction)

cull

public void cull(Disjunction disjunction)
Cull a disjunction from this conjunction. Cull means remove any constraints from any disjunctions in this conjunction that match (as defined by matches(com.iphrase.runtime.query.constraint.Constraint)) any constraints in the designated disjunction. If any disjunction becomes empty as a result, remove it.
Parameters:
disjunction - the designated Disjunction to cull

cull

public void cull(Conjunction conjunction)

matches

public boolean matches(Constraint c)
Determine whether this conjunction has any constraints that match (as defined by Constraint.matches(com.iphrase.runtime.query.constraint.Constraint)) the designated constraint.
Parameters:
c - Constraint to be matched
Returns:
true if there is a match, else false.

contains

public boolean contains(Constraint constraint)
Determine if the designated constraint is the same as a constraint in one of the disjunctions in this conjunction.
Parameters:
constraint - the designated Constraint
Returns:
true if and only if the designated constraint is the same as a constraint in one of the disjunctions in this instance, as determined by the equals method; false otherwise.

contains

public boolean contains(Disjunction disjunction)
Determine if the designated disjunction is the same as one of the disjunctions int this conjunction.
Parameters:
disjunction - the designated Disjunction
Returns:
true if and only if the designated disjunction is the same as one of the disjunctions in this instance, as determined by the equals method; false otherwise.

© Copyright 2005, 2006. IBM Corporation. All rights reserved.