org.grinvin.invariants
Class InvariantManager
java.lang.Object
org.grinvin.invariants.InvariantManager
public class InvariantManager
extends java.lang.Object
Keeps track of relations between invariants and invariant computers.
Handles the mapping between an invariant and its corresponding identifier, and between
invariants and their computer.
This is a singleton class. The single shared object of this class can be retreived
using the method
getInstance()
.
InvariantFactory> getFactories
public Map getFactories()
addListener
public void addListener(InvariantManagerListener listener)
Add a listener which will be notified whenever a new invariant
or factory is introduced into the system. As with Swing listeners,
the listener most recently registered shall always be notified first.
getDefinitionPath
public String getDefinitionPath(String id)
Return the path of the definition file for the invariant or the factory
with the given ID. (Used by the help subsystem.)
getIds
public List getIds()
Return a list of all ids for both factories and parameterless invariants.
getInstance
public static InvariantManager getInstance()
Get the singleton instance of this class
- the single shared instance of this class
getInvariantComputerFactoryFor
public InvariantComputerFactory getInvariantComputerFactoryFor(String id)
Return the computer factory that corresponds to the given invariant factory.
getInvariantComputerFor
public InvariantComputer getInvariantComputerFor(Invariant invariant)
Return the invariant computer which can be used to compute values for
the given invariant or null when no computer exists
invariant
- the Invariant
for which you want a computer
getInvariantForComputer
public Invariant getInvariantForComputer(InvariantComputer computer)
Return the invariant which is computed by the given computer.
Equivalent to getInvariant (computer.getInvariantId())
but does not throw an exception.
getLocalClassLoader
public LocalClassLoader getLocalClassLoader()
Local class loader which is used to retrieve invariants and
invariant computers.
getStandardInvariantNodes
public Iterable getStandardInvariantNodes()
Return the 'standard' list of invariant nodes (mostly groups)
that come pre-installed with GrInvIn.
loadInvariant
public Invariant loadInvariant(String id,
String path)
throws UnknownInvariantException
Load an invariant and register it with this manager.
id
- Identifier for this invariantpath
- classpath relative path for the definition file of
this invariant.
loadInvariantComputer
public void loadInvariantComputer(File file)
throws IllegalInvariantComputerException
Add a local invariant computer from file. If this is a computer
for a new invariant, information on this invariant is searched
for in the local class path. Can be used for simple invariants
and for invariant factories.
loadInvariantFactory
public InvariantFactory loadInvariantFactory(String id,
String path)
throws UnknownInvariantException
Load an invariant factory and register it with this manager.
id
- Identifier for this invariant factorypath
- classpath relative path for the definition file of
this invariant factory.