EDU.utwente.CoCompose.translate
Class Implementation

java.lang.Object
  extended byEDU.utwente.CoCompose.translate.Implementation
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener

public class Implementation
extends java.lang.Object
implements java.beans.PropertyChangeListener

Represents an implementation for a Concept. It links to a file containing the actual implementation, such as a Java source file.

Version:
0.1.21, 6 April 2004
Author:
Dennis Wagelaar

Constructor Summary
Implementation()
          Constructs an Implementation.
 
Method Summary
 void accept(ModelVisitor visitor)
          Accepts a ModelVisitor.
 void adapt(java.util.Hashtable adapted)
          Adapts the concept data used in the implementation (content & constraints).
 void addConstraint(AbstractConcept concept, java.util.Collection conceptForms)
          Adds a constraint for a concept referred to in this implementation.
 void clearConstraints()
          Clears all constraints.
protected  void constraintsToXML(org.xml.sax.helpers.DefaultHandler handler)
          Creates the constraints table XML using a SAX DefaultHandler.
 void copyAttributes(Implementation fromImplementation)
          Copies the attributes from the given implementation to self.
 void copyConstraints(Implementation fromImplementation)
          Copies the constraints from the given implementation.
static java.beans.PropertyChangeEvent CreateRenameEvent(AbstractConcept source, AbstractConcept target)
          Creates a constrained concept renaming event for this.
protected  AbstractConcept findLocalConcept(AbstractConcept fromConcept, Model inModel, AbstractConcept instantiatedBy)
          Attempts to find the local equivalent/copy of the given concept in the given model.
 Concept getConcept()
          Gets the concept to which this implementation belongs.
 java.lang.String getConceptForm()
          Gets the target language construct form for this implementation.
 java.util.Hashtable getConstraints()
          Gets the concept form constraints table.
 java.lang.String getContent()
          Gets the implementation content.
 java.lang.String getContentWithoutTags()
          Gets the implementation content without concept tags.
 java.lang.String getLanguage()
          Gets the language in which this implementation is expressed.
 Model getModel()
          Gets the model for this implementation from the concept.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method gets called when a property is changed.
 void removeConstraint(AbstractConcept concept)
          Removes the constraint referring to the given concept.
protected  AbstractConcept searchLocalConcept(AbstractConcept fromConcept, Model inModel, AbstractConcept instantiatedBy)
          Searches the local equivalent/copy of the given concept in the given model.
 void setConcept(Concept concept)
          Sets the concept to which this implementation belongs.
 void setConceptForm(java.lang.String conceptForm)
          Sets the target language construct form for this implementation.
 void setContent(java.lang.String content)
          Sets the implementation content.
 void setLanguage(java.lang.String language)
          Sets the language in which this implementation is expressed.
protected  java.lang.String stringReplace(java.lang.String source, java.util.Hashtable nameTable, boolean withoutTag)
          Replaces names in source string and returns the new string.
 void toXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from this object using a SAX DefaultHandler.
protected  void unsubscribeAll()
          Unsubscribes from all AbstractConcepts on which we depend.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Implementation

public Implementation()
Constructs an Implementation.

Method Detail

constraintsToXML

protected void constraintsToXML(org.xml.sax.helpers.DefaultHandler handler)
                         throws org.xml.sax.SAXException
Creates the constraints table XML using a SAX DefaultHandler.

Parameters:
handler - the SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - - if an XML handler error occurs.

stringReplace

protected java.lang.String stringReplace(java.lang.String source,
                                         java.util.Hashtable nameTable,
                                         boolean withoutTag)
Replaces names in source string and returns the new string. Replaces only keywords, which are enclosed in <>.

Parameters:
source - the source string.
nameTable - the Hashtable<String |-> String> of old names mapping to new names.
withoutTag - if true, the new names will be put in without tag signs.
Returns:
the new string.

unsubscribeAll

protected void unsubscribeAll()
Unsubscribes from all AbstractConcepts on which we depend.


findLocalConcept

protected AbstractConcept findLocalConcept(AbstractConcept fromConcept,
                                           Model inModel,
                                           AbstractConcept instantiatedBy)
                                    throws CoComposeException
Attempts to find the local equivalent/copy of the given concept in the given model. This method checks what kind of AbstractConcept to look for and uses appropriate methods to find it.

