de.fzi.kadmos.api.impl
Class SimpleAlignment

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

public final class SimpleAlignment
extends Object
implements Alignment, Serializable

Class representing a simple alignment of two ontologies. The alignment consists of a set of correspondences. Only 1:1 correspondences are allowed, i.e. no entity of each ontology can occur in more than one correspondence. addCorrespondence(de.fzi.kadmos.api.Correspondence) will throw a MultiplicityException if this constraint would be violated while adding correspondences.

Correspondences are stored in hash data structures for constant time access. Note that correspondences once they are created cannot be changed apart from their confidence value. Changing the confidence value does not change the hashcode of the correspondence and thus the hash data structures still provide valid object references.

When cloning this object, the clone will reference the same ontologies as this object, and correspondences of the clone will reference the same entities as resp. correspondences in this object. That is referenced ontologies and corresponding entites will not be cloned recursively.

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

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.
 SimpleAlignment 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.
 int hashCode()
          
 boolean isEmpty()
          Checks, whether this alignment is empty, i.e.
 Iterator<Correspondence<? extends OWLEntity>> iterator()
          
 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
 

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.

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.

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.

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(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.

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.

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 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.

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.

iterator

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

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

clear

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

Specified by:
clear in interface Alignment

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.

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.

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 SimpleAlignment 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


Copyright © 2012. All Rights Reserved.