prefuse.data.expression
Class CompositePredicate

java.lang.Object
  extended by prefuse.data.expression.AbstractExpression
      extended by prefuse.data.expression.AbstractPredicate
          extended by prefuse.data.expression.CompositePredicate
All Implemented Interfaces:
java.util.EventListener, ExpressionListener, Expression, Predicate
Direct Known Subclasses:
AndPredicate, OrPredicate, XorPredicate

public abstract class CompositePredicate
extends AbstractPredicate

Abstract base class for Predicate instances that maintain one or more sub-predicates (clauses).

Author:
jeffrey heer

Field Summary
protected  java.util.ArrayList m_clauses
           
 
Constructor Summary
CompositePredicate()
          Create a new, empty CompositePredicate.
CompositePredicate(Predicate p1, Predicate p2)
          Create a new CompositePredicate.
 
Method Summary
 void add(Predicate p)
          Add a new clause.
protected  void addChildListeners()
          Add child listeners to catch and propagate sub-expression updates.
 void clear()
          Remove all clauses.
 Predicate get(int idx)
          Get the sub-predicate at the given index.
 Predicate getSubPredicate(Predicate p)
          Get a predicate instance just like this one but without the given predicate as a clause.
 boolean remove(Predicate p)
          Remove a new clause.
protected  void removeChildListeners()
          Remove child listeners for sub-expression updates.
 void set(Predicate p)
          Set the given predicate to be the only clause of thie composite.
 void set(Predicate[] p)
          Set the given predicates to be the clauses of thie composite.
 int size()
          Get the number of sub-predicate clauses.
protected  java.lang.String toString(java.lang.String op)
          Return a String representation of this predicate.
 void visit(ExpressionVisitor v)
          Passes the visitor through this expression and any sub expressions
 
Methods inherited from class prefuse.data.expression.AbstractPredicate
get, getType
 
Methods inherited from class prefuse.data.expression.AbstractExpression
addExpressionListener, expressionChanged, fireExpressionChange, getBoolean, getDouble, getFloat, getInt, getLong, hasListeners, removeExpressionListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface prefuse.data.expression.Expression
addExpressionListener, getBoolean, getDouble, getFloat, getInt, getLong, removeExpressionListener
 

Field Detail

m_clauses

protected java.util.ArrayList m_clauses
Constructor Detail

CompositePredicate

public CompositePredicate()
Create a new, empty CompositePredicate.


CompositePredicate

public CompositePredicate(Predicate p1,
                          Predicate p2)
Create a new CompositePredicate.

Parameters:
p1 - the first sub-predicate
p2 - the second sub-predicate
Method Detail

add

public void add(Predicate p)
Add a new clause.

Parameters:
p - the Predicate clause to add

remove

public boolean remove(Predicate p)
Remove a new clause.

Parameters:
p - the Predicate clause to remove
Returns:
true if removed, false if not found

clear

public void clear()
Remove all clauses.


size

public int size()
Get the number of sub-predicate clauses.

Returns:
the number of clauses

get

public Predicate get(int idx)
Get the sub-predicate at the given index.

Parameters:
idx - the index to lookup
Returns:
the sub-predicate at the given index

set

public void set(Predicate p)
Set the given predicate to be the only clause of thie composite.

Parameters:
p - the new sole sub-predicate clause

set

public void set(Predicate[] p)
Set the given predicates to be the clauses of thie composite.

Parameters:
p - the new sub-predicate clauses

getSubPredicate

public Predicate getSubPredicate(Predicate p)
Get a predicate instance just like this one but without the given predicate as a clause.

Parameters:
p - the predicate clause to ignore
Returns:
a clone of this predicate, only without the input predicate

visit

public void visit(ExpressionVisitor v)
Description copied from interface: Expression
Passes the visitor through this expression and any sub expressions

Specified by:
visit in interface Expression
Overrides:
visit in class AbstractExpression
Parameters:
v - the ExpressionVisitor
See Also:
Expression.visit(prefuse.data.expression.ExpressionVisitor)

addChildListeners

protected void addChildListeners()
Description copied from class: AbstractExpression
Add child listeners to catch and propagate sub-expression updates.

Overrides:
addChildListeners in class AbstractExpression
See Also:
AbstractExpression.addChildListeners()

removeChildListeners

protected void removeChildListeners()
Description copied from class: AbstractExpression
Remove child listeners for sub-expression updates.

Overrides:
removeChildListeners in class AbstractExpression
See Also:
AbstractExpression.removeChildListeners()

toString

protected java.lang.String toString(java.lang.String op)
Return a String representation of this predicate.

Parameters:
op - a String describing the operation this Predicate performs
Returns:
a String representing this Expression


Copyright © 2007 Regents of the University of California