Parameters:
fromConcept - the concept to look for
inModel - the model to look in
instantiatedBy - the local concept must be instantiated by this concept.
Returns:
the local concept equivalent
Throws:
CoComposeException - - if more than one concept dependency was found

searchLocalConcept

protected AbstractConcept searchLocalConcept(AbstractConcept fromConcept,
                                             Model inModel,
                                             AbstractConcept instantiatedBy)
                                      throws CoComposeException
Searches the local equivalent/copy of the given concept in the given model.

Parameters:
fromConcept - the concept to look for
inModel - the model to look in
instantiatedBy - the local concept must be instantiated by this concept
Returns:
the local concept equivalent or null
Throws:
CoComposeException - - if more than one concept dependency was found

CreateRenameEvent

public static java.beans.PropertyChangeEvent CreateRenameEvent(AbstractConcept source,
                                                               AbstractConcept target)
Creates a constrained concept renaming event for this.

Parameters:
source - the old constrained concept
target - the new constrained concept
Returns:
the renaming event

getLanguage

public java.lang.String getLanguage()
Gets the language in which this implementation is expressed.

Returns:
the implementation language.

setLanguage

public void setLanguage(java.lang.String language)
Sets the language in which this implementation is expressed.

Parameters:
language - the implementation language.

getContent

public java.lang.String getContent()
Gets the implementation content.

Returns:
the implementation content.

getContentWithoutTags

public java.lang.String getContentWithoutTags()
Gets the implementation content without concept tags.

Returns:
the implementation content without tag symbols.

setContent

public void setContent(java.lang.String content)
Sets the implementation content.

Parameters:
content - the implementation content.

getConceptForm

public java.lang.String getConceptForm()
Gets the target language construct form for this implementation.

Returns:
the target language construct form.

setConceptForm

public void setConceptForm(java.lang.String conceptForm)
Sets the target language construct form for this implementation.

Parameters:
conceptForm - the target language construct form.

getConcept

public Concept getConcept()
Gets the concept to which this implementation belongs.

Returns:
the concept that owns this implementation.

setConcept

public void setConcept(Concept concept)
Sets the concept to which this implementation belongs.

Parameters:
concept - the concept that owns this implementation.

addConstraint

public void addConstraint(AbstractConcept concept,
                          java.util.Collection conceptForms)
Adds a constraint for a concept referred to in this implementation. Semantics: <concept> |-> (<conceptForm> | <conceptForm> in <conceptForms>)

Parameters:
concept - the concept to which the constraints refers.
conceptForms - the Collection<String> of concepts form of which one is assumed for the given concept (the actual constraint).

removeConstraint

public void removeConstraint(AbstractConcept concept)
Removes the constraint referring to the given concept.

Parameters:
concept - the concept for which to remove the constraint.

clearConstraints

public void clearConstraints()
Clears all constraints.


getConstraints

public java.util.Hashtable getConstraints()
Gets the concept form constraints table.

Returns:
a copy of the constraints table. Structure: Hashtable<AbstractConcept |-> Collection<conceptForm:String>>

getModel

public Model getModel()
Gets the model for this implementation from the concept.

Returns:
the model for this implementation's concept or null.

copyAttributes

public void copyAttributes(Implementation fromImplementation)
Copies the attributes from the given implementation to self. It doesn't copy the concept link or concept constraints.

Parameters:
fromImplementation - the implementation to copy from.

copyConstraints

public void copyConstraints(Implementation fromImplementation)
                     throws CoComposeException
Copies the constraints from the given implementation.

Parameters:
fromImplementation - the implementation to copy from.
Throws:
CoComposeException - - if a source concept for a constraint could not be found in the current model.

toXML

public void toXML(org.xml.sax.helpers.DefaultHandler handler)
           throws org.xml.sax.SAXException
Create XML from this object using a SAX DefaultHandler.

Parameters:
handler - the SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - - if an XML handler error occurs.

adapt

public void adapt(java.util.Hashtable adapted)
Adapts the concept data used in the implementation (content & constraints).

Parameters:
adapted - A table of the form: Hashtable<oldConcept:Concept |-> newConcept:Concept>

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called when a property is changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - the event describing which property from what object has been changed.

accept

public void accept(ModelVisitor visitor)
            throws CoComposeException
Accepts a ModelVisitor.

Parameters:
visitor - the visitor object to accept.
Throws:
CoComposeException - - if visiting operation failed.