de.fzi.kadmos.api
Class ForwardingAlignment

java.lang.Object
  extended by de.fzi.kadmos.api.ForwardingAlignment
All Implemented Interfaces:
Alignment, Evaluable, Serializable, Cloneable, Iterable<Correspondence<? extends OWLEntity>>

public abstract class ForwardingAlignment
extends Object
implements Alignment, Serializable

Abstract wrapper class for an Alignment following the Decorator pattern. The class can be extended and additional functionality can be added without accidentally changing the behaviour of the wrapped alignment implementation.

Note that the class is serialisable, thus extending classes must take care of proper serialisation and deserialisation of extra fields added. Care must also be taken if the wrapped alignment is not serialisable.

Extending classes should override equals as follows:

 public boolean equals( Object other ) {
      if( !(other instanceof MyExtension) )
           return false;
      MyExtension otherAlignment = (MyExtension) other;
      return super.equals( otherAlignment.alignment ) && ...
 }
 
where ... is supposed to perform additional checks regarding the extension.

Extending classes should not forget to override the hashCode function and the clone function.

Since:
1.0.0
Version:
1.3.0
Author:
Juergen Bock
See Also:
Serialized Form

Field Summary
protected  Alignment alignment
          Wrapped alignment object.
protected  HashSet<AlignmentListener> listeners
          Set of change listeners.
 
Constructor Summary
protected ForwardingAlignment(Alignment alignment)
          Creates a new instance that wraps another alignment.
 
Method Summary
 void addCorrespondence(Correspondence<? extends OWLEntity> corr)
          Adds a correspondence to an alignment if possible.
 void attachListener(AlignmentListener listener)
          Registers an AlignmentListener.
 void clear()
          Clears the alignment.
 ForwardingAlignment clone()
          Creates a clone of this alignment.
 boolean contains(Correspondence<? extends OWLEntity> corr)
          Checks if this alignment contains a correspondence with the same entities as the provided correspondence.
 boolean contains(IRI ent1, IRI ent2)
          Checks if a correspondence of two entities specified by their IRIs is part of this alignment.
<T extends OWLEntity>
boolean
contains(T ent1, T ent2)
          Checks if a correspondence of two specified entities is part of this alignment.
 boolean containsEntity1(IRI ent)
          Checks if this alignment contains a correspondence with a first entity specified by an IRI.
 boolean containsEntity1(OWLEntity ent)
          Checks if this alignment contains a correspondence with a specific first entity.
 boolean containsEntity2(IRI ent)
          Checks if this alignment contains a correspondence with a second entity specified by an IRI.
 boolean containsEntity2(OWLEntity ent)
          Checks if this alignment contains a correspondence with a specific second entity.
 void detachListener(AlignmentListener listener)
          Deregisters an AlignmentListener.
 boolean equals(Object other)
          
 Set<Correspondence<? extends OWLEntity>> getCorrespondences()
          Gets the set of correspondences of this alignment.
 Correspondence<? extends OWLEntity> getEntity1Corr(IRI ent)
          Gets the correspondence with a specific entity as entity 1.
<T extends OWLEntity>
Correspondence<T>
getEntity1Corr(T ent)
          Gets the correspondence with a specific entity as entity 1.
 Correspondence<? extends OWLEntity> getEntity2Corr(IRI ent)
          Gets the correspondence with a specific entity as entity 2.
<T extends OWLEntity>
Correspondence<T>
getEntity2Corr(T ent)
          Gets the correspondence with a specific entity as entity 2.
 Correspondence<? extends OWLEntity> getEntityCorr(IRI ent1, IRI ent2)
          Gets the correspondence with specific entities as entity 1 and entity2.
<T extends OWLEntity>
Correspondence<T>
getEntityCorr(T ent1, T ent2)
          Gets the correspondence with specific entities as entity 1 and entity 2.
 OWLOntology getOntology1()
          Gets the first ontology of this alignment.
 OWLOntology getOntology2()
          Gets the second ontology of this alignment.
protected  void guard_attachListener(AlignmentListener listener)
          Guard for the attachListener(AlignmentListener) method.
protected  void guard_detachListener(AlignmentListener listener)
          Guard for the detachListener(AlignmentListener) method.
 int hashCode()
          
 boolean isEmpty()
          Checks, whether this alignment is empty, i.e.
 Iterator<Correspondence<? extends OWLEntity>> iterator()
          
protected  void notifyListeners(AlignmentChangeEvent changeEvent)
          Notifies all registered listeners of the provided AlignmentChangeEvent.
 void removeCorrespondence(Correspondence<? extends OWLEntity> corr)
          Removes a correspondence from this alignment if present.
 int size()
          Gets the size of this alignment.
 String toString()
          
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

alignment

protected Alignment alignment
Wrapped alignment object.


listeners

protected HashSet<AlignmentListener> listeners
Set of change listeners.

Constructor Detail

