edu.buffalo.fs7.mathlib
Class VarAuthority

java.lang.Object
  |
  +--edu.buffalo.fs7.mathlib.VarAuthority

public class VarAuthority
extends java.lang.Object

Class providing a filter and grouping mechanism for variables kept by a Mathlib object. It can for example be used to obtain all variables of a certain type, e.g. gates. But it also provides more complex filter rules, such as dimension constraints, or boolean expressions. For details see MathObjectConstraints.

See Also:
MathObjectConstraints, Mathlib

Field Summary
protected  java.util.Hashtable categories
          holds registered categories
protected  boolean exclusiveMode
          exclusive mode
protected  Mathlib mathlib
          holds a reference to the Mathlib object
protected  java.util.Vector priority
          keeps record on priority of groups (first come first serve)
protected  java.util.Vector varsAssigned
          holds references to variables already sorted into a special group (exclusive mode)
 
Constructor Summary
VarAuthority(Mathlib mathlib, boolean exclusiveMode)
          creates a VarAuthority object for a certain Mathlib object.
 
Method Summary
 java.util.Enumeration getCategories()
          returns the registered categories
 java.util.Enumeration getElementsInCategory(java.lang.String category)
          returns a enumeration of variable names which match the given category.
 boolean isObjectInCategory(java.lang.String var, java.lang.String subCategory, java.lang.String category)
          checks whether the given object (given by varibale & subCategory) matches the constraints of category
 void registerCategory(java.lang.String category, MathObjectConstraints constraints)
          registers a category
 void unregisterCategory(java.lang.String category)
          removes a category
 java.lang.String whichCategory(java.lang.String variable, java.lang.String subCategory)
          returns the first matching category for the given variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mathlib

protected Mathlib mathlib
holds a reference to the Mathlib object

categories

protected java.util.Hashtable categories
holds registered categories

varsAssigned

protected java.util.Vector varsAssigned
holds references to variables already sorted into a special group (exclusive mode)

exclusiveMode

protected boolean exclusiveMode
exclusive mode

priority

protected java.util.Vector priority
keeps record on priority of groups (first come first serve)
Constructor Detail

VarAuthority

public VarAuthority(Mathlib mathlib,
                    boolean exclusiveMode)
creates a VarAuthority object for a certain Mathlib object. The exclusive mode allows variables to be in only one category (membership decided by priority of groups).
Parameters:
mathlib - Mathlib object which keeps the variables
exclusiveMode - multiple group membership
Method Detail

getElementsInCategory

public java.util.Enumeration getElementsInCategory(java.lang.String category)
                                            throws java.lang.IllegalArgumentException
returns a enumeration of variable names which match the given category.
Parameters:
category - category name

isObjectInCategory

public boolean isObjectInCategory(java.lang.String var,
                                  java.lang.String subCategory,
                                  java.lang.String category)
checks whether the given object (given by varibale & subCategory) matches the constraints of category
Parameters:
variable - name of the MathObject
subCategory - subcategory of the MathObject
category - category to check against
Returns:
true if object fits into the category

whichCategory

public java.lang.String whichCategory(java.lang.String variable,
                                      java.lang.String subCategory)
returns the first matching category for the given variable.
Returns:
category name or null if no match

getCategories

public java.util.Enumeration getCategories()
returns the registered categories

registerCategory

public void registerCategory(java.lang.String category,
                             MathObjectConstraints constraints)
registers a category

unregisterCategory

public void unregisterCategory(java.lang.String category)
removes a category