org.fopps.model
Class Constraint

java.lang.Object
  |
  +--org.fopps.model.AbstractItem
        |
        +--org.fopps.model.Relation
              |
              +--org.fopps.model.Constraint
Direct Known Subclasses:
ConfigurationConstraint, FeatureConstraint

public abstract class Constraint
extends Relation

Constraint is the base class for all constraints. A constraint is a special relation with an additional attibute 'type'. Currently a constraint may be an 'exclude' or an 'include' constraint. 'A exclude B' means, that A must not be selected, if B is selected. 'A include B' means, that A requires also the selection of B.

Please note, that these rules are not reflexive: 'A includes B' does not imply 'B includes A' (same for exclude). In this case you have to define a seperate constraint.

Convention: The first part of the constrained will also called the constraint source, the second part is the constraint destination, because B plays a passive role. For the above examples, A is the source and B the destination.


Field Summary
 
Fields inherited from class org.fopps.model.Relation
from, to
 
Fields inherited from class org.fopps.model.AbstractItem
ADDED_EVENT, CHANGE_EVENT, name, REMOVED_EVENT
 
Constructor Summary
Constraint(AbstractItem pFrom, AbstractItem pTo, ConstraintType pConstraintType)
          Creates a new constraint
 
Method Summary
abstract  boolean check()
          Checks, if constraint is met by current configuration
 ConstraintType getConstraintType()
           
 boolean isValid()
          Checks if relation is valid.
protected  void saveUndoOnDisconnect()
          Called while disconnecting.
 void setConstraintType(ConstraintType pConstraintType)
           
 void toggleConstraintType()
          Toggle constraint type
 java.lang.String toString()
           
 
Methods inherited from class org.fopps.model.Relation
accept, disconnect, getFrom, getTo, isGhost, loopAllowed, setAllowLoop, setFrom, setGhost, setTo
 
Methods inherited from class org.fopps.model.AbstractItem
addIncoming, addListener, addOutgoing, commitGhostRelations, containsType, copyAttributes, delete, filterElements, fireItemAdded, fireItemChanged, fireItemRemoved, getConstraints, getDescription, getIncoming, getIncomingConstraints, getListeners, getName, getOutgoing, getOutgoingConstraints, getRelationTo, hasConstraints, isBlockEvents, isConnectedWith, notifyListeners, removeAllConstraints, removeAllIncoming, removeAllListener, removeAllOutgoing, removeAllRelations, removeGhostRelations, removeIncoming, removeListener, removeOutgoing, removeRelationTo, setBlockEvents, setDescription, setIncoming, setName, setOutgoing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constraint

public Constraint(AbstractItem pFrom,
                  AbstractItem pTo,
                  ConstraintType pConstraintType)
           throws InvalidRelationException
Creates a new constraint

Parameters:
pFrom - Constraint source
Method Detail

getConstraintType

public ConstraintType getConstraintType()

toggleConstraintType

public void toggleConstraintType()
Toggle constraint type


setConstraintType

public void setConstraintType(ConstraintType pConstraintType)

isValid

public boolean isValid()
Description copied from class: Relation
Checks if relation is valid. This is true, if both sides are not null and have the correct type

Overrides:
isValid in class Relation
See Also:
Relation.accept(AbstractItem)

saveUndoOnDisconnect

protected void saveUndoOnDisconnect()
Called while disconnecting. Subclasses should override this method to save undo information of additional fields

Overrides:
saveUndoOnDisconnect in class Relation

check

public abstract boolean check()
Checks, if constraint is met by current configuration

Returns:
true, if constraint is valid

toString

public java.lang.String toString()
Overrides:
toString in class Relation


Fopps 0.19 - Copyright © 2002 Oliver Wieland. All Rights Reserved.