ForwardingAlignment

protected ForwardingAlignment(Alignment alignment)
Creates a new instance that wraps another alignment.

Parameters:
alignment - The alignment to be wrapped.
Since:
1.0.0
Method Detail

addCorrespondence

public void addCorrespondence(Correspondence<? extends OWLEntity> corr)
                       throws MultiplicityException,
                              IllegalArgumentException,
                              IncompatibleOntologyException
Adds a correspondence to an alignment if possible. Multiplicity of correspondences in an alignment will be assured.

Specified by:
addCorrespondence in interface Alignment
Parameters:
corr - The correspondence to be added.
Throws:
MultiplicityException - if multiplicity of correspondence is violated.
IllegalArgumentException - if the argument is null
IncompatibleOntologyException - if either of the corresponding entities is not contained in the signature of the according aligned ontology.

clear

public void clear()
Clears the alignment. All correspondence references are deleted. References to ontologies are preserved.

Specified by:
clear in interface Alignment

contains

public boolean contains(Correspondence<? extends OWLEntity> corr)
Checks if this alignment contains a correspondence with the same entities as the provided correspondence.

Specified by:
contains in interface Alignment
Parameters:
corr - The correspondence to be checked if it is contained by this alignment.
Returns:
true if this alignment contains a correspondence with the same entities as corr, false otherwise.

contains

public <T extends OWLEntity> boolean contains(T ent1,
                                              T ent2)
Checks if a correspondence of two specified entities is part of this alignment.

Specified by:
contains in interface Alignment
Type Parameters:
T - Type of the entities of correspondence to be checked.
Parameters:
ent1 - Entity 1.
ent2 - Entity 2.
Returns:
true if a correspondence of ent1 and ent2 is part of this alignment, false otherwise.

contains

public boolean contains(IRI ent1,
                        IRI ent2)
Checks if a correspondence of two entities specified by their IRIs is part of this alignment.

Specified by:
contains in interface Alignment
Parameters:
ent1 - IRI of entity 1.
ent2 - IRI of entity 2.
Returns:
true if a correspondence of ent1 and ent2 is part of this alignment, false otherwise.

containsEntity1

public boolean containsEntity1(OWLEntity ent)
Checks if this alignment contains a correspondence with a specific first entity.

Specified by:
containsEntity1 in interface Alignment
Parameters:
ent - Entity to be checked if present as entity 1 in a correspondence in this alignment.
Returns:
true if ent participates as entity 1 of a correspondence in this alignment, false otherwise.

containsEntity1

public boolean containsEntity1(IRI ent)
Checks if this alignment contains a correspondence with a first entity specified by an IRI.

Specified by:
containsEntity1 in interface Alignment
Parameters:
ent - IRI of entity to be checked if present as entity 1 in a correspondence in this alignment.
Returns:
true if ent participates as entity 1 of a correspondence in this alignment, false otherwise.

containsEntity2

public boolean containsEntity2(OWLEntity ent)
Checks if this alignment contains a correspondence with a specific second entity.

Specified by:
containsEntity2 in interface Alignment
Parameters:
ent - Entity to be checked if present as entity 2 in a correspondence in this alignment.
Returns:
true if ent participates as entity 2 of a correspondence in this alignment, false otherwise.

containsEntity2

public boolean containsEntity2(IRI ent)
Checks if this alignment contains a correspondence with a second entity specified by an IRI.

Specified by:
containsEntity2 in interface Alignment
Parameters:
ent - IRI of entity to be checked if present as entity 2 in a correspondence in this alignment.
Returns:
true if ent participates as entity 2 of a correspondence in this alignment, false otherwise.

getCorrespondences

public Set<Correspondence<? extends OWLEntity>> getCorrespondences()
Gets the set of correspondences of this alignment. The method returns a defensive copy of the set of correspondences contained in this alignment. In other words, modifying this returned set does not modify the state of this alignment.

Specified by:
getCorrespondences in interface Alignment
Returns:
Correspondences of this alignment.

getEntity1Corr

public <T extends OWLEntity> Correspondence<T> getEntity1Corr(T ent)
Gets the correspondence with a specific entity as entity 1. If there is no correspondence with the specified entity as entity 1, null will be returned.

Specified by:
getEntity1Corr in interface Alignment
Type Parameters:
T - Entity type.
Parameters:
ent - Entity 1 of the requested correspondence.
Returns:
Correspondence with ent as entity 1, or null if no such correspondence exists.

getEntity1Corr

public Correspondence<? extends OWLEntity> getEntity1Corr(IRI ent)
Gets the correspondence with a specific entity as entity 1. The entity is specified by its IRI. If there is no correspondence with the specified entity as entity 1, null will be returned.

Specified by:
getEntity1Corr in interface Alignment
Parameters:
ent - IRI of entity 1 of the requested correspondence.
Returns:
Correspondence with ent as entity 1, or null if no such correspondence exists.

