org.rubato.base
Class Repository

java.lang.Object
  extended by java.util.Observable
      extended by org.rubato.base.Repository
All Implemented Interfaces:
RubatoDictionary

public class Repository
extends java.util.Observable
implements RubatoDictionary

A repository of forms and denotators, retrievable by their names. There is a global repository, that should contain all forms and named denotators used troughout the Rubato system.

Author:
Gérard Milmeister

Method Summary
 ColimitForm autogenColimitForm(java.util.ArrayList<Form> factors)
          Returns a colimit form with the given factors.
 LimitForm autogenLimitForm(java.util.ArrayList<Form> factors)
          Returns a limit form with the given factors.
 ListForm autogenListForm(Form baseForm)
          Returns a list form with the given base form.
 PowerForm autogenPowerForm(Form baseForm)
          Returns a power form with the given base form.
 SimpleForm autogenSimpleForm(Module module)
          Returns a simple form with the given module.
 void clear()
          Removes all content from the repository.
 void display()
          Prints a tabular representation of the repository on stdout.
 void display(java.io.PrintStream out)
          Prints a tabular representation of the repository.
 NameEntry getCurrentNamespace()
           
 Denotator getDenotator(NameDenotator name)
          Returns denotator with the given name if it exists, otherwise null.
 Denotator getDenotator(NameEntry name)
          Returns denotator with the given name if it exists, otherwise null.
 Denotator getDenotator(java.lang.String name)
          Returns denotator with the given name if it exists, otherwise null.
 java.util.List<Denotator> getDenotators()
          Returns a list of all denotators.
 Form getForm(NameDenotator name)
          Returns the form with the given name if it exists, otherwise null.
 Form getForm(NameEntry name)
          Returns the form with the given name if it exists, otherwise null.
 Form getForm(java.lang.String name)
          Returns the form with the given name if it exists, otherwise null.
 java.util.List<Form> getForms()
          Returns a list of all forms.
 Module getModule(java.lang.String name)
          Returns the module for the given name.
 ModuleElement getModuleElement(java.lang.String name)
          Returns the module element for the given name.
 java.util.List<java.lang.String> getModuleElementNames()
           
 ModuleMorphism getModuleMorphism(java.lang.String name)
          Returns the module morphism for the given name.
 java.util.List<java.lang.String> getModuleMorphismNames()
           
 java.util.List<java.lang.String> getModuleMorphismNames(Module domain, Module codomain)
           
 java.util.List<java.lang.String> getModuleNames()
           
 java.lang.String getSchemeCode()
          Returns the Scheme code.
 Env getSchemeEnvironment()
          Returns the system Scheme environment.
 void initGlobalRepository()
           
 boolean isBuiltin(Denotator denotator)
          Returns true iff the given denotator is a builtin.
 boolean isBuiltin(Form form)
          Returns true iff the given form is a builtin.
 boolean register(java.util.Collection<Form> formSet, java.util.Collection<Denotator> denotatorSet)
          Registers a collection of forms and a collection of denotators.
 Denotator register(Denotator d)
          Registers a denotator with repository.
 Form register(Form form)
          Registers a form with repository.
 Form register(Form form, boolean builtin)
          Registers a form.
 Denotator registerBuiltin(Denotator denotator)
          Registers a denotator as builtin with repository.
 Form registerBuiltin(Form form)
          Registers a form as builtin with repository.
 void registerBuiltinModule(java.lang.String name, Module module)
           
 void registerDenotexFile(java.lang.String filename)
           
 void registerDenotexResource(java.lang.String denotex)
           
 void registerModule(java.lang.String name, Module module)
           
 void registerModuleElement(java.lang.String name, ModuleElement element)
           
 void registerModuleMorphism(java.lang.String name, ModuleMorphism morphism)
           
 boolean registerXML(java.io.Reader reader)
          Registers the objects in the XML file of the reader.
 boolean registerXMLFile(java.lang.String filename)
          Registers the objects in the XML file with the specified file name.
 void removeDenotator(Denotator d)
          Removes the given denotator from the repository.
 void removeDenotator(NameDenotator name)
          Remove the denotator with the given name from the repository.
 void removeForm(Form form)
          Removes the given form from the repository.
 void removeForm(NameDenotator name)
          Removes the form with given name in the repository.
 void rollback()
          Removes all temporary forms and denotators from the repository.
 void setNamespace(NameEntry ns)
           
 java.lang.String setSchemeCode(java.lang.String s)
          Sets the Scheme code.
