From da65041e98e4964383f4d756c76c839d8f1c10af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Sun, 7 Mar 2010 19:40:05 +0000 Subject: [PATCH] - new expressive language EDOAL --- .../align/impl/edoal/ClassConstruction.java | 106 ++++++++ .../align/impl/edoal/ClassExpression.java | 61 +++++ .../exmo/align/impl/edoal/ClassId.java | 116 +++++++++ .../impl/edoal/ClassOccurenceRestriction.java | 73 ++++++ .../align/impl/edoal/ClassRestriction.java | 90 +++++++ .../impl/edoal/ClassTypeRestriction.java | 71 ++++++ .../impl/edoal/ClassValueRestriction.java | 111 ++++++++ .../exmo/align/impl/edoal/Comparator.java | 57 +++++ .../exmo/align/impl/edoal/Datatype.java | 96 +++++++ .../exmo/align/impl/edoal/EDOALAlignment.java | 208 +++++++++++++++ .../exmo/align/impl/edoal/EDOALCell.java | 105 ++++++++ .../exmo/align/impl/edoal/EDOALRelation.java | 240 ++++++++++++++++++ .../exmo/align/impl/edoal/Expression.java | 69 +++++ .../inrialpes/exmo/align/impl/edoal/Id.java | 59 +++++ .../align/impl/edoal/InstanceExpression.java | 65 +++++ .../exmo/align/impl/edoal/InstanceId.java | 89 +++++++ .../exmo/align/impl/edoal/PathExpression.java | 61 +++++ .../impl/edoal/PropertyConstruction.java | 109 ++++++++ .../impl/edoal/PropertyDomainRestriction.java | 81 ++++++ .../align/impl/edoal/PropertyExpression.java | 74 ++++++ .../exmo/align/impl/edoal/PropertyId.java | 76 ++++++ .../align/impl/edoal/PropertyRestriction.java | 75 ++++++ .../impl/edoal/PropertyTypeRestriction.java | 89 +++++++ .../impl/edoal/PropertyValueRestriction.java | 128 ++++++++++ .../edoal/RelationCoDomainRestriction.java | 74 ++++++ .../impl/edoal/RelationConstruction.java | 113 +++++++++ .../impl/edoal/RelationDomainRestriction.java | 80 ++++++ .../align/impl/edoal/RelationExpression.java | 61 +++++ .../exmo/align/impl/edoal/RelationId.java | 109 ++++++++ .../align/impl/edoal/RelationRestriction.java | 59 +++++ .../exmo/align/impl/edoal/TransfService.java | 213 ++++++++++++++++ .../exmo/align/impl/edoal/Value.java | 99 ++++++++ .../align/impl/edoal/ValueConstraint.java | 47 ++++ 33 files changed, 3164 insertions(+) create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassConstruction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassExpression.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassOccurenceRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassTypeRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ClassValueRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/Comparator.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/EDOALCell.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/EDOALRelation.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/Expression.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/Id.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/InstanceExpression.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PathExpression.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyConstruction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyDomainRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyExpression.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyTypeRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/PropertyValueRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/RelationCoDomainRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/RelationConstruction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/RelationDomainRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/RelationExpression.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/RelationRestriction.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/TransfService.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/Value.java create mode 100644 src/fr/inrialpes/exmo/align/impl/edoal/ValueConstraint.java diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassConstruction.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassConstruction.java new file mode 100644 index 00000000..29ffd063 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassConstruction.java @@ -0,0 +1,106 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 - was ClassExpr + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; +import java.util.HashSet; + +import fr.inrialpes.exmo.align.parser.SyntaxElement.Constructor; +import fr.inrialpes.exmo.align.parser.SyntaxElement; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a ClassExpression. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/ClassExpr.java,v $, + * @version $Revision: 1.5 $ $Date$ + */ + +// JE2010: Should it be abstract with ClassConjunction?? + +public class ClassConstruction extends ClassExpression { + + /** Holds all expressions. */ + private Collection<ClassExpression> components; + + /** Operator of this complex expression. */ + private Constructor operator; + + public ClassConstruction() { + super(); + components = new HashSet<ClassExpression>(); + } + + public ClassConstruction( Constructor op, Collection<ClassExpression> expressions ) { + if ((expressions == null) || (op == null)) { + throw new NullPointerException("The subexpressions and the operator must not be null"); + } + if (expressions.contains(null)) { + throw new IllegalArgumentException("The subexpressions must not contain null"); + } + this.components = expressions; + if ( op != SyntaxElement.AND.getOperator() && + op != SyntaxElement.OR.getOperator() && + op != SyntaxElement.NOT.getOperator() ) { + throw new IllegalArgumentException( "Incorrect operator for class : "+op ); + } + this.operator = op; + } + + public Constructor getOperator() { + return operator; + } + + public void setOperator( Constructor op ) { + operator = op; + } + + public Collection<ClassExpression> getComponents() { + return components; + } + + public void addComponents( ClassExpression exp ) { + components.add( exp ); + } + + /* + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + */ + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassExpression.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassExpression.java new file mode 100644 index 00000000..aa0dbec6 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassExpression.java @@ -0,0 +1,61 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 - was ClassExpr + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a ClassExpression. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/ClassExpr.java,v $, + * @version $Revision: 1.5 $ $Date$ + */ + +public abstract class ClassExpression extends Expression { + + protected ClassExpression() { + super(); + } + + /* + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + */ + + /* public Object clone() { + return super.clone(); + }*/ + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java new file mode 100644 index 00000000..60426584 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java @@ -0,0 +1,116 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +import java.net.URI; +import java.net.URISyntaxException; + +/** + * A simple Id to represent a Class. + * + * @author richi + * + */ +public class ClassId extends ClassExpression implements Id { + + /** Holds the identifier. */ + private String id; + + URI uri; + + public ClassId(final String id) throws AlignmentException { + if (id == null) { + throw new NullPointerException("The id must not be null"); + } + if (id.length() <= 0) { + throw new IllegalArgumentException( + "The id must be longer than 0 characters"); + } + this.id = id; + try { + uri = new URI( id ); + } catch ( URISyntaxException mfuex ) { + throw new AlignmentException( "Not an URI "+id, mfuex ); + } + } + + public ClassId( final URI u ) { + if ( u == null) { + throw new NullPointerException("The URI must not be null"); + } + this.uri = u; + id = u.toString(); + } + + public URI getURI(){ + return uri; + } + + public String plainText() { + return id; + } + + /** + * <p> + * Returns a simple description of this object. <b>The format of the + * returned String is undocumented and subject to change.</b> + * <p> + * <p> + * An expamle return String could be: + * <code>classId: http://my/super/class</code> + * </p> + */ + public String toString() { + return "classId: " + id; + } + + public int hashCode() { + int result = 17; + result = result * 37 + id.hashCode(); + return result; + } + + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ClassId)) { + return false; + } + ClassId i = (ClassId) obj; + return id.equals(i.id); + } + + /* + public Object clone() { + return super.clone(); + } + */ +} + diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassOccurenceRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassOccurenceRestriction.java new file mode 100644 index 00000000..f54915d9 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassOccurenceRestriction.java @@ -0,0 +1,73 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 -- then AttributeOccurenceCondition.java + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a attributeOccurenceRestriction tag for a ClassExpressions. + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * <p> + * $Id: ClassOccurenceRestriction.java,v 1.5 2006/11/15 16:01:17 poettler_ric + * Exp $ + * </p> + * + * @author Francois Scharffe + * @author Adrian Mocan + * @author Richard Pöttler + * @version $Revision: 1.6 $ $Date$ + */ +public class ClassOccurenceRestriction extends ClassRestriction implements Cloneable { + + Comparator comparator = null; + int occurence = 1; + + /** + * Constructs a attributeOccurenceRestriction with the given restriction. + * + * @param attribute + * the attribute on which the restriction should be applied + * @param restriction + * the restriction for the domain + * @throws NullPointerException + * if the restriction is null + */ + public ClassOccurenceRestriction( final PathExpression p, Comparator c, int n ) { + super( p ); + constrainedPath = p; + comparator = c; + occurence = n; + } + + public int getOccurence() { return occurence; } + public void setOccurence( int n ) { occurence = n; } + public Comparator getComparator() { return comparator; } + public void setComparator( Comparator c ) { comparator = c; } + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassRestriction.java new file mode 100644 index 00000000..85c9cefc --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassRestriction.java @@ -0,0 +1,90 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.6 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Superclass for all ClassRestrictions. + * </p> + * <p> + * To successfully subclass this class the <code>clone</code> and + * <code>equals</code> methods must be overwritten. And if new fields were + * introduced, the <code>hashCode</code> and <code>toString</code> methods, + * too. + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * <p> + * $Id: ClassRestriction.java,v 1.6 2006/11/27 16:39:08 poettler_ric Exp $ + * </p> + * + * @author Francois Scharffe + * @author Adrian Mocan + * @author Richard Pöttler + * @version $Revision: 1.6 $ $Date$ + */ +public abstract class ClassRestriction extends ClassExpression { + + /** The attribute on which the restriction should be applied. */ + protected PathExpression constrainedPath = null; + + public ClassRestriction( PathExpression att ) { + super(); + constrainedPath = att; + } + + /* + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + */ + + public PathExpression getRestrictionPath() { + return constrainedPath; + } + + public void setRestrictionPath( PathExpression att) { + constrainedPath = att; + } + + /* + public Object clone() { + try { + ClassRestriction clone = (ClassRestriction) super.clone(); + clone.restriction = (Restriction) restriction.clone(); + clone.attribute = (PathExpression) attribute.clone(); + clone.target = (ExpressionDefinition) target.clone(); + return clone; + } catch (CloneNotSupportedException e) { + assert true : "Object is always cloneable"; + } + return null; + } + */ + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassTypeRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassTypeRestriction.java new file mode 100644 index 00000000..37b31dc6 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassTypeRestriction.java @@ -0,0 +1,71 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a type typeCondition tag for PropertyExpressions. + * </p> + * <p> + * $Id: ClassTypeRestriction.java,v 1.5 2006/11/27 16:39:09 poettler_ric Exp $ + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * + * @author Francois Scharffe + * @author Adrian Mocan + * @author Richard Pöttler + * @version $Revision: 1.5 $ $Date$ + */ +public class ClassTypeRestriction extends ClassRestriction implements Cloneable { + + // BEWARE THIS IS INCORRECTLY IMPLEMENTED AS VALUES INSTEAD OF TYPES + Datatype type = null; + + /** + * Constructs a typeCondition with the given restriction. + * + * @param res + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public ClassTypeRestriction(final PathExpression p, + final Datatype t) { + super(p); + // Check that this is a property + type = t; + } + + public Datatype getType() { + return type; + } + + public void setType( Datatype t ) { + type = t; + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassValueRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassValueRestriction.java new file mode 100644 index 00000000..fafa76c7 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassValueRestriction.java @@ -0,0 +1,111 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.6 - 2006 + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a type valueCondition tag for PropertyExpressions. + * </p> + * <p> + * $Id: ClassValueRestriction.java,v 1.6 2006/11/27 16:39:09 poettler_ric Exp $ + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * + * @author Richard Pöttler + * @version $Revision: 1.6 $ $Date$ + */ +public class ClassValueRestriction extends ClassRestriction implements Cloneable { + + Comparator comparator = null; + PathExpression pathValue = null; + Value value = null; + InstanceExpression inst = null; + + /** + * Constructs a valueCondition with the given restriction. + * + * @param res + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public ClassValueRestriction(final PathExpression p, final Comparator comp, final PathExpression p2) { + super(p); + pathValue = p2; + comparator = comp; + } + + public ClassValueRestriction(final PathExpression p, final Comparator comp, final Value v) { + super(p); + value = v; + comparator = comp; + } + + public ClassValueRestriction(final PathExpression p, final Comparator comp, final InstanceExpression i) { + super(p); + inst = i; + comparator = comp; + } + + public Comparator getComparator() { + return comparator; + } + + public void setComparator( Comparator comp ) { + comparator = comp; + } + + public PathExpression getPathValue() { + return pathValue; + } + + public InstanceExpression getInstanceValue() { + return inst; + } + + public Value getValue() { + return value; + } + + public void setValue( PathExpression p ) { + pathValue = p; + value = null; + inst = null; + } + + public void setValue( InstanceExpression i ) { + inst = i; + pathValue = null; + value = null; + } + + public void setValue( Value v ) { + value = v; + pathValue = null; + inst = null; + } +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Comparator.java b/src/fr/inrialpes/exmo/align/impl/edoal/Comparator.java new file mode 100644 index 00000000..6319eaee --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Comparator.java @@ -0,0 +1,57 @@ +/* + * $Id$ + * + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.net.URI; +import java.net.URISyntaxException; + +public class Comparator { + + URI uri = null; + + // This replaces the Comparator class + // SHOULD CERTAINLY BE AN ENUM + public static Comparator EQUAL = initComparator( "http://www.w3.org/2001/XMLSchema#equals", 0 ); + public static Comparator LOWER = initComparator( "http://www.w3.org/2001/XMLSchema#lower-than", -1 ); + public static Comparator GREATER = initComparator( "http://www.w3.org/2001/XMLSchema#greater-than", 1 ); + + protected Comparator() { + super(); + } + + public Comparator( URI u ) { + super(); + uri = u; + } + + private static Comparator initComparator( String uri, int rank ){ + try { + return new Comparator( new URI( uri ) ); + } catch ( URISyntaxException usex ) { + return new Comparator(); + } + } + + public URI getURI() { + return uri; + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java b/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java new file mode 100644 index 00000000..0c577757 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java @@ -0,0 +1,96 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.2 - 2006 + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Id to represent a datatype + * </p> + * <p> + * $Id$ + * </p> + */ + +public class Datatype { //implements Cloneable, Visitable { + + /** Holds the type */ + private String type; + + /** + * Constructs an object with the given type. + * + * @param type + * the type for this object. + * @throws NullPointerException + * if the type is {@code null} + * @throws IllegalArgumentException + * if the type isn't longer than 0 + */ + public Datatype( final String type ) { + if (type == null) { + throw new NullPointerException("The type must not be null"); + } + this.type = type; + } + + // public void accept(AlignmentVisitor visitor) throws AlignmentException { + // visitor.visit(this); + // } + + public String plainText() { + return type; + } + + public int hashCode() { + return type.hashCode(); + } + + public boolean equals(final Object o) { + if ( o == this ) { + return true; + } + if (!(o instanceof Datatype)) { + return false; + } + Datatype s = (Datatype) o; + return type.equals(s.type); + } + /* + public Object clone() { + return super.clone(); + } + */ + + /** + * <p> + * Returns a short description about this object. <b>The format of the + * returned string is undocumentd and subject to change.</b> + * </p> + * <p> + * An example return string could be: {@code 15} + * </p> + */ + public String toString() { + return type; + } +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java new file mode 100644 index 00000000..05ac35e4 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java @@ -0,0 +1,208 @@ +/* + * $Id: EDOALAlignment.java,v 1.6 2008/09/15 08:38:54 jeuzenat Exp $ + * + * Sourceforge version 1.6 - 2008 - was OMWGAlignment + * Copyright (C) INRIA, 2007-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.net.URI; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.Alignment; +import org.semanticweb.owl.align.Cell; +import org.semanticweb.owl.align.Relation; +import org.semanticweb.owl.align.Parameters; + +import fr.inrialpes.exmo.ontowrap.Ontology; +import fr.inrialpes.exmo.align.impl.Annotations; +import fr.inrialpes.exmo.align.impl.Namespace; +import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.BasicParameters; +import fr.inrialpes.exmo.align.impl.Extensions; + +/** + * <p>This class is an encapsulation of BasicAlignement so that + * it creates the structures required by the MappingDocument within + * the BasicAlignment</p> + * JE 2009: Maybe ObjectAlignment could even be better + * + */ +public class EDOALAlignment extends BasicAlignment { + + protected EDOALAlignment init = null; + + public EDOALAlignment() { + setLevel("2EDOAL"); + setXNamespace( Namespace.EDOAL.shortCut, Namespace.EDOAL.prefix ); + } + + public void init( Object onto1, Object onto2 ) throws AlignmentException { + if ( (onto1 == null) || (onto2 == null) ) + throw new AlignmentException("The source and target ontologies must not be null"); + if ( (onto1 instanceof Ontology && onto2 instanceof Ontology) ){ + super.init( onto1, onto2 ); + } else { + throw new AlignmentException("arguments must be LoadedOntology"); + }; + } + + public void loadInit( Alignment al ) throws AlignmentException { + if ( al instanceof EDOALAlignment ) { + init = (EDOALAlignment)al; + } else { + throw new AlignmentException( "EDOAL required as initial alignment"); + } + } + + /* + * Dealing with correspondences + */ + + /** Cell methods **/ + public Cell addAlignCell( EDOALCell rule ) throws AlignmentException { + addCell( rule ); + return rule; + } + + public Cell addAlignCell(String id, Object ob1, Object ob2, Relation relation, double measure, Extensions extensions ) throws AlignmentException { + if ( !( ob1 instanceof Expression && ob2 instanceof Expression ) ) + throw new AlignmentException("arguments must be Expressions"); + return super.addAlignCell( id, ob1, ob2, relation, measure, extensions); + }; + public Cell addAlignCell(String id, Object ob1, Object ob2, Relation relation, double measure) throws AlignmentException { + if ( !( ob1 instanceof Expression && ob2 instanceof Expression ) ) + throw new AlignmentException("arguments must be Expressions"); + return super.addAlignCell( id, ob1, ob2, relation, measure); + }; + public Cell addAlignCell(Object ob1, Object ob2, String relation, double measure) throws AlignmentException { + + if ( !( ob1 instanceof Expression && ob2 instanceof Expression ) ) + throw new AlignmentException("arguments must be Expressions"); + return super.addAlignCell( ob1, ob2, relation, measure); + }; + public Cell addAlignCell(Object ob1, Object ob2) throws AlignmentException { + + if ( !( ob1 instanceof Expression && ob2 instanceof Expression ) ) + throw new AlignmentException("arguments must be Expressions"); + return super.addAlignCell( ob1, ob2 ); + }; + public Cell createCell(String id, Object ob1, Object ob2, Relation relation, double measure) throws AlignmentException { + return (Cell)new EDOALCell( id, (Expression)ob1, (Expression)ob2, (EDOALRelation)relation, measure); + } + + public Set<Cell> getAlignCells1(Object ob) throws AlignmentException { + if ( ob instanceof Expression ){ + return super.getAlignCells1( ob ); + } else { + throw new AlignmentException("argument must be Expression"); + } + } + public Set<Cell> getAlignCells2(Object ob) throws AlignmentException { + if ( ob instanceof Expression ){ + return super.getAlignCells2( ob ); + } else { + throw new AlignmentException("argument must be Expression"); + } + } + + // Deprecated: implement as the one retrieving the highest strength correspondence ( + public Cell getAlignCell1(Object ob) throws AlignmentException { + if ( Annotations.STRICT_IMPLEMENTATION == true ){ + throw new AlignmentException("deprecated (use getAlignCells1 instead)"); + } else { + if ( ob instanceof Expression ){ + return super.getAlignCell1( ob ); + } else { + throw new AlignmentException("argument must be Expression"); + } + } + } + + public Cell getAlignCell2(Object ob) throws AlignmentException { + if ( Annotations.STRICT_IMPLEMENTATION == true ){ + throw new AlignmentException("deprecated (use getAlignCells2 instead)"); + } else { + if ( ob instanceof Expression ){ + return super.getAlignCell2( ob ); + } else { + throw new AlignmentException("argument must be Expression"); + } + } + } + + /* + * Dealing with ontology Ids from an Alignment API standpoint + */ + public URI getOntology1URI() { return onto1.getURI(); }; + + public URI getOntology2URI() { return onto2.getURI(); }; + + public void setOntology1(Object ontology) throws AlignmentException { + if ( ontology instanceof Ontology ){ + super.setOntology1( ontology ); + } else { + throw new AlignmentException("arguments must be Ontology"); + }; + }; + + public void setOntology2(Object ontology) throws AlignmentException { + if ( ontology instanceof Ontology ){ + super.setOntology2( ontology ); + } else { + throw new AlignmentException("arguments must be Ontology"); + }; + }; + + +/** + * Returns the mappings of the EDOALAlignment + * @return The set of rules contained by the EDOALAlignment + */ + + /** + * Generate a copy of this alignment object + */ + // JE: this is a mere copy of the method in BasicAlignement + // It has two difficulties + // - it should call the current init() and not that of BasicAlignement + // - it should catch the AlignmentException that it is supposed to raise + public Object clone() { + EDOALAlignment align = new EDOALAlignment(); + try { + align.init( (Ontology)getOntology1(), (Ontology)getOntology2() ); + } catch ( AlignmentException e ) {}; + align.setType( getType() ); + align.setLevel( getLevel() ); + align.setFile1( getFile1() ); + align.setFile2( getFile2() ); + for ( String[] ext: extensions.getValues() ){ + align.setExtension( ext[0], ext[1], ext[2] ); + } + align.setExtension( Namespace.ALIGNMENT.getUriPrefix(), "id", (String)null ); + try { + align.ingest( this ); + } catch (AlignmentException ex) { ex.printStackTrace(); } + return align; + } + + } diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALCell.java b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALCell.java new file mode 100644 index 00000000..b5a892c1 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALCell.java @@ -0,0 +1,105 @@ +/* + * $Id: EDOALCell.java,v 1.2 2008/06/29 16:18:49 jeuzenat Exp $ + * + * Sourceforge version 1.2 - 2008 + * Copyright (C) INRIA, 2007-2009 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.io.PrintStream; +import java.io.IOException; +import java.util.Comparator; +import java.lang.ClassNotFoundException; +import java.lang.Float; +import java.lang.Double; +import java.net.URISyntaxException; +import java.net.URI; + +import org.semanticweb.owl.align.Alignment; +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Cell; +import org.semanticweb.owl.align.Relation; + +import fr.inrialpes.exmo.align.impl.BasicCell; + +import fr.inrialpes.exmo.align.impl.rel.*; + +/** + * This implements a particular of ontology correspondence when it + * is a correspondence from the EDOAL Mapping Language. + * + * The current implementation of this class consists of encapsulating + * the EDOAL Mapping Rule object and reimplementing the ALignment API + * accessors around it. + * This is fine but there is another implementation that would be more + * satisfactory: + * + * Reimplementing the EDOAL Mapping Rules in terms of a proper Cell + * with: + * id: URI id + * object1: Resource source + * object2: Resource target + * relation: The class name of the rule + * measure: float measure + * -- no real use of direction. + * + * @author Jérôme Euzenat + * @version $Id: EDOALCell.java,v 1.2 2008/06/29 16:18:49 jeuzenat Exp $ + */ + +public class EDOALCell extends BasicCell { + + // JE2009: This has been added for + private URI id; // This is the id + + public void accept( AlignmentVisitor visitor) throws AlignmentException { + visitor.visit( this ); + } + + /** Creation **/ + public EDOALCell( String id, Expression ob1, Expression ob2, EDOALRelation rel, double m ) throws AlignmentException { + super( id, (Object)ob1, (Object)ob2, rel, m ); + }; + + public boolean equals( Cell c ) { + if ( c instanceof EDOALCell ){ + return ( object1.equals(c.getObject1()) && object2.equals(c.getObject2()) && strength == c.getStrength() && (relation.equals( c.getRelation() )) ); + } else { + return false; + } + } + + // JE// Maybe do it in case Expressions have URI + public URI getObject1AsURI( Alignment al ) throws AlignmentException { + return null; + //throw new AlignmentException( "Cannot convert to URI "+object1 ); + } + public URI getObject2AsURI( Alignment al ) throws AlignmentException { + return null; + //throw new AlignmentException( "Cannot convert to URI "+object2 ); + } + + public Cell inverse() throws AlignmentException { + return (Cell)new EDOALCell( (String)null, (Expression)object2, (Expression)object1, (EDOALRelation)relation.inverse(), strength ); + // The same should be done for the measure + } + +} + diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALRelation.java b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALRelation.java new file mode 100644 index 00000000..c090fb4c --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALRelation.java @@ -0,0 +1,240 @@ +/* + * $Id: EDOALRelation.java,v 1.3 2008/02/28 20:14:10 jeuzenat Exp $ + * + * Sourceforge version 1.3 - 2008 + * Copyright (C) INRIA, 2007-2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +// JE2009: This is a total mess that must be rewritten wrt Direction + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Relation; + +import java.lang.reflect.Constructor; +import java.io.PrintWriter; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import org.xml.sax.ContentHandler; + +/** + * Represents an ontology alignment relation. + * In fact, for the EDOAL Mapping language, this encodes directions + * but should be rewritten in order to achive a better implementation + * + * @author Jérôme Euzenat + * @version $Id: EDOALRelation.java,v 1.3 2008/02/28 20:14:10 jeuzenat Exp $ + */ + +public class EDOALRelation implements Relation { + + /** + * <p> + * Enumeration to distinuish the direction of the mapping. + * </p> + * <p> + * $Id: MappingRule.java,v 1.10 2008/01/22 18:24:58 jeuzenat Exp $ + * </p> + * + * @author richi + * @version $Revision: 1.10 $ + */ + // JE2009: THIS SHOULD BE REWRITTEN WITH SUBCLASSES AND NO DIRECTIONS... + /* [JE:22/01/2008] + * I make this compliant with 2.2.10 and replacing RDFRuleTYpe + * The Trick for having a hash-table for recording the various relations makes the nameIndex non-static and the getRelation() unusable in static context... + * Hence it has to be used as: Direction.GENERIC.getRelation(); + */ + public static enum Direction { + GENERIC("Generic",(String)null), + EQUIVALENCE("Equivalence","="), + DISJOINTFROM("DisjointFrom","><"), + SUBSUMES("Subsumes",">"), + SUBSUMEDBY("SubsumedBy","<"), + INSTANCEOF("InstanceOf",(String)null), + HASINSTANCE("HasInstance",(String)null); + + private final String EDOALRepr; + private final String abbrev; + private final URI uri; + + private static Map<String, Direction> nameIndex = null; + + private Direction(final String repr, final String abb) { + EDOALRepr = repr; + abbrev = abb; + uri = (URI)null; + } + + public String toString() { + return EDOALRepr; + } + + public static Direction getRelation( final String name ){ + if ( nameIndex == null ){ + nameIndex = new HashMap<String, Direction>(); + nameIndex.put( "Equivalence", EQUIVALENCE ); + nameIndex.put( "=", EQUIVALENCE ); + nameIndex.put( "equivalence", EQUIVALENCE ); + nameIndex.put( "ClassMapping", EQUIVALENCE ); + nameIndex.put( "Subsumes", SUBSUMES ); + nameIndex.put( ">", SUBSUMES ); + nameIndex.put( "SubsumedBy", SUBSUMEDBY ); + nameIndex.put( "<", SUBSUMEDBY ); + nameIndex.put("><",DISJOINTFROM); + nameIndex.put("DisjointFrom",DISJOINTFROM); + nameIndex.put("Disjoint",DISJOINTFROM); + nameIndex.put("disjointFrom",DISJOINTFROM); + nameIndex.put("disjoint",DISJOINTFROM); + nameIndex.put( "InstanceOf", INSTANCEOF ); + nameIndex.put( "HasInstance", HASINSTANCE ); + } + if (name == null) + throw new NullPointerException("The string to search must not be null"); + return nameIndex.get(name); + } + } + + public void accept( AlignmentVisitor visitor) throws AlignmentException { + visitor.visit( this ); + } + /** + * It is intended that the value of the relation is =, < or >. + * But this can be any string in other applications. + */ + protected String type = null; + + protected Direction direction = null; + + /** Creation **/ + public EDOALRelation( String t ) throws AlignmentException { + direction = Direction.getRelation( t ); + if ( direction == null ) throw new AlignmentException( "Unknown EDOALRelation : "+t ); + type = t; + } + + /** Creation **/ + public EDOALRelation( Direction d ) { + type = d.toString(); + direction = d; + } + + /** Creation: OLD Stuff should disappear **/ + public EDOALRelation( String t, Direction d ) { + direction = d; + type = t; + } + + /** printable format **/ + public String getRelation(){ + return type; + } + + /** printable format **/ + public Direction getDirection(){ + return direction; + } + + public Relation compose(Relation r) { + String newType = null; + Direction newDirection = null; + if ( ! (r instanceof EDOALRelation) ) return null; + String rType = ((EDOALRelation)r).getRelation(); + // Compose types + if ( type.startsWith("Class") ) { newType = "Class"; } + else if ( type.startsWith("Relation") ) { newType = "Relation"; } + else if ( type.startsWith("Attribute") ) { newType = "Attribute"; } + else if ( type.startsWith("Instance") ) { newType = "Instance"; } + if ( ( type.endsWith("Class") && !rType.startsWith("Class") ) || + ( type.endsWith("Relation") && !rType.startsWith("Relation") ) || + ( type.endsWith("Attribute") && !rType.startsWith("Attribute") ) || + ( type.endsWith("Instance") && !rType.startsWith("Instance") ) ){ + return null; + } + if ( rType.endsWith("Class") ) { newType += "Class"; } + else if ( rType.endsWith("Relation") ) { newType += "Relation"; } + else if ( rType.endsWith("Attribute") ) { newType += "Attribute"; } + else if ( rType.endsWith("Instance") ) { newType += "Instance"; } + // Compose directions + Direction rDir = ((EDOALRelation)r).getDirection(); + if ( direction == Direction.GENERIC || rDir == Direction.GENERIC || + direction == null || rDir == null ) return null; + if ( direction == Direction.EQUIVALENCE ) { newDirection = rDir; } + else if ( direction == Direction.SUBSUMES ) { + if ( rDir == Direction.SUBSUMES || rDir == Direction.EQUIVALENCE ) { + newDirection = Direction.SUBSUMES; + } else if ( rDir == Direction.HASINSTANCE ) newDirection = Direction.HASINSTANCE; + } else if ( direction == Direction.SUBSUMEDBY ) { + if ( rDir == Direction.SUBSUMEDBY || rDir == Direction.EQUIVALENCE ) + newDirection = Direction.SUBSUMEDBY; + } else if ( direction == Direction.INSTANCEOF ) { + if ( rDir == Direction.SUBSUMEDBY || rDir == Direction.EQUIVALENCE ) + newDirection = Direction.INSTANCEOF; + } else if ( direction == Direction.HASINSTANCE ) { + if ( rDir == Direction.EQUIVALENCE ) newDirection = Direction.HASINSTANCE; + } + if ( newType != null && newDirection != null ) { + return new EDOALRelation( newType, newDirection ); + } else return null; + } + + /** By default the inverse is the relation itself **/ + public Relation inverse() { + if ( type.equals("Class") ) return new EDOALRelation("Class", direction); + else if (type.equals("ClassRelation") ) return new EDOALRelation("RelationClass", direction); + else if (type.equals("ClassAttribute") ) return new EDOALRelation("AttributeClass", direction); + else if (type.equals("ClassInstance") ) return new EDOALRelation("InstanceClass", direction); + else if (type.equals("RelationClass") ) return new EDOALRelation("ClassRelation", direction); + else if (type.equals("Relation") ) return new EDOALRelation("Relation", direction); + else if (type.equals("RelationAttribute") ) return new EDOALRelation("AttributeRelation", direction); + else if (type.equals("RelationInstance") ) return new EDOALRelation("InstanceRelation", direction); + else if (type.equals("AttributeClass") ) return new EDOALRelation("ClassAttribute", direction); + else if (type.equals("AttributeRelation") ) return new EDOALRelation("RelationAttribute", direction); + else if (type.equals("Attribute") ) return new EDOALRelation("Attribute", direction); + else if (type.equals("AttributeInstance") ) return new EDOALRelation("InstanceAttribute", direction); + else if (type.equals("InstanceClass") ) return new EDOALRelation("ClassInstance", direction); + else if (type.equals("InstanceRelation") ) return new EDOALRelation("RelationInstance", direction); + else if (type.equals("InstanceAttribute") ) return new EDOALRelation("AttributeInstance", direction); + else if (type.equals("Instance") ) return new EDOALRelation("Instance", direction); + else return null; + } + + /** Are the two relations equal **/ + public boolean equals( Relation r ) { + if ( r instanceof EDOALRelation ){ + return ( type.equals( ((EDOALRelation)r).getRelation() ) + && direction.equals( ((EDOALRelation)r).getDirection() ) ); + } else { + return false; + } + } + + /** Housekeeping **/ + public void dump( ContentHandler h ){}; + + /** This is kept for displayig more correctly the result **/ + public void write( PrintWriter writer ) { + writer.print(direction.toString()); + } +} + + diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Expression.java b/src/fr/inrialpes/exmo/align/impl/edoal/Expression.java new file mode 100644 index 00000000..c701ed07 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Expression.java @@ -0,0 +1,69 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.7 - 2007 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.semanticweb.owl.align.Visitable; +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; + +/** + * <p> + * This class serves as the base for the four different expression types. These + * types are namely <code>AttributeExpression</code>, + * <code>ClassExpression</code>, <code>RelationExpression</code> and + * <code>InstanceExpression</code> + * </p> + * <p> + * The only fields stored in this class is the <code>ExpressionDefinition</code> + * of this Expression and the set of condition associated with this expression. + * </p> + * <p> + * To successfully subclass this class overwrite the <code>equals</code> and + * <code>clone</code> methods. If new fields are introduced the + * <code>toString</code> and <code>hashCode</code> methods must be + * overwritten, too. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/Expression.java,v $, + * @version $Revision: 1.7 $ $Date$ + */ + +public abstract class Expression implements Cloneable, Visitable { + + protected Expression() {} + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Id.java b/src/fr/inrialpes/exmo/align/impl/edoal/Id.java new file mode 100644 index 00000000..7f2c3b20 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Id.java @@ -0,0 +1,59 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.3 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.net.URI; + +/** + * Interface or class description + * + * @author FirstName LastName, FirstName LastName + * + * Created on 22-Mar-2005 + * Committed by $Author: poettler_ric $ + * + * $Source: /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/Id.java,v $, + * @version $Revision: 1.3 $ $Date$ + */ + +public interface Id { + + /* + public boolean isComplexExpression(){ + return false; + } + */ + + /** + * Returns a plain representation of the value of this id. + * @return the plain text representation. + */ + public String plainText(); + + /** + * Returns a plain representation of the value of this id. + * @return the plain text representation. + */ + public URI getURI(); +} + diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/InstanceExpression.java b/src/fr/inrialpes/exmo/align/impl/edoal/InstanceExpression.java new file mode 100644 index 00000000..48e56c27 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/InstanceExpression.java @@ -0,0 +1,65 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.4 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a InstanceExpression. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/InstanceExpr.java,v $, + * @version $Revision: 1.4 $ $Date$ + */ + +public class InstanceExpression extends Expression { + + /** + * Creates a simple InstaneExpression with the given Id. + * + * @param id + * the Id of this expression + * @throws IllegalArgumentException + * if the id isn't a InstanceId + */ + public InstanceExpression() { + super(); + } + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java b/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java new file mode 100644 index 00000000..fc945cff --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java @@ -0,0 +1,89 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.4 - 2006 -- then InstanceExpr + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.net.URI; +import java.net.URISyntaxException; + +/** + * A simple Id to represent a Instance. + * + * @author richi + * + */ + +public class InstanceId extends InstanceExpression implements Id { + + private URI uri; + + public URI getURI(){ + return uri; + } + + public void setURI( URI u ){ + uri = u; + } + + /** + * Constructs a InstanceId. + * + * @param id + * the id of the class + */ + public InstanceId( final URI u ) { + if ( u == null ) { + throw new NullPointerException("The URI must not be null"); + } + this.uri = u; + } + + /** + * Returns the Id. + * + * @return the id. + */ + public String plainText() { + return toString(); + } + + + /** + * <p> + * Returns a simple description of this object. <b>The format of the + * returned String is undocumented and subject to change.</b> + * <p> + * <p> + * An expamle return String could be: + * <code>instanceId: http://my/super/instance</code> + * </p> + */ + public String toString() { + return "instanceId: " + uri; + } + + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PathExpression.java b/src/fr/inrialpes/exmo/align/impl/edoal/PathExpression.java new file mode 100644 index 00000000..21a83960 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PathExpression.java @@ -0,0 +1,61 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + + +/** + * <p> + * Represents a RelationExpression. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/RelationExpr.java,v $, + * @version $Revision: 1.5 $ $Date$ + */ + +public abstract class PathExpression extends Expression implements Cloneable, Visitable { + + public PathExpression() { + super(); + } + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + /* + public Object clone() { + return super.clone(); + } + */ + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyConstruction.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyConstruction.java new file mode 100644 index 00000000..a321a33c --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyConstruction.java @@ -0,0 +1,109 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 - was PropertyExpr + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; +import java.util.HashSet; + +import fr.inrialpes.exmo.align.parser.SyntaxElement.Constructor; +import fr.inrialpes.exmo.align.parser.SyntaxElement; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a PropertyConstruction. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/PropertyExpr.java,v $, + * @version $Revision: 1.5 $ $Date$ + */ + +// JE2010: Should it be abstract with RelationConjunction?? + +public class PropertyConstruction extends PropertyExpression { + + /** Holds all expressions. */ + private Collection<PathExpression> components; + + /** Operator of this complex expression. */ + private Constructor operator; + + public PropertyConstruction() { + super(); + components = new HashSet<PathExpression>(); + } + + public PropertyConstruction( Constructor op, Collection<PathExpression> expressions ) { + if ((expressions == null) || (op == null)) { + throw new NullPointerException("The subexpressions and the operator must not be null"); + } + if (expressions.contains(null)) { + throw new IllegalArgumentException("The subexpressions must not contain null"); + } + // The collection should have only relations and end in a property + // It should be ordered with comp: implement List + this.components = expressions; + if ( op != SyntaxElement.AND.getOperator() && + op != SyntaxElement.OR.getOperator() && + op != SyntaxElement.NOT.getOperator() && + op != SyntaxElement.COMPOSE.getOperator() ) { + throw new IllegalArgumentException( "Incorrect operator for property : "+op ); + } + this.operator = op; + } + + public Constructor getOperator() { + return operator; + } + + public void setOperator( Constructor op ) { + operator = op; + } + + public Collection<PathExpression> getComponents() { + return components; + } + + public void addComponents( PathExpression exp ) { + components.add( exp ); + } + + /* + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + */ + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyDomainRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyDomainRestriction.java new file mode 100644 index 00000000..d9fac77f --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyDomainRestriction.java @@ -0,0 +1,81 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.4 - 2006 -- then DomainAttributeCondition.java + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a domainRestriction tag for PropertyExpressions. + * </p> + * <p> + * $Id: PropertyDomainRestriction.java,v 1.4 2006/11/27 16:39:08 poettler_ric Exp $ + * </p> + * + * @author Richard Pöttler + * @version $Revision: 1.4 $ + * @date $Date$ + * + */ +public class PropertyDomainRestriction extends PropertyRestriction { + protected ClassExpression domain; + + /** + * Constructs a domainRestiction with the given restriction. + * + * @param restriction + * the restriction for the domain + * @throws NullPointerException + * if the restriction is null + */ + public PropertyDomainRestriction() { + super(); + } + + /** + * Constructs a domainRestiction with the given restriction. + * + * @param res + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public PropertyDomainRestriction(final ClassExpression dom) { + super(); + domain = dom; + } + + public ClassExpression getDomain() { + return domain; + } + + public void setDomain( ClassExpression dom ) { + domain = dom; + } + /* + public Object clone() { + return super.clone(); + } + */ + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyExpression.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyExpression.java new file mode 100644 index 00000000..f8a2981f --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyExpression.java @@ -0,0 +1,74 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.7 - 2006 -- then AttributeExpr.java + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; +import java.util.Set; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a PropertyExpression. + * </p> + * <p> + * $Id: PropertyExpr.java,v 1.7 2006/11/30 12:21:41 poettler_ric Exp $ + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * @author richi + * @version $Revision: 1.7 $ + * @date $Date$ + */ + +public abstract class PropertyExpression extends PathExpression implements Cloneable, Visitable { + + /** The transformation service */ + private TransfService transf; + + /** + * Creates a simple PropertyExpression with the given ExpressionDefinition, + * conditions and transf. + * + * @param id + * the ExpressionDefinition + * @param conditions + * the conditions for the expression + * @param transf + * the transformation service + * @throws IllegalArgumentException + * if there are other ids than PropertyId + * @throws NullPointerException + * if the id is {@code null} + */ + public PropertyExpression() { + super(); + } + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java new file mode 100644 index 00000000..540bd944 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java @@ -0,0 +1,76 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.7 - 2006 -- then AttributeExpr.java + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.net.URI; +import java.net.URISyntaxException; + +/** + * <p> + * A simple Id to represent a Property. + * </p> + * <p> + * $Id: PropertyExpr.java,v 1.7 2006/11/30 12:21:41 poettler_ric Exp $ + * </p> + * + * @author richi + * @version $Revision: 1.7 $ + * @date $Date$ + */ +public class PropertyId extends PropertyExpression implements Id { + /** Holds the identifier. */ + private String id; + + URI uri; + + public PropertyId( final URI u ) { + if ( u == null ) { + throw new NullPointerException("The URI must not be null"); + } + uri = u; + id = u.toString(); + } + + public URI getURI(){ + return uri; + } + + public String plainText() { + return toString(); + } + + /** + * <p> + * Returns a simple description of this object. <b>The format of the + * returned String is undocumented and subject to change.</b> + * <p> + * <p> + * An expamle return String could be: + * <code>attributeId: http://my/super/attribute</code> + * </p> + */ + public String toString() { + return "PropertyId: " + id; + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyRestriction.java new file mode 100644 index 00000000..68d3570e --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyRestriction.java @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.6 - 2006 -- then AttributeCondition.java + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Superclass for all AttributeConditions. + * </p> + * <p> + * To successfully subclass this class the <code>clone</code> and + * <code>equals</code> methods must be overwritten. And if new fields were + * introduced, the <code>hashCode</code> and <code>toString</code> methods, + * too. + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * <p> + * $Id: PropertyCondition.java,v 1.6 2006/11/27 16:39:09 poettler_ric Exp $ + * </p> + * + * @author Richard Pöttler + * @author Adrian Mocan + * @author Francois Scharffe + * @version $Revision: 1.6 $ $Date$ + */ +public abstract class PropertyRestriction extends PropertyExpression implements Cloneable, Visitable { + + protected PropertyRestriction() { + super(); + } + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + + /* + public Object clone() { + try { + PropertyRestriction clone = (PropertyRestriction) super.clone(); + clone.restriction = (Restriction) restriction.clone(); + clone.target = (ExpressionDefinition) target.clone(); + return clone; + } catch (CloneNotSupportedException e) { + assert true : "Object is always cloneable"; + } + return null; + } + */ + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyTypeRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyTypeRestriction.java new file mode 100644 index 00000000..3148abb5 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyTypeRestriction.java @@ -0,0 +1,89 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.6 - 2006 -- then AttributeTypeCondition.java + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a attributeTypeRestriction tag for a ClassExpressions. + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * <p> + * $Id: PropertyTypeRestriction.java,v 1.6 2006/11/27 16:39:08 poettler_ric Exp $ + * </p> + * + * @author Francois Scharffe + * @author Adrian Mocan + * @author Richard Pöttler + * @version $Revision: 1.6 $ $Date$ + */ +public class PropertyTypeRestriction extends PropertyRestriction implements Cloneable { + + // BEWARE THIS IS INCORRECTLY IMPLEMENTED AS VALUES INSTEAD OF TYPES + Datatype type = null; + + /** + * Constructs a attributeTypeRestriction with the given restriction. + * + * @param attribute + * the attribute on which the restriction should be applied + * @param restriction + * the restriction for the domain + * @throws NullPointerException + * if the restriction is null + */ + public PropertyTypeRestriction() { + super(); + } + + /** + * Constructs a attributeTypeRestriction with the given restriction. + * + * @param attribute + * the attribute on which the restriction should be applied + * @param restriction + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public PropertyTypeRestriction(final Datatype t) { + super(); + type = t; + } + + public Datatype getType() { + return type; + } + public void setType( Datatype t ) { + type = t; + } + + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyValueRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyValueRestriction.java new file mode 100644 index 00000000..c7e9f72c --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyValueRestriction.java @@ -0,0 +1,128 @@ +/* + * $Id$ + * + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a attributeValueRestriction tag for a ClassExpressions. + * </p> + * <p> + * Created on 24-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * <p> + * $Id: PropertyValueRestriction.java,v 1.6 2006/11/27 16:39:08 poettler_ric Exp $ + * </p> + * + * @author Francois Scharffe + * @author Adrian Mocan + * @author Richard Pöttler + * @version $Revision: 1.6 $ $Date$ + */ +public class PropertyValueRestriction extends PropertyRestriction implements Cloneable { + + Comparator comparator = null; + PathExpression path = null; + InstanceExpression inst = null; + Value value = null; + + /** + * Constructs a attributeValueRestriction with the given restriction. + * + * @param attribute + * the attribute on which the restriction should be applied + * @throws NullPointerException + * if the restriction is null + */ + public PropertyValueRestriction() { + super(); + } + + /** + * Constructs a attributeValueRestriction with the given restriction. + * + * @param attribute + * the attribute on which the restriction should be applied + * @param restriction + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public PropertyValueRestriction(final Comparator comp, final PathExpression p) { + super(); + comparator = comp; + path = p; + } + + public PropertyValueRestriction(final Comparator comp, final Value v) { + super(); + comparator = comp; + value = v; + } + + public PropertyValueRestriction(final Comparator comp, final InstanceExpression i) { + super(); + comparator = comp; + inst = i; + } + + public Comparator getComparator(){ + return comparator; + } + + public void setComparator( Comparator comp ){ + comparator = comp; + } + + public Value getValue(){ + return value; + } + public void setValue( Value v ){ + value = v; + path = null; + inst = null; + } + + public InstanceExpression getInstanceValue(){ + return inst; + } + public void setInstanceValue( InstanceExpression i ){ + inst = i; + value = null; + path = null; + } + + public PathExpression getPath(){ + return path; + } + public void setPath( PathExpression p ){ + path = p; + value = null; + inst = null; + } + + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationCoDomainRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationCoDomainRestriction.java new file mode 100644 index 00000000..ee32644b --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationCoDomainRestriction.java @@ -0,0 +1,74 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.4 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a coDomainRestriction tag for RelationExpressions. + * </p> + * <p> + * $Id: RelationCoDomainRestriction.java,v 1.3 2006/11/15 16:01:17 poettler_ric + * Exp $ + * </p> + * + * @author Richard Pöttler + * @version $Revision: 1.4 $ + * @date $Date$ + * + */ +public class RelationCoDomainRestriction extends RelationRestriction { + + protected ClassExpression codomain = null; + + /** + * Constructs a coDomainRestriction with the given restriction. + * + * @param restriction + * the restriction for the domain + * @throws NullPointerException + * if the restriction is null + */ + public RelationCoDomainRestriction() { + super(); + } + + /** + * Constructs a coDomainRestriction with the given restriction. + * + * @param res + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public RelationCoDomainRestriction(final ClassExpression cod) { + super(); + codomain = cod; + } + + public ClassExpression getCoDomain() { + return codomain; + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationConstruction.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationConstruction.java new file mode 100644 index 00000000..a0b6f375 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationConstruction.java @@ -0,0 +1,113 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 - was RelationExpr + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; +import java.util.HashSet; + +import fr.inrialpes.exmo.align.parser.SyntaxElement.Constructor; +import fr.inrialpes.exmo.align.parser.SyntaxElement; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a RelationExpression. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/RelationExpr.java,v $, + * @version $Revision: 1.5 $ $Date$ + */ + +// JE2010: Should it be abstract with RelationConjunction?? + +public class RelationConstruction extends RelationExpression { + + /** Holds all expressions. */ + private Collection<PathExpression> components; + + /** Operator of this complex expression. */ + private Constructor operator; + + public RelationConstruction() { + super(); + components = new HashSet<PathExpression>(); + } + + public RelationConstruction( Constructor op, Collection<PathExpression> expressions ) { + if ((expressions == null) || (op == null)) { + throw new NullPointerException("The subexpressions and the operator must not be null"); + } + if (expressions.contains(null)) { + throw new IllegalArgumentException("The subexpressions must not contain null"); + } + // The collection should have only relations + // It should be ordered: implement List + this.components = expressions; + if ( op != SyntaxElement.AND.getOperator() && + op != SyntaxElement.OR.getOperator() && + op != SyntaxElement.NOT.getOperator() && + op != SyntaxElement.COMPOSE.getOperator() && + op != SyntaxElement.TRANSITIVE.getOperator() && + op != SyntaxElement.SYMMETRIC.getOperator() && + op != SyntaxElement.REFLEXIVE.getOperator() && + op != SyntaxElement.INVERSE.getOperator() ) { + throw new IllegalArgumentException( "Incorrect operator for relation : "+op ); + } + this.operator = op; + } + + public Constructor getOperator() { + return operator; + } + + public void setOperator( Constructor op ) { + operator = op; + } + + public Collection<PathExpression> getComponents() { + return components; + } + + public void addComponents( RelationExpression exp ) { + components.add( exp ); + } + + /* + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + */ + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationDomainRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationDomainRestriction.java new file mode 100644 index 00000000..d107b848 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationDomainRestriction.java @@ -0,0 +1,80 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.4 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Represents a domainRestriction tag for RelationExpressions. + * </p> + * <p> + * $Id: RelationDomainRestriction.java,v 1.4 2006/11/27 16:39:08 poettler_ric Exp $ + * </p> + * + * @author Richard Pöttler + * @version $Revision: 1.4 $ + * @date $Date$ + * + */ +public class RelationDomainRestriction extends RelationRestriction { + + private ClassExpression domain = null; + /** + * Constructs a domainRestiction with the given restriction. + * + * @param restriction + * the restriction for the domain + * @throws NullPointerException + * if the restriction is null + */ + public RelationDomainRestriction() { + super(); + } + + /** + * Constructs a domainRestiction with the given restriction. + * + * @param res + * the restriction for the domain + * @param target + * the target expression which should be restricted + * @throws NullPointerException + * if the restriction is null + */ + public RelationDomainRestriction(final ClassExpression dom) { + super(); + domain = dom; + } + + public ClassExpression getDomain() { + return domain; + } + + public void getDomain( ClassExpression dom ) { + domain = dom; + } + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationExpression.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationExpression.java new file mode 100644 index 00000000..c6382edc --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationExpression.java @@ -0,0 +1,61 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + + +/** + * <p> + * Represents a RelationExpression. + * </p> + * + * @author Francois Scharffe, Adrian Mocan + * + * Created on 23-Mar-2005 Committed by $Author: adrianmocan $ + * + * $Source: + * /cvsroot/mediation/mappingapi/src/fr.inrialpes.exmo.align.impl.edoal/RelationExpr.java,v $, + * @version $Revision: 1.5 $ $Date$ + */ + +public abstract class RelationExpression extends PathExpression implements Cloneable, Visitable { + + public RelationExpression() { + super(); + } + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + /* + public Object clone() { + return super.clone(); + } + */ + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java new file mode 100644 index 00000000..3255100f --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java @@ -0,0 +1,109 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 -- then RelationExpr + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.semanticweb.owl.align.AlignmentException; + +/** + * A simple Id to represent a Relation. + * + * @author richi + * + */ +public class RelationId extends RelationExpression implements Id { + /** Holds the identifier. */ + private String id; + + URI uri; + + public RelationId(final String id) throws AlignmentException { + if (id == null) { + throw new NullPointerException("The id must not be null"); + } + if (id.length() <= 0) { + throw new IllegalArgumentException( + "The id must be longer than 0 characters"); + } + this.id = id; + try { + uri = new URI( id ); + } catch ( URISyntaxException mfuex ) { + throw new AlignmentException( "Not an URI "+id, mfuex ); + } + } + + public RelationId( final URI u ) { + if ( u == null ) { + throw new NullPointerException("The URI must not be null"); + } + uri = u; + id = u.toString(); + } + + public URI getURI(){ + return uri; + } + + public String plainText() { + return id; + } + + /** + * <p> + * Returns a simple description of this object. <b>The format of the + * returned String is undocumented and subject to change.</b> + * <p> + * <p> + * An expamle return String could be: + * <code>RelationId: http://my/super/class</code> + * </p> + */ + public String toString() { + return "RelationId: " + id; + } + + public int hashCode() { + int result = 17; + result = result * 37 + uri.hashCode(); + return result; + } + + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RelationId)) { + return false; + } + RelationId i = (RelationId) obj; + return id.equals(i.id); + } + /* + public Object clone() { + return super.clone(); + } + */ +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationRestriction.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationRestriction.java new file mode 100644 index 00000000..aea2ef71 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationRestriction.java @@ -0,0 +1,59 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.5 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Superclass for all RelationConditions. + * </p> + * <p> + * To successfully subclass this class the <code>clone</code> and + * <code>equals</code> methods must be overwritten. And if new fields were + * introduced, the <code>hashCode</code> and <code>toString</code> methods, + * too. + * </p> + * <p> + * Created on 23-Mar-2005 Committed by $Author: poettler_ric $ + * </p> + * <p> + * $Id: RelationCondition.java,v 1.5 2006/11/27 16:39:08 poettler_ric Exp $ + * </p> + * + * + * @author Richard Pöttler + * @author Francois Scharffe + * @version $Revision: 1.5 $ $Date$ + */ +public abstract class RelationRestriction extends RelationExpression implements Visitable { + + protected RelationRestriction() {} + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/TransfService.java b/src/fr/inrialpes/exmo/align/impl/edoal/TransfService.java new file mode 100644 index 00000000..bf3c8ac4 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/TransfService.java @@ -0,0 +1,213 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.2 - 2006 + * Copyright (C) INRIA, 2009 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.net.URI; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +/** + * <p> + * Represents a tranformation service to transform the values of attributes. + * </p> + * <p> + * In the specification a {@code transf} is a local transformaion + * function/service. The {@code pov} specifies the parameters needed for the + * function to compute the transformaion. + * </p> + * <p> + * In the specification a {@code service} is a remote transformaion + * function/service. The {@code id} distiguishes between multiple transformation + * function at the given address. The {@code pov} specifies the parameters + * needed for the function to compute the transformaion. + * </p> + * <p> + * $Id: TransfService.java,v 1.2 2006/12/06 12:54:09 poettler_ric Exp $ + * </p> + * + * @author richi + * @version $Revision: 1.2 $ + * @date $Date$ + */ +public class TransfService implements Cloneable, Visitable { + /** resource (uri) to the service */ + private URI res; + + /** id of the transformation function (only used if it is a service) */ + private URI id; + + /** paramteters for the transformation */ + private Set<Id> params; + + /** + * <p> + * Constructs a transf. + * </p> + * + * @param res + * uri to the service + * @param params + * parameters for the transformation + * @throws NullPointerException + * if the res is {@code null} + */ + public TransfService(final URI res, final Collection<Id> params) { + this(res, null, params); + } + + public void accept(AlignmentVisitor visitor) throws AlignmentException { + visitor.visit(this); + } + + /** + * <p> + * Constructs a service. + * </p> + * + * @param res + * uri to the service + * @param id + * id of the transformation function + * @param params + * parameters for the transformation + * @throws NullPointerException + * if the res is {@code null} + */ + @SuppressWarnings( "unchecked" ) + public TransfService(final URI res, final URI id, + final Collection<Id> params) { + if (res == null) { + throw new NullPointerException("The resource must not be null"); + } + this.res = res; + this.id = id; + if (params == null) { + // The unchecked would be solved by creating an empty hashset + this.params = (Set<Id>)Collections.EMPTY_SET;//[W:uncheked] + } else { + this.params = new HashSet<Id>(params); + this.params.remove(null); + } + } + + /** + * Returns the resource / uri to the transformation. + * + * @return the uri to the transformator + */ + public URI getRes() { + return res; + } + + /** + * Returns the id of the transformation function. This function only returns + * a usable value (another value than {@code null}) if it is a service. + * + * @return the id of the function + * @see #hasId() + */ + public URI getId() { + return id; + } + + /** + * Returns an unmodifiable set of parameters needed for the transformation. + * + * @return the set of parameters + */ + public Set<Id> getParameters() { + return Collections.unmodifiableSet(params); + } + + /** + * Returns whether there is a id. + * + * @return {@code true} if there is a usable id, otherwise {@code false} + * @see #getId() + */ + public boolean hasId() { + return id != null; + } + + /** + * <p> + * Returns a short string description of this object. <b>The format of the + * returned string is undocumented and subject to change.</b> + * </p> + * <p> + * An example string could be: + * {@code transf: http://my/super/transf params: [dollar]} + * </p> + */ + public String toString() { + return "transf: " + res + ((id != null) ? " id: " + id : "") + + " params: " + params; + } + + public boolean equals(final Object o) { + if (o == this) { + return true; + } + if (!(o instanceof TransfService)) { + return false; + } + TransfService t = (TransfService) o; + return res.equals(t.res) + && ((id == t.id) || ((id != null) && id.equals(t.id))) + && (params.size() == t.params.size()) + && params.containsAll(t.params); + } + + public int hashCode() { + int hash = 17; + hash = hash * 37 + res.hashCode(); + hash = hash * 37 + ((id != null) ? id.hashCode() : 0); + hash = hash * 37 + params.hashCode(); + return hash; + } + + @SuppressWarnings( "unchecked" ) + public Object clone() { + try { + TransfService clone = (TransfService) super.clone(); + // JE: noclone on URI + //clone.res = (URI) res.clone(); + clone.res = res; + clone.params = (params.isEmpty()) ? Collections.EMPTY_SET //[W:unchecked] + : new HashSet<Id>(params); + // JE: noclone on URI + //clone.id = (id == null) ? null : (URI) id.clone(); + clone.id = (id == null) ? null : id; + return clone; + } catch (CloneNotSupportedException e) { + assert true : "Object is always cloneable"; + } + return null; + } +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Value.java b/src/fr/inrialpes/exmo/align/impl/edoal/Value.java new file mode 100644 index 00000000..3a2ce50f --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Value.java @@ -0,0 +1,99 @@ +/* + * $Id$ + * + * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck + * Sourceforge version 1.2 - 2006 + * Copyright (C) INRIA, 2009-2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +/** + * <p> + * Id to represent a simple valuestring. + * </p> + * <p> + * $Id: Value.java,v 1.2 2006/10/30 15:24:43 poettler_ric Exp $ + * </p> + * + * @author richi + * @version $Revision: 1.2 $ + * @date $Date$ + */ +public class Value { //implements Cloneable, Visitable { + + /** Holds the value */ + private String value; + + /** + * Constructs an object with the given value. + * + * @param value + * the value for this object. + * @throws NullPointerException + * if the value is {@code null} + * @throws IllegalArgumentException + * if the value isn't longer than 0 + */ + public Value( final String value ) { + if (value == null) { + throw new NullPointerException("The value must not be null"); + } + this.value = value; + } + + // public void accept(AlignmentVisitor visitor) throws AlignmentException { + // visitor.visit(this); + // } + + public String plainText() { + return value; + } + + public int hashCode() { + return value.hashCode(); + } + + public boolean equals(final Object o) { + if ( o == this ) { + return true; + } + if (!(o instanceof Value)) { + return false; + } + Value s = (Value) o; + return value.equals(s.value); + } + /* + public Object clone() { + return super.clone(); + } + */ + + /** + * <p> + * Returns a short description about this object. <b>The format of the + * returned string is undocumentd and subject to change.</b> + * </p> + * <p> + * An example return string could be: {@code 15} + * </p> + */ + public String toString() { + return value; + } +} diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ValueConstraint.java b/src/fr/inrialpes/exmo/align/impl/edoal/ValueConstraint.java new file mode 100644 index 00000000..932df32d --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ValueConstraint.java @@ -0,0 +1,47 @@ +/* + * $Id$ + * + * Copyright (C) INRIA, 2010 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.impl.edoal; + +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.Visitable; + +public class ValueConstraint implements Cloneable, Visitable { + + // JE: 2010 this must be replaced by path-or-value + Value value = null; + Comparator comparator; + + public ValueConstraint() { + super(); + } + + public ValueConstraint( Value v, Comparator comp ) { + super(); + value = v; + comparator = comp; + } + + public void accept( AlignmentVisitor visitor ) throws AlignmentException { + visitor.visit(this); + } + +} -- GitLab