getEntity2Corr

public <T extends OWLEntity> Correspondence<T> getEntity2Corr(T ent)
Gets the correspondence with a specific entity as entity 2. If no correspondence with the specified entity as entity 2, null will be returned.

Specified by:
getEntity2Corr in interface Alignment
Type Parameters:
T - Entity type.
Parameters:
ent - Entity 2 of the requested correspondence.
Returns:
Correspondence with ent as entity 2, or null if no such correspondence exists.

getEntity2Corr

public Correspondence<? extends OWLEntity> getEntity2Corr(IRI ent)
Gets the correspondence with a specific entity as entity 2. The entity is specified by its IRI. If there is no correspondence with the specified entity as entity 2, null will be returned.

Specified by:
getEntity2Corr in interface Alignment
Parameters:
ent - IRI of entity 2 of the requested correspondence.
Returns:
Correspondence with ent as entity 2, or null if no such correspondence exists.

getEntityCorr

public <T extends OWLEntity> Correspondence<T> getEntityCorr(T ent1,
                                                             T ent2)
Gets the correspondence with specific entities as entity 1 and entity 2. If no correspondence with the specified entities as entity 1 and entity 2, null will be returned.

Specified by:
getEntityCorr in interface Alignment
Type Parameters:
T - Entity type.
Parameters:
ent1 - Entity 1 of the requested correspondence.
ent2 - Entity 2 of the requested correspondence.
Returns:
Correspondence with ent as entity 1 and ent as entity 2, or null if no such correspondence exists.

getEntityCorr

public Correspondence<? extends OWLEntity> getEntityCorr(IRI ent1,
                                                         IRI ent2)
Gets the correspondence with specific entities as entity 1 and entity2. The entities are specified by its IRI. If there is no correspondence with the specified entities as entity 1 and entity2, null will be returned.

Specified by:
getEntityCorr in interface Alignment
Parameters:
ent1 - IRI of entity 1 of the requested correspondence.
ent2 - IRI of entity 2 of the requested correspondence.
Returns:
Correspondence with ent1 as entity 1 and ent2 as entity 2 or null if no such correspondence exists.

getOntology1

public OWLOntology getOntology1()
Gets the first ontology of this alignment.

Specified by:
getOntology1 in interface Alignment
Returns:
Ontology 1.

getOntology2

public OWLOntology getOntology2()
Gets the second ontology of this alignment.

Specified by:
getOntology2 in interface Alignment
Returns:
Ontology 2.

isEmpty

public boolean isEmpty()
Checks, whether this alignment is empty, i.e. has no correspondences.

Specified by:
isEmpty in interface Alignment
Returns:
true iff this alignment contains no correspondences, false otherwise.

removeCorrespondence

public void removeCorrespondence(Correspondence<? extends OWLEntity> corr)
Removes a correspondence from this alignment if present.

Specified by:
removeCorrespondence in interface Alignment
Parameters:
corr - The correspondence to be removed.

size

public int size()
Gets the size of this alignment. The size of the alignment is the number of correspondences it contains.

Specified by:
size in interface Alignment
Returns:
The number of correspondences held by this alignment.

iterator

public Iterator<Correspondence<? extends OWLEntity>> iterator()

Specified by:
iterator in interface Iterable<Correspondence<? extends OWLEntity>>

attachListener

public void attachListener(AlignmentListener listener)
Registers an AlignmentListener. The AlignmentListener gets notified when the alignment changes. Calling this method with an AlignmentListener that is already registered is a no-op.

Specified by:
attachListener in interface Alignment
Parameters:
listener - AlignmentListener to register.

detachListener

public void detachListener(AlignmentListener listener)
Deregisters an AlignmentListener. The AlignmentListener will be no longer notified when the alignment changes. Calling this method with an AlignmentListener that is not registered is a no-op.

Specified by:
detachListener in interface Alignment
Parameters:
listener - AlignmentListener to deregister.

clone

public ForwardingAlignment clone()
Creates a clone of this alignment.

Specified by:
clone in interface Alignment
Overrides:
clone in class Object
Returns:
Clone of this alignment.

equals

public boolean equals(Object other)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object

notifyListeners

protected final void notifyListeners(AlignmentChangeEvent changeEvent)
Notifies all registered listeners of the provided AlignmentChangeEvent.

Parameters:
changeEvent - The AlignmentChangeEvent.

guard_attachListener

protected void guard_attachListener(AlignmentListener listener)
Guard for the attachListener(AlignmentListener) method. Ensures that the argument is not null.

Parameters:
listener - The listener argument.
Throws:
NullPointerException - if the argument is null

guard_detachListener

protected void guard_detachListener(AlignmentListener listener)
Guard for the detachListener(AlignmentListener) method. Ensures that the argument is not null.

Parameters:
listener - The listener argument.
Throws:
NullPointerException - if the argument is null


Copyright © 2012. All Rights Reserved.