org.rubato.math.yoneda
Class Denotator

java.lang.Object
  extended by org.rubato.math.yoneda.AbstractConnectableYoneda
      extended by org.rubato.math.yoneda.Denotator
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Denotator>, java.lang.Iterable<Denotator>, Connectable, Yoneda
Direct Known Subclasses:
ColimitDenotator, DenotatorReference, LimitDenotator, ListDenotator, PowerDenotator, SimpleDenotator

public abstract class Denotator
extends AbstractConnectableYoneda
implements java.lang.Comparable<Denotator>, java.lang.Iterable<Denotator>

Abstract base class for denotators.

Author:
Gérard Milmeister, Stefan Müller, Stefan Göller
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.rubato.math.yoneda.Yoneda
COLIMIT, LIMIT, LIST, POWER, SIMPLE
 
Method Summary
abstract  Denotator at(ModuleElement element)
          If not null-addressed returns a new denotator evaluated at address element.
 Denotator atNull()
          Returns denotator evaluated at null address.
abstract  Denotator changeAddress(Module newAddress)
          Makes an address change.
abstract  Denotator changeAddress(ModuleMorphism morphism)
          Makes an address change using a module morphism.
abstract  boolean check()
          Returns true iff this denotator is consistent.
 java.lang.Object clone()
          The cloning of a denotator is the same as copying it.
abstract  int compareTo(Denotator object)
           
abstract  Denotator copy()
          Returns a deep copy of this denotator.
 void display()
          Print denotator to stdout.
 void display(java.io.PrintStream out)
          Print denotator to a stream.
abstract  boolean equals(java.lang.Object object)
          Checks for equality.
 boolean formEquals(Denotator other)
          Returns true iff this denotator has the same form as the other denotator.
 Denotator get(int[] path)
          Retrieves a denotator by traversing the tree rooted at this denotator.
 Module getAddress()
          Returns the address of the denotator.
 Morphism getCoordinate()
          Returns the coordinate of the denotator.
 java.util.LinkedList<Denotator> getDependencies()
          Returns a list of the named denotators that this denotator depends on.
 ModuleElement getElement(int[] path)
          Retrieves the module element by traversing the denotator tree.
 Form getForm()
          Returns the form of the denotator.
 Morphism getFrameCoordinate()
          Returns the frame coordinate of the denotator.
 ModuleMorphism getModuleMorphism(int[] path)
          Retrieves the module morphism by traversing the denotator tree.
 NameDenotator getName()
          Returns the name of the denotator as a denotator.
 java.lang.String getNameString()
          Returns the name of the denotator converted to a string.
abstract  int getType()
          Returns the type of the denotator.
 boolean hasForm(Form f)
          Checks if the form of the denotator matches f.
 int hashCode()
          Returns a hash code for this denotator.
abstract  boolean isConstant()
          Returns true iff this is ultimately a constant denotator, regardless of its address.
abstract  java.util.Iterator<Denotator> iterator()
          Returns an iterator over the coordinates of this denotator.
 Denotator map(int[] path, ModuleMorphism morphism)
          Maps this denotator using the given morphism along the specified path.
 int nameCompareTo(Denotator d)
          Compares the names of two denotators.
abstract  Denotator namedCopy(NameDenotator nameDeno)
          Makes a shallow copy this denotator and gives it the specified name.
 boolean nameEquals(Denotator other)
          Returns true iff this denotator has the same name as the other denotator.
 boolean nullAddressed()
          Return true iff denotator is null-addressed.
 Denotator replace(int[] path, Denotator d)
          Returns a denotator by replacing the denotator at the given path in this denotator with d.
 boolean resolveReferences(RubatoDictionary dict)
          Replaces reference denotators by respective name denotators.
 void setName(NameDenotator name)
          Sets the name of the denotator as a NameDenotator.
 void setNameString(java.lang.String nameString)
          Sets the name of the denotator as a string.
 java.lang.String toString()
          Returns a string representation of this denotator.
abstract  void toXML(XMLWriter writer)
           
 
Methods inherited from class org.rubato.math.yoneda.AbstractConnectableYoneda
getConnector, setConnector
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

namedCopy

public abstract Denotator namedCopy(NameDenotator nameDeno)
Makes a shallow copy this denotator and gives it the specified name.


getName

public NameDenotator getName()
Returns the name of the denotator as a denotator. A null name indicates an anonymous denotator.


getNameString

public java.lang.String getNameString()
Returns the name of the denotator converted to a string. An empty string indicates an anonymous denotator.


setName

public final void setName(NameDenotator name)
Sets the name of the denotator as a NameDenotator. To make an anonymous denotator, pass a null name.


setNameString

public final void setNameString(java.lang.String nameString)
Sets the name of the denotator as a string. To make an anonymous denotator, pass an empty string.


getForm

public Form getForm()
Returns the form of the denotator.


