diff --git a/build.xml b/build.xml index a675aa8ed1bc97a6b8f670cb25c8844767fc8830..10ed0390e42759abf687252cd96d990f2156e07f 100644 --- a/build.xml +++ b/build.xml @@ -42,6 +42,7 @@ <property name="jarclasspath" value="mappingapilite.jar api.jar impl.jar io.jar rdfparser.jar getopt.jar commons-logging.jar log4j.jar rdfapi.jar align.jar procalign.jar"/> + <!-- this is useful but introduces, Xlint:path warnings --> <path id="classpath"> <fileset dir="./lib"> <include name="*.jar"/> @@ -72,7 +73,7 @@ <!-- tested --> <target name="lint" depends="init"> - <!-- values: all, deprecation, unchecked, fallthrough, path, serial, finally --> + <!-- values: all, deprecation, unchecked[3], fallthrough, path[5], serial, finally --> <echo message="Setting property..."/> <property name="javacargs" value="-Xlint:all" /> <antcall target="compileall"/> diff --git a/html/relnotes.html b/html/relnotes.html index 0d492e3a8eb2de41561e1ddce71d4cd34481b15b..4942418bb8a98397e1e6fca62ea41a2a0e5d29f8 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -22,14 +22,18 @@ <li>Restructuring language dependent alignments (impl)</li> <li>Implementing database store for OMWG Language (server)</li> <li>Replacing <tt>Parameters</tt> with Java <tt>Property</tt> (api/impl)</li> -<li>Pass all code through lint</li> -<li>Moving all construct to full Java 1.5</li> +<li>Use more for-each Java 1.5 construct</li> </ul></p> <h2>Current SVN trunk version</h2> <!--h2>Version 3.3 (): xx/yy/2008 - O sole mio</h2--> +<p><ul compact="1"> +<li>Passed to Java 1.5 generics [incl. API modif] (dev/api)</li> +<li>Passed all code through lint (dev)</li> +</ul></p> + <h2>Version 3.2 (666): 29/02/2008 - Blejsko jezero</h2> <p> <ul compact="1"> diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/NavigationView.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/NavigationView.java index bd5cc88212619eae8abc2cc86a7c0346dd0368bb..96ea98dc7a40085ba96afe41664c93dec54b64aa 100755 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/NavigationView.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/NavigationView.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rh�ne-Alpes, 2007-2008 + * Copyright (C) INRIA Rhône-Alpes, 2007-2008 * * 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 @@ -104,10 +104,10 @@ public class NavigationView extends ViewPart { } class TreeParent extends TreeObject { - private ArrayList children; + private ArrayList<TreeObject> children; public TreeParent(String name) { super(name); - children = new ArrayList(); + children = new ArrayList<TreeObject>(); } public void addChild(TreeObject child) { children.add(child); @@ -247,4 +247,4 @@ public class NavigationView extends ViewPart { public void setFocus() { viewer.getControl().setFocus(); } -} \ No newline at end of file +} diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java index 4454769259cbcb4c0fa37fd3123743b3f88d87f5..6926e06666a7a560812559fffb60ef2306ece640 100644 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rh�ne-Alpes, 2007-2008 + * Copyright (C) INRIA Rhône-Alpes, 2007-2008 * * 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 @@ -72,7 +72,9 @@ import com.ontoprise.ontostudio.gui.navigator.project.ProjectControl; //import org.eclipse.core.runtime.IProgressMonitor; public class SWTInterface extends JPanel { - + + private static final long serialVersionUID = 330; + private static JSplitPane _mainSplitter = new JSplitPane (JSplitPane.VERTICAL_SPLIT); //private URL SOAPUrl = null; @@ -1145,9 +1147,9 @@ private void refreshOntoList() { } - public static Vector getCorresFromAnswer( String answer, String type ,String separator) { + public static Vector<String[]> getCorresFromAnswer( String answer, String type ,String separator) { Document doc=null; - Vector names= new Vector(); + Vector<String[]> names = new Vector<String[]>(); //File message=null; //System.out.println( "displaying XML ..." ); answer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + answer; diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java index f937239a4ef710776ec5afc0324c2c3561fefe34..90738ec7ea39d50ee08c7ddcf027f2b39c7b7546 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java @@ -70,9 +70,9 @@ public class BasicAlignment implements Alignment { protected String type = "**"; - protected Hashtable hash1 = null; + protected Hashtable<Object,Set<Cell>> hash1 = null; - protected Hashtable hash2 = null; + protected Hashtable<Object,Set<Cell>> hash2 = null; protected long time = 0; @@ -87,8 +87,8 @@ public class BasicAlignment implements Alignment { */ public BasicAlignment() { - hash1 = new Hashtable(); - hash2 = new Hashtable(); + hash1 = new Hashtable<Object,Set<Cell>>(); + hash2 = new Hashtable<Object,Set<Cell>>(); extensions = new BasicParameters(); namespaces = new BasicParameters(); if ( this instanceof AlignmentProcess ) setExtension( Annotations.ALIGNNS, Annotations.METHOD, getClass().getName() ); @@ -117,7 +117,7 @@ public class BasicAlignment implements Alignment { public int nbCells() { int sum = 0; for ( Enumeration e = hash1.elements(); e.hasMoreElements(); ) { - sum += ((HashSet)e.nextElement()).size(); + sum += ((Set)e.nextElement()).size(); } return sum; } @@ -203,12 +203,12 @@ public class BasicAlignment implements Alignment { return (String)namespaces.getParameter( label ); }; - public Enumeration getElements() { - return new MEnumeration( hash1 ); + public Enumeration<Cell> getElements() { + return new MEnumeration<Cell>( hash1 ); } - public ArrayList getArrayElements() { - ArrayList array = new ArrayList(); + public ArrayList<Cell> getArrayElements() { + ArrayList<Cell> array = new ArrayList<Cell>(); for (Enumeration e = getElements(); e.hasMoreElements(); ) { array.add( (BasicCell)e.nextElement() ); } @@ -244,7 +244,7 @@ public class BasicAlignment implements Alignment { protected void addCell( Cell c ) throws AlignmentException { boolean found = false; - HashSet s1 = (HashSet)hash1.get(c.getObject1()); + Set<Cell> s1 = (Set<Cell>)hash1.get(c.getObject1()); if ( s1 != null ) { // I must check that there is no one here for (Iterator i = s1.iterator(); !found && i.hasNext(); ) { @@ -252,12 +252,12 @@ public class BasicAlignment implements Alignment { } if (!found) s1.add( c ); } else { - s1 = new HashSet(); + s1 = new HashSet<Cell>(); s1.add( c ); hash1.put(c.getObject1(),s1); } found = false; - HashSet s2 = (HashSet)hash2.get(c.getObject2()); + Set<Cell> s2 = (Set<Cell>)hash2.get(c.getObject2()); if( s2 != null ){ // I must check that there is no one here for (Iterator i=s2.iterator(); !found && i.hasNext(); ) { @@ -265,17 +265,17 @@ public class BasicAlignment implements Alignment { } if (!found) s2.add( c ); } else { - s2 = new HashSet(); + s2 = new HashSet<Cell>(); s2.add( c ); hash2.put(c.getObject2(),s2); } } - public Set getAlignCells1(Object ob) throws AlignmentException { - return (HashSet)hash1.get( ob ); + public Set<Cell> getAlignCells1(Object ob) throws AlignmentException { + return hash1.get( ob ); } - public Set getAlignCells2(Object ob) throws AlignmentException { - return (HashSet)hash2.get( ob ); + public Set<Cell> getAlignCells2(Object ob) throws AlignmentException { + return hash2.get( ob ); } /* @@ -381,8 +381,8 @@ public class BasicAlignment implements Alignment { // JE: beware this does only remove the exact equal cell // not those with same value public void removeAlignCell(Cell c) throws AlignmentException { - HashSet s1 = (HashSet)hash1.get(c.getObject1()); - HashSet s2 = (HashSet)hash2.get(c.getObject2()); + Set<Cell> s1 = hash1.get(c.getObject1()); + Set<Cell> s2 = hash2.get(c.getObject2()); s1.remove(c); s2.remove(c); if (s1.isEmpty()) @@ -428,7 +428,7 @@ public class BasicAlignment implements Alignment { throw new AlignmentException( "Not a percentage or threshold : "+threshold ); // Create a sorted list of cells // For sure with sorted lists, we could certainly do far better - List buffer = getArrayElements(); + List<Cell> buffer = getArrayElements(); Collections.sort( buffer ); int size = buffer.size(); boolean found = false; @@ -517,7 +517,7 @@ public class BasicAlignment implements Alignment { // TODO type and level // TODO extension for ( Enumeration e = getElements() ; e.hasMoreElements(); ){ - Cell c1 = (Cell) e.nextElement(); + Cell c1 = (Cell)e.nextElement(); Set<Cell> cells2 = align.getAlignCells1(c1.getObject2()); if (cells2 !=null) { for (Cell c2 : cells2) { @@ -621,26 +621,26 @@ public class BasicAlignment implements Alignment { } -class MEnumeration implements Enumeration { - private Enumeration set = null; // The enumeration of sets - private Iterator current = null; // The current set's enumeration +class MEnumeration<T> implements Enumeration<T> { + private Enumeration<Set<T>> set = null; // The enumeration of sets + private Iterator<T> current = null; // The current set's enumeration - MEnumeration( Hashtable s ){ + MEnumeration( Hashtable<Object,Set<T>> s ){ set = s.elements(); while( set.hasMoreElements() && current == null ){ - current = ((Set)set.nextElement()).iterator(); + current = set.nextElement().iterator(); if( !current.hasNext() ) current = null; } } public boolean hasMoreElements(){ return ( current != null); } - public Object nextElement(){ - Object val = current.next(); + public T nextElement(){ + T val = current.next(); if( !current.hasNext() ){ current = null; while( set.hasMoreElements() && current == null ){ - current = ((Set)set.nextElement()).iterator(); + current = set.nextElement().iterator(); if( !current.hasNext() ) current = null; } } diff --git a/src/fr/inrialpes/exmo/align/impl/BasicCell.java b/src/fr/inrialpes/exmo/align/impl/BasicCell.java index 5e988621677ac819472e6e0123d640bdea1c88f9..0e97b6db4d1ec490daffb4b3a525312b82a7519a 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicCell.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicCell.java @@ -39,7 +39,7 @@ import org.semanticweb.owl.align.Parameters; * @version $Id$ */ -public class BasicCell implements Cell, Comparable { +public class BasicCell implements Cell, Comparable<Cell> { public void accept( AlignmentVisitor visitor) throws AlignmentException { visitor.visit( this ); } @@ -76,10 +76,10 @@ public class BasicCell implements Cell, Comparable { * Used to order the cells in an alignment: * -- this > c iff this.getStrength() < c.getStrength() -- */ - public int compareTo( Object c ){ + public int compareTo( Cell c ){ //if ( ! (c instanceof Cell) ) return 1; - if ( ((Cell)c).getStrength() > getStrength() ) return 1; - if ( getStrength() > ((Cell)c).getStrength() ) return -1; + if ( c.getStrength() > getStrength() ) return 1; + if ( getStrength() > c.getStrength() ) return -1; return 0; } diff --git a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java index ddf2c39c0b37d7bfa438a5218872e232d39eb2e2..ee6f1c7840f706b2b6c1db395ce07b90d6dd655c 100644 --- a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2007 + * Copyright (C) INRIA Rhône-Alpes, 2003-2008 * * 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 @@ -338,35 +338,30 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce } else { throw new ClassCastException(); }}});*/ - SortedSet cellSet = new TreeSet( - new Comparator() { - public int compare( Object o1, Object o2 ) + SortedSet<Cell> cellSet = new TreeSet<Cell>( + new Comparator<Cell>() { + public int compare( Cell o1, Cell o2 ) throws ClassCastException{ try { - //System.err.println(((Cell)o1).getObject1()+" -- "+((Cell)o1).getObject2()+" // "+((Cell)o2).getObject1()+" -- "+((Cell)o2).getObject2()); - if ( o1 instanceof Cell - && o2 instanceof Cell ) { - if ( ((Cell)o1).getStrength() > ((Cell)o2).getStrength() ){ + //System.err.println(o1.getObject1()+" -- "+o1.getObject2()+" // "+o2.getObject1()+" -- "+o2.getObject2()); + if ( o1.getStrength() > o2.getStrength() ){ return -1; - } else if ( ((Cell)o1).getStrength() < ((Cell)o2).getStrength() ){ + } else if ( o1.getStrength() < o2.getStrength() ){ return 1; - } else if ( (((OWLEntity)((Cell)o1).getObject1()).getURI().getFragment() == null) - || (((OWLEntity)((Cell)o2).getObject1()).getURI().getFragment() == null) ) { + } else if ( (((OWLEntity)o1.getObject1()).getURI().getFragment() == null) + || (((OWLEntity)o2.getObject1()).getURI().getFragment() == null) ) { return -1; - } else if ( ((OWLEntity)((Cell)o1).getObject1()).getURI().getFragment().compareTo(((OWLEntity)((Cell)o2).getObject1()).getURI().getFragment()) > 0) { + } else if ( ((OWLEntity)o1.getObject1()).getURI().getFragment().compareTo(((OWLEntity)o2.getObject1()).getURI().getFragment()) > 0) { return -1; - } else if ( ((OWLEntity)((Cell)o1).getObject1()).getURI().getFragment().compareTo(((OWLEntity)((Cell)o2).getObject1()).getURI().getFragment()) < 0 ) { + } else if ( ((OWLEntity)o1.getObject1()).getURI().getFragment().compareTo(((OWLEntity)o2.getObject1()).getURI().getFragment()) < 0 ) { return 1; - } else if ( (((OWLEntity)((Cell)o1).getObject2()).getURI().getFragment() == null) - || (((OWLEntity)((Cell)o2).getObject2()).getURI().getFragment() == null) ) { + } else if ( (((OWLEntity)o1.getObject2()).getURI().getFragment() == null) + || (((OWLEntity)o2.getObject2()).getURI().getFragment() == null) ) { return -1; - } else if ( ((OWLEntity)((Cell)o1).getObject2()).getURI().getFragment().compareTo(((OWLEntity)((Cell)o2).getObject2()).getURI().getFragment()) > 0) { + } else if ( ((OWLEntity)o1.getObject2()).getURI().getFragment().compareTo(((OWLEntity)o2.getObject2()).getURI().getFragment()) > 0) { return -1; // On va supposer qu'ils n'ont pas le meme nom } else { return 1; } - } else { - throw new ClassCastException(); - } } catch ( OWLException e) { e.printStackTrace(); return 0;} } diff --git a/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java b/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java index 99b282f7e4c5a9c70f951e86ee06424247e41246..4d231e863cd17040fa4fc969c6fa8a5a40e66331 100644 --- a/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java +++ b/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2007 + * Copyright (C) INRIA Rhône-Alpes, 2003-2008 * * 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 @@ -59,12 +59,12 @@ public abstract class MatrixMeasure implements Similarity { public int nbind2 = 0; // number of individuals in onto2 public int i, j = 0; // index for onto1 and onto2 classes public int l1, l2 = 0; // length of strings (for normalizing) - public HashMap classlist2 = null; // onto2 classes - public HashMap classlist1 = null; // onto1 classes - public HashMap proplist2 = null; // onto2 properties - public HashMap proplist1 = null; // onto1 properties - public HashMap indlist2 = null; // onto2 individuals - public HashMap indlist1 = null; // onto1 individuals + public HashMap<OWLClass,Integer> classlist2 = null; // onto2 classes + public HashMap<OWLClass,Integer> classlist1 = null; // onto1 classes + public HashMap<OWLProperty,Integer> proplist2 = null; // onto2 properties + public HashMap<OWLProperty,Integer> proplist1 = null; // onto1 properties + public HashMap<OWLIndividual,Integer> indlist2 = null; // onto2 individuals + public HashMap<OWLIndividual,Integer> indlist1 = null; // onto1 individuals private NumberFormat numFormat = null; // printing @@ -80,35 +80,35 @@ public abstract class MatrixMeasure implements Similarity { public void initialize( OWLOntology o1, OWLOntology o2 ){ onto1 = o1; onto2 = o2; - classlist2 = new HashMap(); // onto2 classes - classlist1 = new HashMap(); // onto1 classes - proplist2 = new HashMap(); // onto2 properties - proplist1 = new HashMap(); // onto1 properties - indlist2 = new HashMap(); // onto2 instances - indlist1 = new HashMap(); // onto1 instances + classlist2 = new HashMap<OWLClass,Integer>(); // onto2 classes + classlist1 = new HashMap<OWLClass,Integer>(); // onto1 classes + proplist2 = new HashMap<OWLProperty,Integer>(); // onto2 properties + proplist1 = new HashMap<OWLProperty,Integer>(); // onto1 properties + indlist2 = new HashMap<OWLIndividual,Integer>(); // onto2 instances + indlist1 = new HashMap<OWLIndividual,Integer>(); // onto1 instances try { // Create class lists for ( Iterator it = onto2.getClasses().iterator(); it.hasNext(); nbclass2++ ){ - classlist2.put( it.next(), new Integer(nbclass2) ); + classlist2.put( (OWLClass)it.next(), new Integer(nbclass2) ); } for ( Iterator it = onto1.getClasses().iterator(); it.hasNext(); nbclass1++ ){ - classlist1.put( it.next(), new Integer(nbclass1) ); + classlist1.put( (OWLClass)it.next(), new Integer(nbclass1) ); } clmatrix = new double[nbclass1+1][nbclass2+1]; // Create property lists for ( Iterator it = onto2.getObjectProperties().iterator(); it.hasNext(); nbprop2++ ){ - proplist2.put( it.next(), new Integer(nbprop2) ); + proplist2.put( (OWLProperty)it.next(), new Integer(nbprop2) ); } for ( Iterator it = onto2.getDataProperties().iterator(); it.hasNext(); nbprop2++ ){ - proplist2.put( it.next(), new Integer(nbprop2) ); + proplist2.put( (OWLProperty)it.next(), new Integer(nbprop2) ); } for ( Iterator it = onto1.getObjectProperties().iterator(); it.hasNext(); nbprop1++ ){ - proplist1.put( it.next(), new Integer(nbprop1) ); + proplist1.put( (OWLProperty)it.next(), new Integer(nbprop1) ); } for ( Iterator it = onto1.getDataProperties().iterator(); it.hasNext(); nbprop1++ ){ - proplist1.put( it.next(), new Integer(nbprop1) ); + proplist1.put( (OWLProperty)it.next(), new Integer(nbprop1) ); } prmatrix = new double[nbprop1+1][nbprop2+1]; // Create individual lists diff --git a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java index 79be8166e8889d6b43f854a89dd3bf6c8a924234..c605b49d031f4d4117c0f7dd589a3b7e0c71323d 100644 --- a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java @@ -191,14 +191,14 @@ public class OWLAPIAlignment extends BasicAlignment { return (Cell)new OWLAPICell( id, (OWLEntity)ob1, (OWLEntity)ob2, relation, measure); } - public Set getAlignCells1(Object ob) throws AlignmentException { + public Set<Cell> getAlignCells1(Object ob) throws AlignmentException { if ( ob instanceof OWLEntity ){ return super.getAlignCells1( ob ); } else { throw new AlignmentException("argument must be OWLEntity"); } } - public Set getAlignCells2(Object ob) throws AlignmentException { + public Set<Cell> getAlignCells2(Object ob) throws AlignmentException { if ( ob instanceof OWLEntity ){ return super.getAlignCells2( ob ); } else { diff --git a/src/fr/inrialpes/exmo/align/impl/OntologyCache.java b/src/fr/inrialpes/exmo/align/impl/OntologyCache.java index b1abbeca6475626a54c42f8e39ae63bfac4642bc..986bdfd5c5280d4e7853c91bc43d1f92a31120d4 100644 --- a/src/fr/inrialpes/exmo/align/impl/OntologyCache.java +++ b/src/fr/inrialpes/exmo/align/impl/OntologyCache.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2007 + * Copyright (C) INRIA Rhône-Alpes, 2007-2008 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -44,14 +44,14 @@ public class OntologyCache { * URI --> Ontology * This is the ontology URI, NOT its filename */ - Hashtable ontologies = null; + Hashtable<URI,Object> ontologies = null; public OntologyCache() { - ontologies = new Hashtable(); + ontologies = new Hashtable<URI,Object>(); } public void recordOntology( URI uri, Object ontology ){ - ontologies.put((Object)uri,ontology); + ontologies.put(uri,ontology); } public OWLOntology getOntology( URI uri ){ @@ -60,7 +60,7 @@ public class OntologyCache { public void unloadOntology( URI uri, Object ontology ){ // used to be uri.toString(); - Object o = ontologies.get((Object)uri); + Object o = ontologies.get(uri); try { if ( o instanceof OWLOntology && o == ontology ) ((OWLOntology)o).getOWLConnection().notifyOntologyDeleted( ((OWLOntology)o) ); diff --git a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java index 59085d10ec9148131728113fa76db71726808adb..a7fe1b87c2609dc82860d10eab98085077d48d8d 100644 --- a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java @@ -110,17 +110,17 @@ public class URIAlignment extends BasicAlignment { } // Actually I should search them with equals() but this is what is supposed to be used - public Set getAlignCells1(Object ob) throws AlignmentException { + public Set<Cell> getAlignCells1(Object ob) throws AlignmentException { if ( ob instanceof URI ){ - return (HashSet)hash1.get( (URI)ob ); + return hash1.get( (URI)ob ); // return super.getAlignCells1( ob ); } else { throw new AlignmentException("arguments must be URIs"); } } - public Set getAlignCells2(Object ob) throws AlignmentException { + public Set<Cell> getAlignCells2(Object ob) throws AlignmentException { if ( ob instanceof URI ){ - return (HashSet)hash2.get( (URI)ob ); + return hash2.get( (URI)ob ); // return super.getAlignCells2( ob ); } else { throw new AlignmentException("arguments must be URIs"); diff --git a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java index 908677e8f87cb014fddf0bc73c5fe10455fb8d05..1e0f3595f92be4630772171c3e67ed158527dddf 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2004-2007 + * Copyright (C) INRIA Rhône-Alpes, 2004-2008 * * 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 @@ -202,15 +202,16 @@ public class ExtPREvaluator extends BasicEvaluator { public int isSuperClass( OWLClass class1, OWLClass class2, OWLOntology ontology ) throws OWLException { URI uri1 = class1.getURI(); - Set superclasses = new HashSet(); + Set<OWLEntity> superclasses = new HashSet<OWLEntity>(); // required for avoiding java.util.ConcurrentModificationException - Set bufferedSuperClasses = null; + Set<OWLEntity> bufferedSuperClasses = null; int level = 0; - superclasses.addAll(class2.getSuperClasses( ontology )); + // [Warning:unchecked] due to OWL API not serving generic types + superclasses.addAll( class2.getSuperClasses( ontology )); // [W:unchecked] while ( !superclasses.isEmpty() ){ bufferedSuperClasses = superclasses; - superclasses = new HashSet(); + superclasses = new HashSet<OWLEntity>(); Iterator it = bufferedSuperClasses.iterator(); level++; for( ; it.hasNext() ; ){ @@ -221,7 +222,8 @@ public class ExtPREvaluator extends BasicEvaluator { if ( uri1.toString().equals(uri2.toString()) ) { return level; } else { - superclasses.addAll(((OWLClass)entity).getSuperClasses( ontology )); + // [Warning:unchecked] due to OWL API not serving generic types + superclasses.addAll(((OWLClass)entity).getSuperClasses( ontology )); // [W:unchecked] } } } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java index 40af58c31ce31da3224105b599d3852182ef318c..1e7fc6e9b756fd04cfa1da5dffcf3f75f4134109 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java @@ -66,7 +66,7 @@ public class PRGraphEvaluator extends BasicEvaluator { // The eleven values of precision and recall private double[] precisions = null; - private Vector points; + private Vector<Pair> points; /** Creation: * A priori, evaluators can deal with any kind of alignments. @@ -77,7 +77,7 @@ public class PRGraphEvaluator extends BasicEvaluator { if ( align1.getClass() != align2.getClass() ) { // This should throw an exception... } - points = new Vector(); + points = new Vector<Pair>(); } /** @@ -103,9 +103,9 @@ public class PRGraphEvaluator extends BasicEvaluator { // Create a sorted structure in which putting the cells // TreeSet could be replaced by something else - SortedSet cellSet = new TreeSet( - new Comparator() { - public int compare( Object o1, Object o2 ) + SortedSet<Cell> cellSet = new TreeSet<Cell>( + new Comparator<Cell>() { + public int compare( Cell o1, Cell o2 ) throws ClassCastException{ try { //System.err.println(((Cell)o1).getObject1()+" -- "+((Cell)o1).getObject2()+" // "+((Cell)o2).getObject1()+" -- "+((Cell)o2).getObject2()); @@ -138,7 +138,7 @@ public class PRGraphEvaluator extends BasicEvaluator { // Set the found cells in the sorted structure for (Enumeration e = align2.getElements(); e.hasMoreElements();) { - cellSet.add( e.nextElement() ); + cellSet.add( (Cell)e.nextElement() ); } // Collect the points that change recall @@ -183,7 +183,7 @@ public class PRGraphEvaluator extends BasicEvaluator { double level = (double)i/STEP; // max level of that interval double best = 0.; // best value found for that interval while( j >= 0 ){ - Pair precrec = (Pair)points.get(j); + Pair precrec = points.get(j); while ( precrec.getX() < level ){ precisions[i] = best; i--; @@ -220,7 +220,7 @@ public class PRGraphEvaluator extends BasicEvaluator { */ public void writeFullPlot(PrintWriter writer) throws java.io.IOException { for( int j = 0; j < points.size(); j++ ){ - Pair precrec = (Pair)points.get(j); + Pair precrec = points.get(j); writer.println( precrec.getX()+" "+precrec.getY() ); } } diff --git a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java index 2ec62151e247f8eec5cb7bcda9af179edfd960ed..065fbaf76c59dfb4f33c26eba559557ded2c1018 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2007 + * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2007-2008 * * 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 @@ -30,6 +30,7 @@ import java.lang.reflect.InvocationTargetException; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLProperty; import org.semanticweb.owl.model.OWLRestriction; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLNaryBooleanDescription; @@ -76,8 +77,8 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment //int l1, l2 = 0; // length of strings (for normalizing) int nbclass1 = 0; // number of classes in onto1 int nbclass2 = 0; // number of classes in onto2 - Vector classlist2 = new Vector(10); // onto2 classes - Vector classlist1 = new Vector(10); // onto1 classes + Vector<OWLClass> classlist2 = new Vector<OWLClass>(10); // onto2 classes + Vector<OWLClass> classlist1 = new Vector<OWLClass>(10); // onto1 classes double classmatrix[][]; // class distance matrix double pic1 = 0.5; // class weigth for name double pic2 = 0.5; // class weight for properties @@ -86,10 +87,10 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment try { // Create class lists for ( Iterator it = ((OWLOntology)onto2).getClasses().iterator(); it.hasNext(); nbclass2++ ){ - classlist2.add( it.next() ); + classlist2.add( (OWLClass)it.next() ); } for ( Iterator it = ((OWLOntology)onto1).getClasses().iterator(); it.hasNext(); nbclass1++ ){ - classlist1.add( it.next() ); + classlist1.add( (OWLClass)it.next() ); } classmatrix = new double[nbclass1+1][nbclass2+1]; @@ -114,23 +115,23 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment // (sigma (att in c[i]) getAllignCell... ) // / nbatts of c[i] + nbatts of c[j] for ( i=0; i<nbclass1; i++ ){ - Set properties1 = getProperties( (OWLClass)classlist1.get(i), ((OWLOntology)onto1) ); + Set<OWLProperty> properties1 = getProperties( classlist1.get(i), ((OWLOntology)onto1) ); int nba1 = properties1.size(); if ( nba1 > 0 ) { // if not, keep old values... //Set correspondences = new HashSet(); for ( j=0; j<nbclass2; j++ ){ - Set properties2 = getProperties( (OWLClass)classlist2.get(j), ((OWLOntology)onto2) ); + Set<OWLProperty> properties2 = getProperties( classlist2.get(j), ((OWLOntology)onto2) ); int nba2 = properties1.size(); double attsum = 0.; // check that there is a correspondance // in list of class2 atts and add their weights - for ( Iterator prp = properties1.iterator(); prp.hasNext(); ){ - Set s2 = getAlignCells1( (OWLEntity)prp.next() ); + for ( OWLProperty prp : properties1 ){ + Set<Cell> s2 = (Set<Cell>)getAlignCells1( prp ); // Find the property with the higest similarity // that is matched here double currentValue = 0.; - for( Iterator it2 = s2.iterator(); it2.hasNext(); ){ - Cell c2 = (Cell)it2.next(); + for( Iterator<Cell> it2 = s2.iterator(); it2.hasNext(); ){ + Cell c2 = it2.next(); if ( properties2.contains((Object)c2.getObject2() ) ) { double val = c2.getStrength(); if ( val > currentValue ) @@ -152,7 +153,7 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment } } - public void getProperties( OWLDescription desc, OWLOntology o, Set list){ + public void getProperties( OWLDescription desc, OWLOntology o, Set<OWLProperty> list){ // I am Jerome Euzenat and I am sure that there is some problem here... // DISPATCHING MANUALLY ! try { @@ -185,15 +186,15 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment e.printStackTrace(); } } - public void getProperties( OWLRestriction rest, OWLOntology o, Set list) throws OWLException { - list.add( (Object)rest.getProperty() ); + public void getProperties( OWLRestriction rest, OWLOntology o, Set<OWLProperty> list) throws OWLException { + list.add( rest.getProperty() ); } - public void getProperties( OWLNaryBooleanDescription d, OWLOntology o, Set list) throws OWLException { + public void getProperties( OWLNaryBooleanDescription d, OWLOntology o, Set<OWLProperty> list) throws OWLException { for ( Iterator it = d.getOperands().iterator(); it.hasNext() ;){ getProperties( (OWLDescription)it.next(), o, list ); } } - public void getProperties( OWLClass cl, OWLOntology o, Set list) throws OWLException { + public void getProperties( OWLClass cl, OWLOntology o, Set<OWLProperty> list) throws OWLException { for ( Iterator it = cl.getSuperClasses(o).iterator(); it.hasNext(); ){ OWLDescription dsc = (OWLDescription)it.next(); getProperties( dsc, o, list ); @@ -204,8 +205,8 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment } } - private Set getProperties( OWLClass cl, OWLOntology o ) throws OWLException { - Set resultSet = new HashSet(); + private Set<OWLProperty> getProperties( OWLClass cl, OWLOntology o ) throws OWLException { + Set<OWLProperty> resultSet = new HashSet<OWLProperty>(); getProperties( cl, o, resultSet ); return resultSet; } diff --git a/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java index c205ac55465014d67b97b97c6d3180408850466d..e05fdff316a951d32f1a803e1b86faee83bc3012 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java @@ -80,13 +80,13 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align //int l1, l2 = 0; // length of strings (for normalizing) int nbclass1 = 0; // number of classes in onto1 int nbclass2 = 0; // number of classes in onto2 - Vector classlist2 = new Vector(10); // onto2 classes - Vector classlist1 = new Vector(10); // onto1 classes + Vector<OWLClass> classlist2 = new Vector<OWLClass>(10); // onto2 classes + Vector<OWLClass> classlist1 = new Vector<OWLClass>(10); // onto1 classes double classmatrix[][]; // class distance matrix int nbprop1 = 0; // number of properties in onto1 int nbprop2 = 0; // number of properties in onto2 - Vector proplist2 = new Vector(10); // onto2 properties - Vector proplist1 = new Vector(10); // onto1 properties + Vector<OWLProperty> proplist2 = new Vector<OWLProperty>(10); // onto2 properties + Vector<OWLProperty> proplist1 = new Vector<OWLProperty>(10); // onto1 properties double propmatrix[][]; // properties distance matrix double pic1 = 0.5; // class weigth for name //double pic2 = 0.5; // class weight for properties @@ -101,25 +101,25 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align try { // Create property lists and matrix for ( Iterator it = ((OWLOntology)getOntology1()).getObjectProperties().iterator(); it.hasNext(); nbprop1++ ){ - proplist1.add( it.next() ); + proplist1.add( (OWLProperty)it.next() ); } for ( Iterator it = ((OWLOntology)getOntology1()).getDataProperties().iterator(); it.hasNext(); nbprop1++ ){ - proplist1.add( it.next() ); + proplist1.add( (OWLProperty)it.next() ); } for ( Iterator it = ((OWLOntology)getOntology2()).getObjectProperties().iterator(); it.hasNext(); nbprop2++ ){ - proplist2.add( it.next() ); + proplist2.add( (OWLProperty)it.next() ); } for ( Iterator it = ((OWLOntology)getOntology2()).getDataProperties().iterator(); it.hasNext(); nbprop2++ ){ - proplist2.add( it.next() ); + proplist2.add( (OWLProperty)it.next() ); } propmatrix = new double[nbprop1+1][nbprop2+1]; // Create class lists for ( Iterator it = ((OWLOntology)getOntology2()).getClasses().iterator(); it.hasNext(); nbclass2++ ){ - classlist2.add( it.next() ); + classlist2.add( (OWLClass)it.next() ); } for ( Iterator it = ((OWLOntology)getOntology1()).getClasses().iterator(); it.hasNext(); nbclass1++ ){ - classlist1.add( it.next() ); + classlist1.add( (OWLClass)it.next() ); } classmatrix = new double[nbclass1+1][nbclass2+1]; @@ -234,7 +234,7 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align } } - public void getProperties( OWLDescription desc, OWLOntology o, Set list){ + public void getProperties( OWLDescription desc, OWLOntology o, Set<OWLProperty> list){ // I am Jerome Euzenat and I am sure that there is some problem here... // DISPATCHING MANUALLY ! try { @@ -260,15 +260,15 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align e.printStackTrace(); } } - public void getProperties( OWLRestriction rest, OWLOntology o, Set list) throws OWLException { - list.add( (Object)rest.getProperty() ); + public void getProperties( OWLRestriction rest, OWLOntology o, Set<OWLProperty> list) throws OWLException { + list.add( rest.getProperty() ); } - public void getProperties( OWLNaryBooleanDescription d, OWLOntology o, Set list) throws OWLException { + public void getProperties( OWLNaryBooleanDescription d, OWLOntology o, Set<OWLProperty> list) throws OWLException { for ( Iterator it = d.getOperands().iterator(); it.hasNext() ;){ getProperties( (OWLDescription)it.next(), o, list ); } } - public void getProperties( OWLClass cl, OWLOntology o, Set list) throws OWLException { + public void getProperties( OWLClass cl, OWLOntology o, Set<OWLProperty> list) throws OWLException { for ( Iterator it = cl.getSuperClasses(o).iterator(); it.hasNext(); ){ OWLDescription dsc = (OWLDescription)it.next(); getProperties( dsc, o, list ); @@ -279,8 +279,8 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align } } - private Set getProperties( OWLClass cl, OWLOntology o ) throws OWLException { - Set resultSet = new HashSet(); + private Set<OWLProperty> getProperties( OWLClass cl, OWLOntology o ) throws OWLException { + Set<OWLProperty> resultSet = new HashSet<OWLProperty>(); getProperties( cl, o, resultSet ); return resultSet; } diff --git a/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java index 26d4fc78bb76ab6713e77ad0ede443cee7f5d08e..04a1d5c0bd3b5f0a9252a0671a34f174e7041520 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java @@ -80,13 +80,13 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme //int l1, l2 = 0; // length of strings (for normalizing) int nbclass1 = 0; // number of classes in onto1 int nbclass2 = 0; // number of classes in onto2 - Vector classlist2 = new Vector(10); // onto2 classes - Vector classlist1 = new Vector(10); // onto1 classes + Vector<OWLClass> classlist2 = new Vector<OWLClass>(10); // onto2 classes + Vector<OWLClass> classlist1 = new Vector<OWLClass>(10); // onto1 classes double classmatrix[][]; // class distance matrix int nbprop1 = 0; // number of properties in onto1 int nbprop2 = 0; // number of properties in onto2 - Vector proplist2 = new Vector(10); // onto2 properties - Vector proplist1 = new Vector(10); // onto1 properties + Vector<OWLProperty> proplist2 = new Vector<OWLProperty>(10); // onto2 properties + Vector<OWLProperty> proplist1 = new Vector<OWLProperty>(10); // onto1 properties double propmatrix[][]; // properties distance matrix double pic1 = 0.5; // class weigth for name double pic2 = 0.5; // class weight for properties @@ -101,35 +101,35 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme try { // Create property lists and matrix for ( Iterator it = ((OWLOntology)onto1).getObjectProperties().iterator(); it.hasNext(); nbprop1++ ){ - proplist1.add( it.next() ); + proplist1.add( (OWLProperty)it.next() ); } for ( Iterator it = ((OWLOntology)onto1).getDataProperties().iterator(); it.hasNext(); nbprop1++ ){ - proplist1.add( it.next() ); + proplist1.add( (OWLProperty)it.next() ); } for ( Iterator it = ((OWLOntology)onto2).getObjectProperties().iterator(); it.hasNext(); nbprop2++ ){ - proplist2.add( it.next() ); + proplist2.add( (OWLProperty)it.next() ); } for ( Iterator it = ((OWLOntology)onto2).getDataProperties().iterator(); it.hasNext(); nbprop2++ ){ - proplist2.add( it.next() ); + proplist2.add( (OWLProperty)it.next() ); } propmatrix = new double[nbprop1+1][nbprop2+1]; // Create class lists for ( Iterator it = ((OWLOntology)onto1).getClasses().iterator(); it.hasNext(); nbclass1++ ){ - classlist1.add( it.next() ); + classlist1.add( (OWLClass)it.next() ); } for ( Iterator it = ((OWLOntology)onto2).getClasses().iterator(); it.hasNext(); nbclass2++ ){ - classlist2.add( it.next() ); + classlist2.add( (OWLClass)it.next() ); } classmatrix = new double[nbclass1+1][nbclass2+1]; if (debug > 0) System.err.println("Initializing property distances"); for ( i=0; i<nbprop1; i++ ){ - OWLProperty cl = (OWLProperty)proplist1.get(i); + OWLProperty cl = proplist1.get(i); String s1 = cl.getURI().getFragment(); if ( s1 != null ) s1 = s1.toLowerCase(); for ( j=0; j<nbprop2; j++ ){ - cl = (OWLProperty)proplist2.get(j); + cl = proplist2.get(j); String s2 = cl.getURI().getFragment(); if ( s2 != null ) s2 = s2.toLowerCase(); if ( s1 == null || s2 == null ) { propmatrix[i][j] = pia1; } @@ -142,11 +142,11 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme if (debug > 0) System.err.println("Initializing class distances"); // Initialize class distances for ( i=0; i<nbclass1; i++ ){ - OWLClass cl = (OWLClass)classlist1.get(i); + OWLClass cl = classlist1.get(i); for ( j=0; j<nbclass2; j++ ){ classmatrix[i][j] = pic1 * StringDistances.subStringDistance( cl.getURI().getFragment().toLowerCase(), - ((OWLClass)classlist2.get(j)).getURI().getFragment().toLowerCase()); + classlist2.get(j).getURI().getFragment().toLowerCase()); } } @@ -170,7 +170,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme max = propmatrix[i][j]; } } - if ( found ) { addAlignDistanceCell( (OWLProperty)proplist1.get(i), (OWLProperty)proplist2.get(best), "=", max ); } + if ( found ) { addAlignDistanceCell( proplist1.get(i), proplist2.get(best), "=", max ); } } if (debug > 0) System.err.print("Computing class distances\n"); @@ -183,12 +183,12 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme // (sigma (att in c[i]) getAllignCell... ) // / nbatts of c[i] + nbatts of c[j] for ( i=0; i<nbclass1; i++ ){ - Set properties1 = getProperties( (OWLClass)classlist1.get(i), ((OWLOntology)onto1) ); + Set properties1 = getProperties( classlist1.get(i), ((OWLOntology)onto1) ); int nba1 = properties1.size(); if ( nba1 > 0 ) { // if not, keep old values... //Set correspondences = new HashSet(); for ( j=0; j<nbclass2; j++ ){ - Set properties2 = getProperties( (OWLClass)classlist2.get(j), ((OWLOntology)onto2) ); + Set properties2 = getProperties( classlist2.get(j), ((OWLOntology)onto2) ); int nba2 = properties2.size(); double attsum = 0.; // check that there is a correspondance @@ -238,14 +238,14 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme max = classmatrix[i][j]; } } - if ( found ) { addAlignDistanceCell( (OWLClass)classlist1.get(i), (OWLClass)classlist2.get(best), "=", max ); } + if ( found ) { addAlignDistanceCell( classlist1.get(i), classlist2.get(best), "=", max ); } } } catch (OWLException e) { throw new AlignmentException( "OWLException during alignment", e ); } } - public void getProperties( OWLDescription desc, OWLOntology o, Set list, Set accu){ + public void getProperties( OWLDescription desc, OWLOntology o, Set<OWLProperty> list, Set<Object> accu){ // I am Jerome Euzenat and I am sure that there is some problem here... // DISPATCHING MANUALLY ! try { @@ -271,13 +271,13 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme e.printStackTrace(); } } - public void getProperties( OWLRestriction rest, OWLOntology o, Set list, Set accu) throws OWLException { + public void getProperties( OWLRestriction rest, OWLOntology o, Set<OWLProperty> list, Set<Object> accu) throws OWLException { if ( !accu.contains( (Object)rest ) ) { accu.add((Object)rest); - list.add( (Object)rest.getProperty() ); + list.add( rest.getProperty() ); } } - public void getProperties( OWLNaryBooleanDescription d, OWLOntology o, Set list, Set accu) throws OWLException { + public void getProperties( OWLNaryBooleanDescription d, OWLOntology o, Set<OWLProperty> list, Set<Object> accu) throws OWLException { if ( !accu.contains( (Object)d ) ) { accu.add((Object)d); for ( Iterator it = d.getOperands().iterator(); it.hasNext() ;){ @@ -285,7 +285,7 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme } } } - public void getProperties( OWLClass cl, OWLOntology o, Set list, Set accu) throws OWLException { + public void getProperties( OWLClass cl, OWLOntology o, Set<OWLProperty> list, Set<Object> accu) throws OWLException { if ( !accu.contains( (Object)cl ) ) { accu.add((Object)cl); for ( Iterator it = cl.getSuperClasses(o).iterator(); it.hasNext(); ){ @@ -299,9 +299,9 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme } } - private Set getProperties( OWLClass cl, OWLOntology o ) throws OWLException { - Set resultSet = new HashSet(); - Set accu = new HashSet(); + private Set<OWLProperty> getProperties( OWLClass cl, OWLOntology o ) throws OWLException { + Set<OWLProperty> resultSet = new HashSet<OWLProperty>(); + Set<Object> accu = new HashSet<Object>(); getProperties( cl, o, resultSet, accu ); return resultSet; } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index 5cfd8c4ef1cc8e858e2b46e72735fd6bf74df4b0..6743eb741e0dea1c9198caacee91e5d9361e6d3b 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -53,7 +53,7 @@ public class RDFRendererVisitor implements AlignmentVisitor Alignment alignment = null; Cell cell = null; OmwgSyntaxFormat oMWGformatter = null; - Hashtable nslist = null; + Hashtable<String,String> nslist = null; public RDFRendererVisitor( PrintWriter writer ){ this.writer = writer; @@ -62,7 +62,7 @@ public class RDFRendererVisitor implements AlignmentVisitor public void visit( Alignment align ) throws AlignmentException { String extensionString = ""; alignment = align; - nslist = new Hashtable(); + nslist = new Hashtable<String,String>(); nslist.put(Annotations.ALIGNNS,"align"); nslist.put("http://www.w3.org/1999/02/22-rdf-syntax-ns#","rdf"); nslist.put("http://www.w3.org/2001/XMLSchema#","xsd"); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java index a4955b8611823866f59c77da130419560afcddf9..effb03bc7dc11cbd481bfe6d905687b6b2b472a9 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java @@ -48,12 +48,12 @@ public class XSLTRendererVisitor implements AlignmentVisitor PrintWriter writer = null; Alignment alignment = null; Cell cell = null; - Hashtable namespaces = null; + Hashtable<String,String> namespaces = null; int nsrank = 0; public XSLTRendererVisitor( PrintWriter writer ){ this.writer = writer; - namespaces = new Hashtable(); + namespaces = new Hashtable<String,String>(); namespaces.put( "http://www.w3.org/1999/XSL/Transform", "xsl" ); namespaces.put( "http://www.w3.org/2002/07/owl#", "owl" ); namespaces.put( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf" ); diff --git a/src/fr/inrialpes/exmo/align/ling/JWNLDistances.java b/src/fr/inrialpes/exmo/align/ling/JWNLDistances.java index b6e76f1d740f393a7c641052d80a8114957177ee..75cb1ee966d6c9b88365182cfa7d6063bf0f8200 100644 --- a/src/fr/inrialpes/exmo/align/ling/JWNLDistances.java +++ b/src/fr/inrialpes/exmo/align/ling/JWNLDistances.java @@ -506,148 +506,143 @@ public class JWNLDistances { } - // the new tokenizer - // firsst looks for non-alphanumeric chars in the string - // if any, they will be taken as the only delimiters - // otherwise the standard naming convention will be assumed: - // words start with a capital letter - // substring of capital letters will be seen as a whole - // if it is a suffix - // otherwise the last letter will be taken as the new token - // start - public Vector tokenize(String s) { - String str1 = s; - int sLength = s.length(); - Vector vTokens = new Vector(); + // the new tokenizer + // first looks for non-alphanumeric chars in the string + // if any, they will be taken as the only delimiters + // otherwise the standard naming convention will be assumed: + // words start with a capital letter + // substring of capital letters will be seen as a whole + // if it is a suffix + // otherwise the last letter will be taken as the new token + // start + public Vector<String> tokenize(String s) { + String str1 = s; + int sLength = s.length(); + Vector<String> vTokens = new Vector<String>(); - // 1. detect possible delimiters - // starts on the first character of the string - int tkStart = 0; - int tkEnd = 0; + // 1. detect possible delimiters + // starts on the first character of the string + int tkStart = 0; + int tkEnd = 0; - // looks for the first delimiter - // while (tkStart < sLength && isAlpha (str1.charAt(tkStart))) { - while (tkStart < sLength && isAlphaNum (str1.charAt(tkStart))) { - tkStart++; - } + // looks for the first delimiter + // while (tkStart < sLength && isAlpha (str1.charAt(tkStart))) { + while (tkStart < sLength && isAlphaNum (str1.charAt(tkStart))) { + tkStart++; + } - // if there is one then the tokens will be the - // substrings between delimiters - if (tkStart < sLength){ + // if there is one then the tokens will be the + // substrings between delimiters + if (tkStart < sLength){ - // reset start and look for the first token - tkStart = 0; + // reset start and look for the first token + tkStart = 0; + + // ignore leading separators + // while (tkStart < sLength && ! isAlpha (str1.charAt(tkStart))) { + while (tkStart < sLength && ! isAlphaNum (str1.charAt(tkStart))) { + tkStart++; + } - // ignore leading separators - // while (tkStart < sLength && ! isAlpha (str1.charAt(tkStart))) { - while (tkStart < sLength && ! isAlphaNum (str1.charAt(tkStart))) { - tkStart++; - } + tkEnd = tkStart; - tkEnd = tkStart; - - while (tkStart < sLength) { - - // consumption of the Alpha/Num token - if (isAlpha (str1.charAt(tkEnd))) { - while (tkEnd < sLength && isAlpha (str1.charAt(tkEnd))) { - tkEnd++; - } - } else { - while (tkEnd < sLength && isNum (str1.charAt(tkEnd))) { - tkEnd++; - } - } - - // consumption of the Num token - vTokens.add(str1.substring(tkStart, tkEnd)); - - // ignoring intermediate delimiters - while (tkEnd < sLength && !isAlphaNum (str1.charAt(tkEnd))) { - tkEnd++; - } - tkStart=tkEnd; - } + while (tkStart < sLength) { + + // consumption of the Alpha/Num token + if (isAlpha (str1.charAt(tkEnd))) { + while (tkEnd < sLength && isAlpha (str1.charAt(tkEnd))) { + tkEnd++; + } + } else { + while (tkEnd < sLength && isNum (str1.charAt(tkEnd))) { + tkEnd++; + } } - // else the standard naming convention will be used - // - // - else{ - // start at the beginning of the string - tkStart = 0; - tkEnd = tkStart; - - while (tkStart < sLength) { - - // the beginning of a token - if (isAlpha (str1.charAt(tkEnd))){ + // consumption of the Num token + vTokens.add(str1.substring(tkStart, tkEnd)); + + // ignoring intermediate delimiters + while (tkEnd < sLength && !isAlphaNum (str1.charAt(tkEnd))) { + tkEnd++; + } + tkStart=tkEnd; + } + } + + // else the standard naming convention will be used + else{ + // start at the beginning of the string + tkStart = 0; + tkEnd = tkStart; + + while (tkStart < sLength) { + + // the beginning of a token + if (isAlpha (str1.charAt(tkEnd))){ - if (isAlphaCap (str1.charAt(tkEnd))){ + if (isAlphaCap (str1.charAt(tkEnd))){ - // This starts with a Cap - // IS THIS an Abbreviaton ??? - // lets see how maqny Caps - while (tkEnd < sLength && isAlphaCap (str1.charAt(tkEnd))) { - tkEnd++; - } + // This starts with a Cap + // IS THIS an Abbreviaton ??? + // lets see how maqny Caps + while (tkEnd < sLength && isAlphaCap (str1.charAt(tkEnd))) { + tkEnd++; + } - // The pointer is at: - // a) string end: make a token and go on - // b) number: make a token and go on - // c) a small letter: - // if there are at least 3 Caps, - // separate them up to the second last one and move the - // tkStart to tkEnd-1 - // otherwise - // go on - - if (tkEnd == sLength || isNum (str1.charAt(tkEnd))) { - vTokens.add(str1.substring(tkStart, tkEnd)); - tkStart=tkEnd; - } else { - // small letter - if (tkEnd - tkStart > 2) { - // If at least 3 - vTokens.add(str1.substring(tkStart, tkEnd-1)); - tkStart=tkEnd-1; - } - } - // if (isAlphaSmall (str1.charAt(tkEnd))){} - } else { - // it is a small letter that follows a number : go on - // relaxed - while (tkEnd < sLength && isAlphaSmall (str1.charAt(tkEnd))) { - tkEnd++; - } - vTokens.add(str1.substring(tkStart, tkEnd)); - tkStart=tkEnd; - } - } else { - - // Here is the numerical token processing - while (tkEnd < sLength && isNum (str1.charAt(tkEnd))) { - tkEnd++; - } - vTokens.add(str1.substring(tkStart, tkEnd)); - tkStart=tkEnd; - } - } + // The pointer is at: + // a) string end: make a token and go on + // b) number: make a token and go on + // c) a small letter: + // if there are at least 3 Caps, + // separate them up to the second last one and move the + // tkStart to tkEnd-1 + // otherwise + // go on + + if (tkEnd == sLength || isNum (str1.charAt(tkEnd))) { + vTokens.add(str1.substring(tkStart, tkEnd)); + tkStart=tkEnd; + } else { + // small letter + if (tkEnd - tkStart > 2) { + // If at least 3 + vTokens.add(str1.substring(tkStart, tkEnd-1)); + tkStart=tkEnd-1; + } + } + // if (isAlphaSmall (str1.charAt(tkEnd))){} + } else { + // it is a small letter that follows a number : go on + // relaxed + while (tkEnd < sLength && isAlphaSmall (str1.charAt(tkEnd))) { + tkEnd++; + } + vTokens.add(str1.substring(tkStart, tkEnd)); + tkStart=tkEnd; + } + } else { + // Here is the numerical token processing + while (tkEnd < sLength && isNum (str1.charAt(tkEnd))) { + tkEnd++; + } + vTokens.add(str1.substring(tkStart, tkEnd)); + tkStart=tkEnd; } - // PV: Debug - //System.err.println("Tokens = "+ vTokens.toString()); - return vTokens; + } } - - + // PV: Debug + //System.err.println("Tokens = "+ vTokens.toString()); + return vTokens; + } // PG: The method now returns an instance of Vector. /** * @param s A string. * @return a vector containing a collection of tokens. */ - public Vector tokenizeDep(String s) { - Vector sTokens = new Vector(); + public Vector<String> tokenizeDep(String s) { + Vector<String> sTokens = new Vector<String>(); String str1 = s; // starts on the second character of the string @@ -702,8 +697,8 @@ public class JWNLDistances { * TODO Look up for other things than nouns * @param word */ - public void lookUpWord(String word, Hashtable nouns, Hashtable adjectives, - Hashtable verbs) { + public void lookUpWord(String word, Hashtable<String,IndexWord> nouns, Hashtable<String,IndexWord> adjectives, + Hashtable<String,IndexWord> verbs) { IndexWord index = null; try { diff --git a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java index 6b3f79793367d62bb3a93cce32e490040095ba00..0640f4982ba9fcc4b6c0058d84032dc5f0fff378 100644 --- a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java +++ b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java @@ -21,7 +21,6 @@ package fr.inrialpes.exmo.align.parser; // Imported OMWG classes -//import org.omwg.mediation.parser.alignment.XpathParser; import org.omwg.mediation.parser.rdf.RDFParser; import org.omwg.mediation.parser.rdf.RDFParserException; @@ -91,11 +90,6 @@ public class AlignmentParser extends DefaultHandler { */ Ontology onto2 = null; - /** - * The currently loaded ontologies - */ - //protected Hashtable ontologies = null; - /** * the alignment that is parsed * We always create a URIAlignment (we could also use a BasicAlignment). @@ -103,9 +97,7 @@ public class AlignmentParser extends DefaultHandler { * is not in accordance with using an interface. */ protected Alignment alignment = null; - // Used by the OMWGAlignments - //protected URIAlignment alignment = null; - + /** * the content found as text... */ @@ -187,6 +179,7 @@ public class AlignmentParser extends DefaultHandler { * @param loaded should be replaced by OntologyCache (by useless) * @deprecated use parse( URI ) instead */ + @Deprecated public Alignment parse( String uri, Hashtable loaded ) throws SAXException, IOException, RDFParserException {//, XPathExpressionException // Determine which parser to use through the use of Xpath? //private static final XPath XPATH = XPathFactory.newInstance().newXPath(); @@ -201,13 +194,11 @@ public class AlignmentParser extends DefaultHandler { * parsed. * @param uri URI of the document to parse */ - public Alignment parse( String uri ) throws SAXException, IOException, RDFParserException { //, XPathExpressionException + public Alignment parse( String uri ) throws SAXException, IOException, RDFParserException { this.uri = uri; try { parser.parse( uri, this ); } catch (SAXException e) { if ( e.getMessage().equals("2OMWGAlignment") ) { - //alignment = new XpathParser().parse(((InputStream)new URL( uri ).openStream())); - //alignment = new XpathParser().parse( new File( uri ) ); alignment = new RDFParser().parse( new File( uri ) ); } else { throw e; // unfortunatelly @@ -276,7 +267,6 @@ public class AlignmentParser extends DefaultHandler { cl2 = null; } else if (pName.equals("map")) { try { - // JE: OMWG1 //NOT SURE alignment.init( onto1, onto2 ); } catch ( AlignmentException e ) { throw new SAXException("Catched alignment exception", e ); @@ -410,7 +400,6 @@ public class AlignmentParser extends DefaultHandler { } else if (pName.equals("uri1")) { if ( onto1.getOntology() == null ){ try { - // JE: OMWG1 URI u = new URI( content ); onto1.setOntology( u ); onto1.setURI( u ); @@ -421,7 +410,6 @@ public class AlignmentParser extends DefaultHandler { } else if (pName.equals("uri2")) { if ( onto2.getOntology() == null ){ try { - // JE: OMWG1 URI u = new URI( content ); onto2.setOntology( u ); onto2.setURI( u ); @@ -429,7 +417,6 @@ public class AlignmentParser extends DefaultHandler { throw new SAXException("uri2: malformed URI"); } } - // JE: OMWG1 } else if (pName.equals("Ontology")) { } else if (pName.equals("location")) { try { curronto.setFile( new URI( content ) ); @@ -451,7 +438,6 @@ public class AlignmentParser extends DefaultHandler { alignment.setType( content ); } else if (pName.equals("level")) { if ( content.equals("2OMWG") ) { - //throw new AlignmentException("2OMWGAlignment"); throw new SAXException("2OMWGAlignment"); } else { alignment.setLevel( content ); diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index c5e44aee4523db3a4c05d471517099f22bd600e0..9c171cb123f3b90e7801f736e040c132b1131f58 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -83,9 +83,9 @@ public class AServProtocolManager { CacheImpl alignmentCache = null; Parameters commandLineParams = null; - Set renderers = null; - Set methods = null; - Set services = null; + Set<String> renderers = null; + Set<String> methods = null; + Set<String> services = null; OntologyCache loadedOntologies = null; OWLRDFErrorHandler handler = null; @@ -140,15 +140,15 @@ public class AServProtocolManager { * Extra administration primitives *********************************************************************/ - public Set listmethods (){ + public Set<String> listmethods (){ return methods; } - public Set listrenderers(){ + public Set<String> listrenderers(){ return renderers; } - public Set listservices(){ + public Set<String> listservices(){ return services; } @@ -597,8 +597,8 @@ public class AServProtocolManager { * Utilities: Finding the implementation of an interface *********************************************************************/ - public static void implementations( Class tosubclass, Set list , boolean debug ){ - Set<String> visited = new HashSet(); + public static void implementations( Class tosubclass, Set<String> list , boolean debug ){ + Set<String> visited = new HashSet<String>(); String classPath = System.getProperty("java.class.path","."); // Hack: this is not necessary //classPath = classPath.substring(0,classPath.lastIndexOf(File.pathSeparatorChar)); @@ -712,8 +712,8 @@ public class AServProtocolManager { * interface in the currently loaded packages. * @param interfaceName the name of the interface to implement */ - public static Set implementations( String interfaceName ) { - Set list = new HashSet(); + public static Set<String> implementations( String interfaceName ) { + Set<String> list = new HashSet<String>(); try { Class toclass = Class.forName(interfaceName); //Package [] pcks = Package.getPackages(); diff --git a/src/fr/inrialpes/exmo/align/service/AlignmentService.java b/src/fr/inrialpes/exmo/align/service/AlignmentService.java index 2d2b328b8b528fe43680517d58ec01096c8e03bc..7ea2ec74fc3fd7efa8a095d8f0c1f757e981d1de 100644 --- a/src/fr/inrialpes/exmo/align/service/AlignmentService.java +++ b/src/fr/inrialpes/exmo/align/service/AlignmentService.java @@ -25,18 +25,19 @@ import fr.inrialpes.exmo.queryprocessor.Result; import fr.inrialpes.exmo.queryprocessor.Type; import fr.inrialpes.exmo.align.impl.BasicParameters; - import fr.inrialpes.exmo.align.util.NullStream; import org.semanticweb.owl.align.Parameters; +import gnu.getopt.LongOpt; +import gnu.getopt.Getopt; + import java.util.Hashtable; import java.util.Enumeration; import java.io.PrintStream; import java.io.File; -import gnu.getopt.LongOpt; -import gnu.getopt.Getopt; +import java.lang.reflect.InvocationTargetException; /** * AlignmentService @@ -83,8 +84,8 @@ public class AlignmentService { private String filename = null; private String outfile = null; private String paramfile = null; - private Hashtable services = null; - private Hashtable directories = null; + private Hashtable<String,AlignmentServiceProfile> services = null; + private Hashtable<String,Directory> directories = null; private AServProtocolManager manager; private DBService connection; @@ -95,8 +96,8 @@ public class AlignmentService { } public void run(String[] args) throws Exception { - services = new Hashtable(); - directories = new Hashtable(); + services = new Hashtable<String,AlignmentServiceProfile>(); + directories = new Hashtable<String,Directory>(); // Read parameters Parameters params = readParameters( args ); if ( outfile != null ) { @@ -128,34 +129,27 @@ public class AlignmentService { if ( debug > 0 ) System.err.println("Manager created"); // Launch services - for ( Enumeration e = services.keys() ; e.hasMoreElements() ; ) { - String name = (String)e.nextElement(); - Class serviceClass = Class.forName(name); - java.lang.reflect.Constructor constructor = serviceClass.getConstructor( (Class[])null ); - AlignmentServiceProfile serv = (AlignmentServiceProfile)constructor.newInstance( (Object[])null ); + for ( AlignmentServiceProfile serv : services.values() ) { try { serv.init( params, manager ); - if ( debug > 0 ) System.err.println(name+" launched on http://"+params.getParameter( "host" )+":"+params.getParameter( "http" )+"/html/"); + if ( debug > 0 ) System.err.println(serv+" launched on http://"+params.getParameter( "host" )+":"+params.getParameter( "http" )+"/html/"); } catch ( AServException ex ) { - System.err.println( "Couldn't start "+name+" server on http://"+params.getParameter( "host" )+":"+params.getParameter( "http" )+"/html/:\n"); + System.err.println( "Couldn't start "+serv+" server on http://"+params.getParameter( "host" )+":"+params.getParameter( "http" )+"/html/:\n"); + // Ideally remove the service ex.printStackTrace(); } - services.put( name, serv ); } - // [Directory]: register to directories - for ( Enumeration e = directories.keys() ; e.hasMoreElements() ; ) { - String name = (String)e.nextElement(); - Class dirClass = Class.forName(name); - java.lang.reflect.Constructor constructor = dirClass.getConstructor( (Class[])null ); - Directory dir = (Directory)constructor.newInstance( (Object[])null ); + // Register to directories + for ( Directory dir : directories.values() ) { try { dir.open( params ); - if ( debug > 0 ) System.err.println(name+" connected."); + if ( debug > 0 ) System.err.println(dir+" connected."); } catch ( AServException ex ) { - System.err.println( "Couldn't connect to "+name+" directory"); + System.err.println( "Couldn't connect to "+dir+" directory"); + // JE: this has to be done + //directories.remove( name, dir ); ex.printStackTrace(); } - directories.put( name, dir ); } // Wait loop @@ -168,8 +162,7 @@ public class AlignmentService { protected void close(){ if (debug > 0 ) System.err.println("Shuting down server"); // [Directory]: unregister to directories - for ( Enumeration e = directories.elements() ; e.hasMoreElements() ; ) { - Directory dir = (Directory)e.nextElement(); + for ( Directory dir : directories.values() ) { try { dir.close(); } catch ( AServException ex ) { System.err.println("Cannot unregister to "+dir); @@ -177,8 +170,7 @@ public class AlignmentService { } } // Close services - for ( Enumeration e = services.elements() ; e.hasMoreElements() ; ) { - AlignmentServiceProfile serv = (AlignmentServiceProfile)e.nextElement(); + for ( AlignmentServiceProfile serv : services.values() ) { try { serv.close(); } catch ( AServException ex ) { System.err.println("Cannot close "+serv); @@ -198,6 +190,13 @@ public class AlignmentService { finally { super.finalize(); } } + protected Object loadInstance( String className) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { + Class cl = Class.forName(className); + java.lang.reflect.Constructor constructor = cl.getConstructor( (Class[])null ); + return constructor.newInstance( (Object[])null ); + } + + public Parameters readParameters( String[] args ) { Parameters params = new BasicParameters(); @@ -244,6 +243,7 @@ public class AlignmentService { case 'h' : usage(); System.exit(0); + break; case 'o' : /* Use filename instead of stdout */ outfile = g.getOptarg(); @@ -266,7 +266,12 @@ public class AlignmentService { case 'i' : /* external service */ arg = g.getOptarg(); - services.put( arg, arg ); + try { + services.put( arg, (AlignmentServiceProfile)loadInstance( arg ) ); + } catch (Exception ex) { + System.err.println("Cannot create service for "+arg); + ex.printStackTrace(); + } break; case 'H' : /* HTTP Server + port */ @@ -277,7 +282,12 @@ public class AlignmentService { params.setParameter( "http", HTML ); } // This shows that it does not work - services.put( "fr.inrialpes.exmo.align.service.HTMLAServProfile", params.getParameter( "http" ) ); + try { + services.put( "fr.inrialpes.exmo.align.service.HTMLAServProfile", (AlignmentServiceProfile)loadInstance( "fr.inrialpes.exmo.align.service.HTMLAServProfile" ) ); + } catch (Exception ex) { + System.err.println("Cannot create service for HTMLAServProfile"); + ex.printStackTrace(); + } break; case 'A' : /* JADE Server + port */ @@ -287,7 +297,12 @@ public class AlignmentService { } else { params.setParameter( "jade", JADE ); } - services.put( "fr.inrialpes.exmo.align.service.jade.JadeFIPAAServProfile", params.getParameter( "jade" ) ); + try { + services.put( "fr.inrialpes.exmo.align.service.jade.JadeFIPAAServProfile", (AlignmentServiceProfile)loadInstance( "fr.inrialpes.exmo.align.service.jade.JadeFIPAAServProfile" ) ); + } catch (Exception ex) { + System.err.println("Cannot create service for JadeFIPAAServProfile"); + ex.printStackTrace(); + } break; case 'W' : /* Web service + port */ @@ -301,7 +316,12 @@ public class AlignmentService { // Put the default port, may be overriden if ( params.getParameter( "http" ) == null ) params.setParameter( "http", HTML ); - services.put( "fr.inrialpes.exmo.align.service.HTMLAServProfile", HTML ); + try { + services.put( "fr.inrialpes.exmo.align.service.HTMLAServProfile", (AlignmentServiceProfile)loadInstance( "fr.inrialpes.exmo.align.service.HTMLAServProfile" ) ); + } catch (Exception ex) { + System.err.println("Cannot create service for Web services"); + ex.printStackTrace(); + } break; case 'P' : /* JXTA Server + port */ @@ -323,8 +343,13 @@ public class AlignmentService { params.setParameter( "oyster", arg ); } else { params.setParameter( "oyster", JADE ); - } - directories.put( "fr.inrialpes.exmo.align.service.OysterDirectory", params.getParameter( "oyster" ) ); + } + try { + directories.put( "fr.inrialpes.exmo.align.service.OysterDirectory", (Directory)loadInstance( "fr.inrialpes.exmo.align.service.OysterDirectory" ) ); + } catch (Exception ex) { + System.err.println("Cannot create directory for Oyster"); + ex.printStackTrace(); + } break; case 'U' : /* [JE: Currently not working]: UDDI directory + port */ @@ -334,7 +359,12 @@ public class AlignmentService { } else { params.setParameter( "uddi", JADE ); } - directories.put( "fr.inrialpes.exmo.align.service.UDDIDirectory", params.getParameter( "uddi" ) ); + try { + directories.put( "fr.inrialpes.exmo.align.service.UDDIDirectory", (Directory)loadInstance( "fr.inrialpes.exmo.align.service.UDDIDirectory" ) ); + } catch (Exception ex) { + System.err.println("Cannot create directory for UDDI"); + ex.printStackTrace(); + } break; case 'm' : params.setParameter( "dbmshost", g.getOptarg() ); diff --git a/src/fr/inrialpes/exmo/align/service/CacheImpl.java b/src/fr/inrialpes/exmo/align/service/CacheImpl.java index f3fcc1d093beddb91c3bec134732f921c9d4d922..9a538f45f08b75f38bd830303a7e084fecb41002 100644 --- a/src/fr/inrialpes/exmo/align/service/CacheImpl.java +++ b/src/fr/inrialpes/exmo/align/service/CacheImpl.java @@ -56,8 +56,8 @@ import org.semanticweb.owl.align.Parameters; */ public class CacheImpl { - Hashtable alignmentTable = null; - Hashtable ontologyTable = null; + Hashtable<String,Alignment> alignmentTable = null; + Hashtable<URI,Set<Alignment>> ontologyTable = null; String host = null; String port = null; @@ -90,8 +90,8 @@ public class CacheImpl { // Rather raise an exception System.err.println(e.toString()); } - alignmentTable = new Hashtable(); - ontologyTable = new Hashtable(); + alignmentTable = new Hashtable<String,Alignment>(); + ontologyTable = new Hashtable<URI,Set<Alignment>>(); } /** @@ -142,7 +142,7 @@ public class CacheImpl { String query = null; String id = null; Alignment alignment = null; - Vector idInfo = new Vector(); + Vector<String> idInfo = new Vector<String>(); Statement st = (Statement) conn.createStatement(); if (force) { @@ -155,14 +155,14 @@ public class CacheImpl { // For each alignment id store metadata for( int i = 0; i < idInfo.size(); i ++ ) { - id = (String)idInfo.get(i); + id = idInfo.get(i); alignment = retrieveDescription( id ); recordAlignment( id, alignment, true ); } } } - protected Enumeration listAlignments() { + protected Enumeration<Alignment> listAlignments() { return alignmentTable.elements(); } @@ -294,7 +294,7 @@ public class CacheImpl { * disreagarding if it is complete o only metadata */ public Alignment getMetadata( String id ) throws Exception { - Alignment result = (Alignment)alignmentTable.get( id ); + Alignment result = alignmentTable.get( id ); if ( result == null ) throw new Exception("getMetadata: Cannot find alignment"); return result; @@ -304,7 +304,7 @@ public class CacheImpl { * retrieve full alignment from id (and cache it) */ public Alignment getAlignment( String id ) throws Exception { - Alignment result = (Alignment)alignmentTable.get( id ); + Alignment result = alignmentTable.get( id ); if ( result == null ) throw new Exception("getAlignment: Cannot find alignment"); @@ -318,14 +318,14 @@ public class CacheImpl { return result; } - public Set getAlignments( URI uri ) { - return (Set)ontologyTable.get( uri ); + public Set<Alignment> getAlignments( URI uri ) { + return ontologyTable.get( uri ); } public Set<Alignment> getAlignments( URI uri1, URI uri2 ) { // Create the set and compare - Set<Alignment> result = new HashSet(); - Set<Alignment> potentials = (Set<Alignment>)ontologyTable.get( uri1 ); + Set<Alignment> result = new HashSet<Alignment>(); + Set<Alignment> potentials = ontologyTable.get( uri1 ); if ( potentials != null ) { String uri2String = uri2.toString(); for( Iterator it = potentials.iterator(); it.hasNext(); ) { @@ -375,15 +375,15 @@ public class CacheImpl { URI ouri1 = new URI( alignment.getExtension( SVCNS, OURI1) ); URI ouri2 = new URI( alignment.getExtension( SVCNS, OURI2) ); if ( force || alignmentTable.get( id ) == null ) { - Set s1 = (Set)ontologyTable.get( ouri1 ); + Set<Alignment> s1 = ontologyTable.get( ouri1 ); if ( s1 == null ) { - s1 = new HashSet(); + s1 = new HashSet<Alignment>(); ontologyTable.put( ouri1, s1 ); } s1.add( alignment ); - Set s2 = (Set)ontologyTable.get( ouri2 ); + Set<Alignment> s2 = ontologyTable.get( ouri2 ); if ( s2 == null ) { - s2 = new HashSet(); + s2 = new HashSet<Alignment>(); ontologyTable.put( ouri2, s2 ); } s2.add( alignment ); @@ -393,7 +393,7 @@ public class CacheImpl { } catch (Exception e) { System.err.println("Unlikely URI exception!"); e.printStackTrace(); - return (String)null; + return null; } } diff --git a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java index 12ec5dd672bf46f0c68b8032117b9e46944faec0..a2b6b1a59550e48d9b13928e1de758d61a2be5bb 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java @@ -117,7 +117,7 @@ public class WSAServProfile implements AlignmentServiceProfile { try { String classPath = System.getProperty("java.class.path","."); StringTokenizer tk = new StringTokenizer(classPath,File.pathSeparator); - Set<String> visited = new HashSet(); + Set<String> visited = new HashSet<String>(); classPath = ""; while ( tk != null && tk.hasMoreTokens() ){ StringTokenizer tk2 = tk; diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java index 82769264c2dfcfa57b44c10a85de8e2bbba7a6a0..6f7d3a66c05c247ac25129fc631a5ec716b95078 100755 --- a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java @@ -2,7 +2,7 @@ * $Id$ * * Copyright (C) Orange R&D, 2006 - * Copyright (C) INRIA Rhône-Alpes, 2006 + * Copyright (C) INRIA Rhône-Alpes, 2006, 2008 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -61,6 +61,7 @@ import fr.inrialpes.exmo.align.service.jade.messageontology.TRANSLATE; public class JadeFIPAAServiceAgent extends Agent { + private static final long serialVersionUID = 330; public static final String SERVICE_NAME = "Alignment"; public static final String SERVICE_TYPE = "Alignment-service"; @@ -109,6 +110,7 @@ public class JadeFIPAAServiceAgent extends Agent { // Add initial behaviours to manage incoming message addBehaviour(new CyclicBehaviour(this) { + private static final long serialVersionUID = 330; public void action() { String perf; // performative diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/AClient.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/AClient.java index b323301ebb92b710064882817da7af3f0aa69cb2..e1265de6d676883a7712e6c133c16cde6f23699c 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/AClient.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/AClient.java @@ -1,8 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.core.AID; /** * Protege name: AClient @@ -11,4 +9,5 @@ import jade.core.*; */ public class AClient extends AID{ + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/ALIGN.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/ALIGN.java index c87204a3bcd4b232f133b199ad09e115cfd53af7..c94ae27683aa55a434dd4533c5305dc29f926fb8 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/ALIGN.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/ALIGN.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: ALIGN @@ -12,4 +9,5 @@ import jade.core.*; */ public class ALIGN extends Action implements Predicate{ + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/AServer.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/AServer.java index 2368c9c69a26cac4c4d9ff3c92bd53b0bcd83b13..4bdaadcce21433fdca7c2bf27acfb93eeebe7b40 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/AServer.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/AServer.java @@ -1,14 +1,13 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.core.AID; /** * Protege name: AServer * @author ontology bean generator * @version 2007/03/19, 17:12:29 */ -public class AServer extends AID{ +public class AServer extends AID { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/Action.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/Action.java index 3c47f975fce6d526dce3f628c249d5e8dd3644db..770cc7092af3e09e5884bcc5a5d68e592976123a 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/Action.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/Action.java @@ -1,9 +1,9 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; /** * Protege name: Action @@ -12,26 +12,28 @@ import jade.core.*; */ public class Action implements Predicate { + private static final long serialVersionUID = 330; /** * Protege name: hasParameter */ - private List hasParameter = new ArrayList(); + private List<Parameter> hasParameter = new ArrayList<Parameter>(); + public void addHasParameter(Parameter elem) { - List oldList = this.hasParameter; + List<Parameter> oldList = this.hasParameter; hasParameter.add(elem); } public boolean removeHasParameter(Parameter elem) { - List oldList = this.hasParameter; + List<Parameter> oldList = this.hasParameter; boolean result = hasParameter.remove(elem); return result; } public void clearAllHasParameter() { - List oldList = this.hasParameter; + List<Parameter> oldList = this.hasParameter; hasParameter.clear(); } - public Iterator getAllHasParameter() {return hasParameter.iterator(); } - public List getHasParameter() {return hasParameter; } - public void setHasParameter(List l) {hasParameter = l; } + public Iterator<Parameter> getAllHasParameter() {return hasParameter.iterator(); } + public List<Parameter> getHasParameter() {return hasParameter; } + public void setHasParameter(List<Parameter> l) {hasParameter = l; } /** * Protege name: Result diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/CUT.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/CUT.java index 0d2fea84a910a608d4a9ecf708329354a4b8886c..0aa5a831a6dc329832ffe2050e39f5543b0d3799 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/CUT.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/CUT.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: CUT @@ -12,4 +9,5 @@ import jade.core.*; */ public class CUT extends Action implements Predicate { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/FIND.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/FIND.java index 4c64b1dfba78d01c3f04631d393690246e62db91..d88a56842103b781597fe09f65dfb4faf6998224 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/FIND.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/FIND.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: FIND @@ -12,4 +9,5 @@ import jade.core.*; */ public class FIND extends Action implements Predicate { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java index cbcb19423c6e88988bfdb1ab979d3fd268670108..fd30792541dbaf7dc11b0a6edd3c5cbef416a209 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/JADEFIPAAlignmentServerOntology.java @@ -13,6 +13,7 @@ import jade.core.CaseInsensitiveString; */ public class JADEFIPAAlignmentServerOntology extends jade.content.onto.Ontology { //NAME + private static final long serialVersionUID = 330; public static final String ONTOLOGY_NAME = "JADEFIPAAlignmentServerOntology"; // The singleton instance of this ontology private static ReflectiveIntrospector introspect = new ReflectiveIntrospector(); diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/LOAD.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/LOAD.java index 3295ce68c3d71e654a1a024dba5ae701d20a654c..1b6f560e7a522608daf26e518c4bb92f0a2c63d8 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/LOAD.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/LOAD.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: LOAD @@ -12,4 +9,5 @@ import jade.core.*; */ public class LOAD extends Action implements Predicate { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/METADATA.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/METADATA.java index b71096f8adc43c5d1d298a2ed016b1d2628fafbe..220784444a6733ea7456863f05eb199f37dc76f7 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/METADATA.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/METADATA.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: METADATA @@ -12,4 +9,5 @@ import jade.core.*; */ public class METADATA extends Action implements Predicate { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/Parameter.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/Parameter.java index cf068813df640cf2d3afc9c12e60203f9275773f..5599e4b06832b759ae267496264353c6f9971e76 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/Parameter.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/Parameter.java @@ -12,6 +12,7 @@ import jade.core.*; */ public class Parameter implements Concept { + private static final long serialVersionUID = 330; /** * Protege name: value */ diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/RETRIEVE.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/RETRIEVE.java index 66e1eb059e851089697d3899a5b6c8f1b0e571be..5cbb70ff08711a5acb1701edbc1a9325b4d557cf 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/RETRIEVE.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/RETRIEVE.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: RETRIEVE @@ -12,4 +9,5 @@ import jade.core.*; */ public class RETRIEVE extends Action implements Predicate { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/STORE.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/STORE.java index 2a38a6a5f526bf72b3d61244a287e87e8ee91915..c6ad0e654f6adaf34d9391a5a1dfe11546648ebb 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/STORE.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/STORE.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: STORE @@ -12,4 +9,5 @@ import jade.core.*; */ public class STORE extends Action implements Predicate{ + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/service/jade/messageontology/TRANSLATE.java b/src/fr/inrialpes/exmo/align/service/jade/messageontology/TRANSLATE.java index fcc9d9f920ae6178ad3186bc5f0cbe397b5a9fff..c853438e16d368fe09193b44bcde83da54d42043 100644 --- a/src/fr/inrialpes/exmo/align/service/jade/messageontology/TRANSLATE.java +++ b/src/fr/inrialpes/exmo/align/service/jade/messageontology/TRANSLATE.java @@ -1,9 +1,6 @@ package fr.inrialpes.exmo.align.service.jade.messageontology; - -import jade.content.*; -import jade.util.leap.*; -import jade.core.*; +import jade.content.Predicate; /** * Protege name: TRANSLATE @@ -12,4 +9,5 @@ import jade.core.*; */ public class TRANSLATE extends Action implements Predicate { + private static final long serialVersionUID = 330; } diff --git a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java index 0f9a31a5a492d1d4a56943ec956e312def7543c1..479f688782bdb1edcdb9a0a62bf13af59e8b970a 100644 --- a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java @@ -97,7 +97,7 @@ public class ExtGroupEval { int fsize = 2; String type = "html"; String dominant = "s"; - Vector listAlgo = null; + Vector<String> listAlgo = null; int debug = 0; String color = null; OntologyCache loaded = null; @@ -165,7 +165,7 @@ public class ExtGroupEval { } // JE: StringTokenizer is obsoleted in Java 1.4 in favor of split: to change - listAlgo = new Vector(); + listAlgo = new Vector<String>(); StringTokenizer st = new StringTokenizer(listFile,","); while (st.hasMoreTokens()) { listAlgo.add(st.nextToken()); @@ -177,8 +177,8 @@ public class ExtGroupEval { print( iterateDirectories() ); } - public Vector iterateDirectories (){ - Vector result = null; + public Vector<Object> iterateDirectories (){ + Vector<Object> result = null; File [] subdir = null; try { subdir = (new File(System.getProperty("user.dir"))).listFiles(); @@ -187,7 +187,7 @@ public class ExtGroupEval { usage(); } int size = subdir.length; - result = new Vector(size); + result = new Vector<Object>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { @@ -204,19 +204,19 @@ public class ExtGroupEval { return result; } - public Vector iterateAlignments ( File dir ) { + public Vector<Object> iterateAlignments ( File dir ) { String prefix = dir.toURI().toString()+"/"; - Vector result = new Vector(); + Vector<Object> result = new Vector<Object>(); boolean ok = false; result.add(0,(Object)dir.getName().toString()); int i = 1; // for all alignments there, - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; i++) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; i++) { // call eval // store the resul in a record // return the record. if ( debug > 1) System.err.println(" Considering result "+i); - Evaluator evaluator = (Evaluator)eval( prefix+"refalign.rdf", prefix+(String)e.nextElement()+".rdf"); + Evaluator evaluator = (Evaluator)eval( prefix+"refalign.rdf", prefix+e.nextElement()+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); } @@ -224,7 +224,7 @@ public class ExtGroupEval { loaded.clear(); if ( ok == true ) return result; - else return (Vector)null; + else return null; } public Evaluator eval( String alignName1, String alignName2 ) { @@ -281,18 +281,18 @@ public class ExtGroupEval { writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { writer.println("<colgroup align='center' span='"+fsize+"' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ;) { - writer.println("<th colspan='"+(fsize+1)+"'>"+(String)e.nextElement()+"</th>"); + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;) { + writer.println("<th colspan='"+(fsize+1)+"'>"+e.nextElement()+"</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { for ( int i = 0; i < fsize; i++){ writer.print("<td>"); if ( format.charAt(i) == 's' ) { @@ -388,7 +388,7 @@ public class ExtGroupEval { } writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); int k = 0; - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; k++) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; k++) { e.nextElement(); if ( foundVect[k] != -1 ){ double precision = (double)correctVect[k]/foundVect[k]; diff --git a/src/fr/inrialpes/exmo/align/util/GenPlot.java b/src/fr/inrialpes/exmo/align/util/GenPlot.java index c8f8945546145a3153a4882ba0a751744717814f..2970773f7a99bf8a375d1de4a6f834a0d48426ff 100644 --- a/src/fr/inrialpes/exmo/align/util/GenPlot.java +++ b/src/fr/inrialpes/exmo/align/util/GenPlot.java @@ -92,7 +92,7 @@ public class GenPlot { int STEP = 10; Parameters params = null; - Vector listAlgo; + Vector<String> listAlgo; String fileNames = ""; String outFile = null; String type = "tsv"; @@ -148,7 +148,7 @@ public class GenPlot { } // JE: StringTokenizer is obsoleted in Java 1.4 in favor of split: to change - listAlgo = new Vector(); + listAlgo = new Vector<String>(); StringTokenizer st = new StringTokenizer(fileNames,","); while (st.hasMoreTokens()) { listAlgo.add(st.nextToken()); diff --git a/src/fr/inrialpes/exmo/align/util/GenTriangle.java b/src/fr/inrialpes/exmo/align/util/GenTriangle.java index c7c019dc486b7d05b63e152ddabdd78dcd4c9604..fec1d3c832948c30536e48b7a1193dfefefc6cf5 100644 --- a/src/fr/inrialpes/exmo/align/util/GenTriangle.java +++ b/src/fr/inrialpes/exmo/align/util/GenTriangle.java @@ -94,7 +94,7 @@ public class GenTriangle { String type = "html"; boolean embedded = false; String dominant = "s"; - Vector listAlgo = null; + Vector<String> listAlgo = null; int debug = 0; String color = null; //Hashtable loaded = null; @@ -179,7 +179,7 @@ public class GenTriangle { } // JE: StringTokenizer is obsoleted in Java 1.4 in favor of split: to change - listAlgo = new Vector(); + listAlgo = new Vector<String>(); StringTokenizer st = new StringTokenizer(listFile,","); while (st.hasMoreTokens()) { listAlgo.add(st.nextToken()); @@ -191,8 +191,8 @@ public class GenTriangle { print( iterateDirectories() ); } - public Vector iterateDirectories (){ - Vector result = null; + public Vector<Object> iterateDirectories (){ + Vector<Object> result = null; File [] subdir = null; try { if(ontoDir == null){ @@ -206,7 +206,7 @@ public class GenTriangle { usage(); } int size = subdir.length; - result = new Vector(size); + result = new Vector<Object>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { @@ -225,7 +225,7 @@ public class GenTriangle { public Vector iterateAlignments ( File dir ) { String prefix = dir.toURI().toString()+"/"; - Vector result = new Vector(); + Vector<Object> result = new Vector<Object>(); boolean ok = false; result.add(0,(Object)dir.getName().toString()); int i = 1; diff --git a/src/fr/inrialpes/exmo/align/util/GroupEval.java b/src/fr/inrialpes/exmo/align/util/GroupEval.java index 51add81978889baeca250a4f9a736e943af0eb39..ac9c5f95c3f082f8f434ba5b864a262eca4ff43f 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/GroupEval.java @@ -94,7 +94,7 @@ public class GroupEval { String type = "html"; boolean embedded = false; String dominant = "s"; - Vector listAlgo = null; + Vector<String> listAlgo = null; int debug = 0; String color = null; //Hashtable loaded = null; @@ -179,7 +179,7 @@ public class GroupEval { } // JE: StringTokenizer is obsoleted in Java 1.4 in favor of split: to change - listAlgo = new Vector(); + listAlgo = new Vector<String>(); StringTokenizer st = new StringTokenizer(listFile,","); while (st.hasMoreTokens()) { listAlgo.add(st.nextToken()); @@ -191,8 +191,8 @@ public class GroupEval { print( iterateDirectories() ); } - public Vector iterateDirectories (){ - Vector result = null; + public Vector<Object> iterateDirectories (){ + Vector<Object> result = null; File [] subdir = null; try { if(ontoDir == null){ @@ -207,7 +207,7 @@ public class GroupEval { } int size = subdir.length; Arrays.sort(subdir); //VS - result = new Vector(size); + result = new Vector<Object>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { @@ -224,14 +224,14 @@ public class GroupEval { return result; } - public Vector iterateAlignments ( File dir ) { + public Vector<Object> iterateAlignments ( File dir ) { String prefix = dir.toURI().toString()+"/"; - Vector result = new Vector(); + Vector<Object> result = new Vector<Object>(); boolean ok = false; result.add(0,(Object)dir.getName().toString()); int i = 1; // for all alignments there, - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; i++) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; i++) { // call eval // store the resul in a record // return the record. @@ -244,7 +244,7 @@ public class GroupEval { loaded.clear(); if ( ok == true ) return result; - else return (Vector)null; + else return null; } public Evaluator eval( String alignName1, String alignName2 ) { @@ -341,7 +341,7 @@ public class GroupEval { //System.out.println("\\draw (10,-0.3) node {1.}; "); System.out.println("% Plots"); int k = 0; - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; k++) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; k++) { double precision = (double)correctVect[k]/foundVect[k]; double recall = (double)correctVect[k]/expected; double prec2 = precision*precision; @@ -427,18 +427,18 @@ which the program does... writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { writer.println("<colgroup align='center' span='"+fsize+"' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ;) { - writer.println("<th colspan='"+fsize+"'>"+(String)e.nextElement()+"</th>"); + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;) { + writer.println("<th colspan='"+fsize+"'>"+e.nextElement()+"</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { for ( int i = 0; i < fsize; i++){ writer.print("<td>"); if ( format.charAt(i) == 'p' ) { @@ -531,7 +531,7 @@ which the program does... // here we use the real values, i.e., add 0 to both correctVect and // foundVect, so this is OK for computing the average. int k = 0; - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; k++) { + for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; k++) { e.nextElement(); double precision = (double)correctVect[k]/foundVect[k]; double recall = (double)correctVect[k]/expected; diff --git a/src/fr/inrialpes/exmo/align/util/GroupOutput.java b/src/fr/inrialpes/exmo/align/util/GroupOutput.java index b7dd3085a8f3896c6bf30d4c4c2768bb374da934..fa3751b0282fd4d7317b101864d49dba6347d4f2 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/util/GroupOutput.java @@ -109,7 +109,7 @@ public class GroupOutput { {254,260,261},//i=14 {262,265,266} };//emptyset=15 Parameters params = null; - Vector listAlgo; + Vector<String> listAlgo; String fileNames = ""; String outFile = null; String type = "tex"; @@ -174,7 +174,7 @@ public class GroupOutput { } // JE: StringTokenizer is obsoleted in Java 1.4 in favor of split: to change - listAlgo = new Vector(); + listAlgo = new Vector<String>(); StringTokenizer st = new StringTokenizer(fileNames,","); while (st.hasMoreTokens()) { listAlgo.add(st.nextToken()); diff --git a/src/org/semanticweb/owl/align/Alignment.java b/src/org/semanticweb/owl/align/Alignment.java index 90154ac0b2122129481fcc794b1be57bb25db300..eef89eb77ee3cc227045aa538eaebd64d599504f 100644 --- a/src/org/semanticweb/owl/align/Alignment.java +++ b/src/org/semanticweb/owl/align/Alignment.java @@ -138,8 +138,8 @@ public interface Alignment extends Cloneable * Some implementations might act cleverly (retrieving the best value). * Basic implementations may raise the exception */ - public Set getAlignCells1( Object ob ) throws AlignmentException; - public Set getAlignCells2( Object ob ) throws AlignmentException; + public Set<Cell> getAlignCells1( Object ob ) throws AlignmentException; + public Set<Cell> getAlignCells2( Object ob ) throws AlignmentException; /** * Extensions are a way to read and add other information (metadata) @@ -149,7 +149,7 @@ public interface Alignment extends Cloneable public String getExtension( String uri, String label ); public void setExtension( String uri, String label, String value ); - public Enumeration getElements(); + public Enumeration<Cell> getElements(); public int nbCells(); public void cut( String method, double threshold ) throws AlignmentException; diff --git a/src/org/semanticweb/owl/align/AlignmentException.java b/src/org/semanticweb/owl/align/AlignmentException.java index d857ff4cfcf999c835142c4d3382da03c4ce23d7..a09da48c91962025e771cdb40181ce4e6f3769f8 100644 --- a/src/org/semanticweb/owl/align/AlignmentException.java +++ b/src/org/semanticweb/owl/align/AlignmentException.java @@ -1,6 +1,7 @@ /* * $Id$ - * Copyright (C) INRIA Rhône-Alpes, 2003-2004 + * + * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2008 * * 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 @@ -32,7 +33,7 @@ import java.lang.Exception; public class AlignmentException extends Exception { - static final long serialVersionID = 100; + private static final long serialVersionUID = 330; public AlignmentException( String message ) { diff --git a/src/org/semanticweb/owl/align/Cell.java b/src/org/semanticweb/owl/align/Cell.java index 30716b09367881c78b2776f8028c837a6ca79c24..5a8b2efbe2f401533b2950e86a1d55c4cdc98285 100644 --- a/src/org/semanticweb/owl/align/Cell.java +++ b/src/org/semanticweb/owl/align/Cell.java @@ -40,8 +40,7 @@ import org.xml.sax.SAXException; */ -public interface Cell -{ +public interface Cell extends Comparable<Cell> { public void accept( AlignmentVisitor visitor ) throws AlignmentException; /** Creation **/ diff --git a/src/org/semanticweb/owl/align/Parameters.java b/src/org/semanticweb/owl/align/Parameters.java index 0e729726f3d321dffa9d9eaabb72087cd4857d76..609fb56e2ed459d2f24486816952ede71705db2b 100644 --- a/src/org/semanticweb/owl/align/Parameters.java +++ b/src/org/semanticweb/owl/align/Parameters.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2004 + * Copyright (C) INRIA Rhône-Alpes, 2004, 2008 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -43,7 +43,7 @@ public interface Parameters { public void setParameter(String name, Object value); public void unsetParameter(String name); public Object getParameter(String name); - public Enumeration getNames(); + public Enumeration<String> getNames(); public void write(); //public static Parameters read(String filename);