static Repository systemRepository()
          Returns the global system-wide repository.
 void toXML(XMLWriter writer)
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

register

public Form register(Form form)
Registers a form with repository. Performs a rollback, if a different form already exists with the same name.

Returns:
the form in the repository

registerBuiltin

public Form registerBuiltin(Form form)
Registers a form as builtin with repository.

Returns:
the form in the repository

isBuiltin

public boolean isBuiltin(Form form)
Returns true iff the given form is a builtin.


register

public Denotator register(Denotator d)
Registers a denotator with repository.

Parameters:
d - register d only if it has a non-null name
Returns:
the registered denotator

registerBuiltin

public Denotator registerBuiltin(Denotator denotator)
Registers a denotator as builtin with repository.

Returns:
the denotator in the repository

isBuiltin

public boolean isBuiltin(Denotator denotator)
Returns true iff the given denotator is a builtin.


registerXML

public boolean registerXML(java.io.Reader reader)
Registers the objects in the XML file of the reader.

Returns:
true if successful

registerXMLFile

public boolean registerXMLFile(java.lang.String filename)
                        throws java.io.IOException
Registers the objects in the XML file with the specified file name.

Returns:
true if successful
Throws:
java.io.IOException

registerDenotexResource

public void registerDenotexResource(java.lang.String denotex)
                             throws RubatoException
Throws:
RubatoException

registerDenotexFile

public void registerDenotexFile(java.lang.String filename)
                         throws RubatoException,
                                java.io.IOException
Throws:
RubatoException
java.io.IOException

register

public boolean register(java.util.Collection<Form> formSet,
                        java.util.Collection<Denotator> denotatorSet)
Registers a collection of forms and a collection of denotators. Performs a rollback, if the registration fails

Parameters:
formSet - a collection of forms
denotatorSet - a collection of denotators
Returns:
true if the registration succeeds

register

public Form register(Form form,
                     boolean builtin)
Registers a form. Does not perform a rollback, if the registration fails


getForm

public Form getForm(NameDenotator name)
Returns the form with the given name if it exists, otherwise null.


getForm

public Form getForm(java.lang.String name)
Returns the form with the given name if it exists, otherwise null.

Specified by:
getForm in interface RubatoDictionary
Returns:
null if there is no form of the given name

getForm

public Form getForm(NameEntry name)
Returns the form with the given name if it exists, otherwise null.


getForms

public java.util.List<Form> getForms()
Description copied from interface: RubatoDictionary
Returns a list of all forms.

Specified by:
getForms in interface RubatoDictionary

autogenPowerForm

public PowerForm autogenPowerForm(Form baseForm)
Returns a power form with the given base form. The new form is given the name "_Power(baseFormName)".


autogenListForm

public ListForm autogenListForm(Form baseForm)
Returns a list form with the given base form. The new form is given the name "_List(baseFormName)".


autogenLimitForm

public LimitForm autogenLimitForm(java.util.ArrayList<Form> factors)
Returns a limit form with the given factors. The new form is given the name "_Limit(factor0Name,factor1Name,...)".


autogenColimitForm

public ColimitForm autogenColimitForm(java.util.ArrayList<Form> factors)
Returns a colimit form with the given factors. The new form is given the name "_Colimit(factor0Name,factor1Name,...)".


autogenSimpleForm