getType

public abstract int getType()
Returns the type of the denotator.

Returns:
type as an integer

getCoordinate

public final Morphism getCoordinate()
Returns the coordinate of the denotator.


getFrameCoordinate

public Morphism getFrameCoordinate()
Returns the frame coordinate of the denotator.


iterator

public abstract java.util.Iterator<Denotator> iterator()
Returns an iterator over the coordinates of this denotator.

Specified by:
iterator in interface java.lang.Iterable<Denotator>

at

public abstract Denotator at(ModuleElement element)
                      throws MappingException
If not null-addressed returns a new denotator evaluated at address element. If null-addressed, returns self.

Parameters:
element - address
Returns:
evaluated denotator
Throws:
MappingException - if evaluation fails

atNull

public final Denotator atNull()
Returns denotator evaluated at null address.

Returns:
evaluated denotator

getAddress

public final Module getAddress()
Returns the address of the denotator.


nullAddressed

public final boolean nullAddressed()
Return true iff denotator is null-addressed.


changeAddress

public abstract Denotator changeAddress(Module newAddress)
Makes an address change.

Parameters:
newAddress - the new address of the denotator
Returns:
a copy of this denotator with the new address or null if address change fails

changeAddress

public abstract Denotator changeAddress(ModuleMorphism morphism)
Makes an address change using a module morphism.

Parameters:
morphism - the address changing morphism
Returns:
a copy of this denotator with the new address or null if address change fails

get

public final Denotator get(int[] path)
                    throws RubatoException
Retrieves a denotator by traversing the tree rooted at this denotator.

Returns:
null if denotator could not be retrieved along the path
Throws:
RubatoException

replace

public final Denotator replace(int[] path,
                               Denotator d)
                        throws RubatoException
Returns a denotator by replacing the denotator at the given path in this denotator with d.

Parameters:
path - the path at the end of which the denotator is replaced
d - the denotator to put at the path
Throws:
RubatoException - if the specified denotator is of the wrong form or address

map

public final Denotator map(int[] path,
                           ModuleMorphism morphism)
                    throws RubatoException
Maps this denotator using the given morphism along the specified path.

Throws:
RubatoException

getElement

public final ModuleElement getElement(int[] path)
                               throws RubatoException
Retrieves the module element by traversing the denotator tree. A denotator of type simple must be reached somewhere along the path.

Returns:
null if element could not be retrieved along the path
Throws:
RubatoException

getModuleMorphism

public final ModuleMorphism getModuleMorphism(int[] path)
                                       throws RubatoException
Retrieves the module morphism by traversing the denotator tree. A denotator of type simple must be reached somewhere along the path.

Returns:
null if morphism could not be retrieved along the path
Throws:
RubatoException

compareTo

public abstract int compareTo(Denotator object)
Specified by:
compareTo in interface java.lang.Comparable<Denotator>

nameCompareTo

public int nameCompareTo(Denotator d)
Compares the names of two denotators. The comparison is string comparison, where a null name is equal to another null name, otherwise less than every other name.


equals

public abstract boolean equals(java.lang.Object object)
Checks for equality.

Overrides:
equals in class java.lang.Object

nameEquals

public boolean nameEquals(Denotator other)
Returns true iff this denotator has the same name as the other denotator.


formEquals

public boolean formEquals(Denotator other)
Returns true iff this denotator has the same form as the other denotator.


isConstant

public abstract boolean isConstant()
Returns true iff this is ultimately a constant denotator, regardless of its address.


hasForm

public final boolean hasForm(Form f)
Checks if the form of the denotator matches f. A form matches f if they are equal.

Returns:
boolean true iff form matches f

clone

public final java.lang.Object clone()
The cloning of a denotator is the same as copying it.

Specified by:
clone in interface Yoneda
Specified by:
clone in class AbstractConnectableYoneda

copy

public abstract Denotator copy()
Returns a deep copy of this denotator. The copy is given the same name as the original.


check

public abstract boolean check()
Returns true iff this denotator is consistent. This can be used in assertions to validate a denotator, for example if its constructed using unsafe methods or changed inplace.


hashCode

public int hashCode()
Returns a hash code for this denotator.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this denotator. This string is not parseable and does not contain all information. It is only meant for information purposes.

Overrides:
toString in class java.lang.Object

toXML

public abstract void toXML(XMLWriter writer)

display

public final void display()
Print denotator to stdout.


display

public final void display(java.io.PrintStream out)
Print denotator to a stream.

Parameters:
out - the stream to print to

getDependencies

public final java.util.LinkedList<Denotator> getDependencies()
Returns a list of the named denotators that this denotator depends on. A named denotator always depends on itself.


resolveReferences

public boolean resolveReferences(RubatoDictionary dict)
Replaces reference denotators by respective name denotators.

Parameters:
dict - contains the lookup table
Returns:
true if all references have been resolved