public SimpleForm autogenSimpleForm(Module module)
Returns a simple form with the given module. The new form is given the name "_Simple(moduleName)".


removeForm

public void removeForm(NameDenotator name)
Removes the form with given name in the repository.


removeForm

public void removeForm(Form form)
Removes the given form from the repository.

Parameters:
form - the form to be removed

removeDenotator

public void removeDenotator(NameDenotator name)
Remove the denotator with the given name from the repository.

Parameters:
name - the name for the denotator to be removed

removeDenotator

public void removeDenotator(Denotator d)
Removes the given denotator from the repository.

Parameters:
d - the denotator to be removed

rollback

public void rollback()
Removes all temporary forms and denotators from the repository.


getSchemeEnvironment

public Env getSchemeEnvironment()
Returns the system Scheme environment.


getSchemeCode

public java.lang.String getSchemeCode()
Returns the Scheme code.


setSchemeCode

public java.lang.String setSchemeCode(java.lang.String s)
Sets the Scheme code.

Returns:
error as a string, and null if no error occurred

clear

public void clear()
Removes all content from the repository.


getDenotator

public Denotator getDenotator(NameDenotator name)
Returns denotator with the given name if it exists, otherwise null.

Parameters:
name - the name of the denotator to be returned

getDenotator

public Denotator getDenotator(NameEntry name)
Returns denotator with the given name if it exists, otherwise null.

Parameters:
name - the name of the denotator to be returned

getDenotator

public Denotator getDenotator(java.lang.String name)
Returns denotator with the given name if it exists, otherwise null.

Specified by:
getDenotator in interface RubatoDictionary
Parameters:
name - the name of the denotator to be returned
Returns:
null if there is no denotator of the given name

getDenotators

public java.util.List<Denotator> getDenotators()
Description copied from interface: RubatoDictionary
Returns a list of all denotators.

Specified by:
getDenotators in interface RubatoDictionary

setNamespace

public void setNamespace(NameEntry ns)

getCurrentNamespace

public NameEntry getCurrentNamespace()

registerBuiltinModule

public void registerBuiltinModule(java.lang.String name,
                                  Module module)

registerModule

public void registerModule(java.lang.String name,
                           Module module)

getModule

public Module getModule(java.lang.String name)
Description copied from interface: RubatoDictionary
Returns the module for the given name.

Specified by:
getModule in interface RubatoDictionary
Returns:
null if there is no module of the given name

getModuleNames

public java.util.List<java.lang.String> getModuleNames()

registerModuleElement

public void registerModuleElement(java.lang.String name,
                                  ModuleElement element)

getModuleElement

public ModuleElement getModuleElement(java.lang.String name)
Description copied from interface: RubatoDictionary
Returns the module element for the given name.

Specified by:
getModuleElement in interface RubatoDictionary
Returns:
null if there is no module element of the given name

getModuleElementNames

public java.util.List<java.lang.String> getModuleElementNames()

registerModuleMorphism

public void registerModuleMorphism(java.lang.String name,
                                   ModuleMorphism morphism)

getModuleMorphism

public ModuleMorphism getModuleMorphism(java.lang.String name)
Description copied from interface: RubatoDictionary
Returns the module morphism for the given name.

Specified by:
getModuleMorphism in interface RubatoDictionary
Returns:
null if there is no module morphism of the given name

getModuleMorphismNames

public java.util.List<java.lang.String> getModuleMorphismNames()

getModuleMorphismNames

public java.util.List<java.lang.String> getModuleMorphismNames(Module domain,
                                                               Module codomain)

toXML

public void toXML(XMLWriter writer)

display

public void display()
Prints a tabular representation of the repository on stdout.


display

public void display(java.io.PrintStream out)
Prints a tabular representation of the repository.

Parameters:
out - print to this PrintStream

systemRepository

public static Repository systemRepository()
Returns the global system-wide repository.


initGlobalRepository

public void initGlobalRepository()