From 0fb3a601447c58fe9233ea97bd6e3e5e1e86ea0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Thu, 18 Feb 2010 00:26:15 +0000 Subject: [PATCH] - lint:cast --- .../align/plugin/webcontent/WSInterface.java | 42 +++++++++---------- .../exmo/align/impl/BasicAlignment.java | 24 +++++------ .../exmo/align/impl/BasicParameters.java | 7 ++-- .../exmo/align/impl/DistanceAlignment.java | 3 +- .../inrialpes/exmo/align/impl/ObjectCell.java | 2 +- .../exmo/align/impl/eval/GraphEvaluator.java | 22 +++++----- .../exmo/align/impl/eval/PRecEvaluator.java | 4 +- .../align/impl/eval/SymMeanEvaluator.java | 2 +- .../impl/method/ClassStructAlignment.java | 9 +++- .../impl/method/StringDistAlignment.java | 6 +-- .../renderer/HTMLMetadataRendererVisitor.java | 2 +- .../impl/renderer/HTMLRendererVisitor.java | 2 +- .../renderer/XMLMetadataRendererVisitor.java | 4 +- .../align/service/AServProtocolManager.java | 15 +++---- .../exmo/align/service/CacheImpl.java | 18 ++++---- .../exmo/align/service/WSAServProfile.java | 10 ++--- .../exmo/align/service/WSAlignment.java | 2 +- .../service/jade/JadeFIPAAServiceAgent.java | 4 +- .../exmo/align/util/ExtGroupEval.java | 8 ++-- .../inrialpes/exmo/align/util/GroupAlign.java | 5 +-- .../inrialpes/exmo/align/util/GroupEval.java | 4 +- .../exmo/align/util/GroupOutput.java | 2 +- .../inrialpes/exmo/align/util/Procalign.java | 2 +- .../ontowrap/owlapi10/OWLAPIOntology.java | 28 ++++++------- .../ontowrap/owlapi30/OWLAPI3Ontology.java | 2 +- 25 files changed, 117 insertions(+), 112 deletions(-) diff --git a/plugins/webcontent/src/fr/inrialpes/exmo/align/plugin/webcontent/WSInterface.java b/plugins/webcontent/src/fr/inrialpes/exmo/align/plugin/webcontent/WSInterface.java index d31e45f7..84fe470f 100644 --- a/plugins/webcontent/src/fr/inrialpes/exmo/align/plugin/webcontent/WSInterface.java +++ b/plugins/webcontent/src/fr/inrialpes/exmo/align/plugin/webcontent/WSInterface.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rh�ne-Alpes, 2007-2008 + * Copyright (C) INRIA Rh�ne-Alpes, 2007-2008, 2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -687,7 +687,7 @@ public class WSInterface { result = new String[nl.getLength()]; for (int i=0; i< nl.getLength(); i++) { - Node method = (Node) nl.item(i); + Node method = nl.item(i); Node firstnode = method.getFirstChild(); String nm = firstnode.getNodeValue(); @@ -719,7 +719,7 @@ public class WSInterface { NodeList ns = nn.getChildNodes(); //tag "alid" is third - Node n3 = (Node) ns.item(3); + Node n3 = ns.item(3); Node nx = n3.getFirstChild(); String nm = nx.getNodeValue(); @@ -740,9 +740,9 @@ public class WSInterface { "xmlns:xsd=\'http://www.w3.org/1999/XMLSchema\'>" + "<SOAP-ENV:Body>"; String messageBody = ""; - String cmd = (String)params.getParameter( "command" ); + String cmd = params.getParameter( "command" ); if ( cmd.equals("list" ) ) { - String arg = (String)params.getParameter( "arg1" ); + String arg = params.getParameter( "arg1" ); if ( arg.equals("methods" ) ){ SOAPAction = "listmethodsRequest"; } else if ( arg.equals("renderers" ) ){ @@ -759,8 +759,8 @@ public class WSInterface { SOAPAction = "wsdlRequest"; } else if ( cmd.equals("find" ) ) { SOAPAction = "findRequest"; - String uri1 = (String)params.getParameter( "arg1" ); - String uri2 = (String)params.getParameter( "arg2" ); + String uri1 = params.getParameter( "arg1" ); + String uri2 = params.getParameter( "arg2" ); if ( uri2 == null ){ //usage(); System.exit(-1); @@ -768,18 +768,18 @@ public class WSInterface { messageBody = "<url1>"+uri1+"</url1><url2>"+uri2+"</url2>"; } else if ( cmd.equals("match" ) ) { SOAPAction = "matchRequest"; - String uri1 = (String)params.getParameter( "arg1" ); - String uri2 = (String)params.getParameter( "arg2" ); + String uri1 = params.getParameter( "arg1" ); + String uri2 = params.getParameter( "arg2" ); if ( uri2 == null ){ //usage(); System.exit(-1); } String method = null; - String arg3 = (String)params.getParameter( "arg3" ); + String arg3 = params.getParameter( "arg3" ); if ( arg3 != null ) { method = uri1; uri1 = uri2; uri2 = arg3; } - arg3 = (String)params.getParameter( "arg4" ); + arg3 = params.getParameter( "arg4" ); messageBody = "<url1>"+uri1+"</url1><url2>"+uri2+"</url2>"; if ( method != null ) messageBody += "<method>"+method+"</method>"; @@ -788,14 +788,14 @@ public class WSInterface { messageBody += "<force>"+arg3+"</force>"; } else if ( cmd.equals("trim" ) ) { SOAPAction = "cutRequest"; - String id = (String)params.getParameter( "arg1" ); - String thres = (String)params.getParameter( "arg2" ); + String id = params.getParameter( "arg1" ); + String thres = params.getParameter( "arg2" ); if ( thres == null ){ //usage(); //System.exit(-1); } String method = null; - String arg3 = (String)params.getParameter( "arg3" ); + String arg3 = params.getParameter( "arg3" ); if ( arg3 != null ) { method = thres; thres = arg3; } @@ -804,7 +804,7 @@ public class WSInterface { messageBody += "<method>"+method+"</method>"; } else if ( cmd.equals("invert" ) ) { SOAPAction = "invertRequest"; - String uri = (String)params.getParameter( "arg1" ); + String uri = params.getParameter( "arg1" ); if ( uri == null ){ //usage(); //System.exit(-1); @@ -812,14 +812,14 @@ public class WSInterface { messageBody = "<alid>"+uri+"</alid>"; } else if ( cmd.equals("store" ) ) { SOAPAction = "storeRequest"; - String uri = (String)params.getParameter( "arg1" ); + String uri = params.getParameter( "arg1" ); if ( uri == null ) { //usage(); //System.exit(-1); } messageBody = "<alid>"+uri+"</alid>"; } else if ( cmd.equals("load" ) ) { - String url = (String)params.getParameter( "arg1" ); + String url = params.getParameter( "arg1" ); if ( url == null ){ SOAPAction = "loadRequest"; /* @@ -853,8 +853,8 @@ public class WSInterface { */ } else if ( cmd.equals("retrieve" ) ) { SOAPAction = "retrieveRequest"; - String uri = (String)params.getParameter( "arg1" ); - String method = (String)params.getParameter( "arg2" ); + String uri = params.getParameter( "arg1" ); + String method = params.getParameter( "arg2" ); if ( method == null ){ //usage(); //System.exit(-1); @@ -862,8 +862,8 @@ public class WSInterface { messageBody = "<alid>"+uri+"</alid><method>"+method+"</method>"; } else if ( cmd.equals("metadata" ) ) { SOAPAction = "metadata"; - String uri = (String)params.getParameter( "arg1" ); - String key = (String)params.getParameter( "arg2" ); + String uri = params.getParameter( "arg1" ); + String key = params.getParameter( "arg2" ); if ( key == null ){ //usage(); //System.exit(-1); diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java index 609dad2e..352c70ea 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java @@ -193,7 +193,7 @@ public class BasicAlignment implements Alignment { }; public String getXNamespace( String label ) { - return (String)namespaces.getParameter( label ); + return namespaces.getParameter( label ); }; public Enumeration<Cell> getElements() { @@ -254,7 +254,7 @@ public class BasicAlignment implements Alignment { hash1.put(c.getObject1(),s1); } found = false; - Set<Cell> s2 = (Set<Cell>)hash2.get(c.getObject2()); + Set<Cell> s2 = hash2.get(c.getObject2()); if( s2 != null ){ // I must check that there is no one here for (Iterator i=s2.iterator(); !found && i.hasNext(); ) { @@ -442,24 +442,24 @@ public class BasicAlignment implements Alignment { i = java.lang.Math.min( size, new Double(threshold*100).intValue() ); } else if ( method.equals("hardgap") || method.equals("propgap") ){ double gap; - double last = ((Cell)buffer.get(0)).getStrength(); + double last = buffer.get(0).getStrength(); if ( method.equals("propgap") ) gap = last * threshold; else gap = threshold; for( i=1; i < size ; i++ ) { - if ( last - ((Cell)buffer.get(i)).getStrength() > gap ) break; + if ( last - buffer.get(i).getStrength() > gap ) break; else { - last = ((Cell)buffer.get(i)).getStrength(); + last = buffer.get(i).getStrength(); if ( method.equals("propgap") ) gap = last * threshold; } } } else { double max; if ( method.equals("hard") ) max = threshold; - else if ( method.equals("span") ) max = ((Cell)buffer.get(0)).getStrength() - threshold; - else if ( method.equals("prop") ) max = ((Cell)buffer.get(0)).getStrength() * threshold; + else if ( method.equals("span") ) max = buffer.get(0).getStrength() - threshold; + else if ( method.equals("prop") ) max = buffer.get(0).getStrength() * threshold; else throw new AlignmentException( "Not a cut specification : "+method ); for( i=0; i < size ; i++) { - if ( ((Cell)buffer.get(i)).getStrength() < max ) break; + if ( buffer.get(i).getStrength() < max ) break; } } // Introduce the result back in the structure @@ -467,7 +467,7 @@ public class BasicAlignment implements Alignment { hash1.clear(); hash2.clear(); for( i=0; i < size; i++ ) { - addCell( (Cell)buffer.get(i) ); + addCell( buffer.get(i) ); } }; @@ -524,7 +524,7 @@ public class BasicAlignment implements Alignment { throw new AlignmentException("Can only diff alignments with same ontologies"); BasicAlignment result = createNewAlignment( onto1, onto2 ); for ( Cell c1 : this ) { - Set<Cell> s2 = (Set<Cell>)align.getAlignCells1( c1.getObject1() ); + Set<Cell> s2 = align.getAlignCells1( c1.getObject1() ); boolean found = false; if ( s2 != null ){ for ( Cell c2 : s2 ){ @@ -554,7 +554,7 @@ public class BasicAlignment implements Alignment { throw new AlignmentException("Can only meet alignments with same ontologies"); BasicAlignment result = createNewAlignment( onto1, onto2 ); for ( Cell c1 : this ) { - Set<Cell> s2 = (Set<Cell>)align.getAlignCells1( c1.getObject1() ); + Set<Cell> s2 = align.getAlignCells1( c1.getObject1() ); boolean found = false; if ( s2 != null ){ for ( Cell c2 : s2 ){ @@ -585,7 +585,7 @@ public class BasicAlignment implements Alignment { BasicAlignment result = createNewAlignment( onto1, onto2 ); result.ingest( align ); for ( Cell c1 : this ) { - Set<Cell> s2 = (Set<Cell>)align.getAlignCells1( c1.getObject1() ); + Set<Cell> s2 = align.getAlignCells1( c1.getObject1() ); boolean found = false; if ( s2 != null ){ for ( Cell c2 : s2 ){ diff --git a/src/fr/inrialpes/exmo/align/impl/BasicParameters.java b/src/fr/inrialpes/exmo/align/impl/BasicParameters.java index e65a5f80..49a9adfd 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicParameters.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicParameters.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2005, 2008-2009 + * Copyright (C) INRIA, 2004-2005, 2008-2010 * Copyright (C) University of Montréal, 2004 * * This program is free software; you can redistribute it and/or @@ -31,7 +31,6 @@ import java.io.PrintStream; import java.io.File; import org.w3c.dom.Document; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Element; @@ -55,6 +54,8 @@ import org.semanticweb.owl.align.Parameters; public class BasicParameters extends Properties implements Parameters, Cloneable { + static final long serialVersionUID = 400L; + /** The list of unlinked out XML_Port */ //Hashtable<String,Object> parameters = null; @@ -135,7 +136,7 @@ public class BasicParameters extends Properties implements Parameters, Cloneable Element paramElement = (Element)paramList.item(s); String paramName = paramElement.getAttribute("name"); NodeList paramContent = paramElement.getChildNodes(); - String paramValue =((Node)paramContent.item(0)).getNodeValue().trim(); + String paramValue = paramContent.item(0).getNodeValue().trim(); p.setParameter(paramName, paramValue); } } catch (SAXParseException err) { diff --git a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java index 26615f27..5689aba6 100644 --- a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java @@ -43,8 +43,7 @@ import fr.inrialpes.exmo.ontosim.util.HungarianAlgorithm; * @version $Id$ */ -public class DistanceAlignment extends ObjectAlignment implements AlignmentProcess -{ +public class DistanceAlignment extends ObjectAlignment implements AlignmentProcess { Similarity sim; /** Creation **/ diff --git a/src/fr/inrialpes/exmo/align/impl/ObjectCell.java b/src/fr/inrialpes/exmo/align/impl/ObjectCell.java index 6f1fe5b5..e0536aa9 100644 --- a/src/fr/inrialpes/exmo/align/impl/ObjectCell.java +++ b/src/fr/inrialpes/exmo/align/impl/ObjectCell.java @@ -118,7 +118,7 @@ public class ObjectCell extends BasicCell { public Cell compose(Cell c) throws AlignmentException { if (!object2.equals(c.getObject1()) && relation.compose(c.getRelation())==null ) return null; - Cell result = (ObjectCell)new ObjectCell( (String)null, object1, c.getObject2(), relation.compose(c.getRelation()), strength*c.getStrength() ); + Cell result = new ObjectCell( (String)null, object1, c.getObject2(), relation.compose(c.getRelation()), strength*c.getStrength() ); // TODO : extension... return result; } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java index 3d2e8d72..5fc6ae2c 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/GraphEvaluator.java @@ -79,26 +79,26 @@ public abstract class GraphEvaluator extends BasicEvaluator { SortedSet<Cell> cellSet = new TreeSet<Cell>( new Comparator<Cell>() { public int compare( Cell o1, Cell o2 ) - throws ClassCastException{ + throws ClassCastException { try { - //System.err.println(((Cell)o1).getObject1()+" -- "+((Cell)o1).getObject2()+" // "+((Cell)o2).getObject1()+" -- "+((Cell)o2).getObject2()); + //System.err.println(((Cell)o1).getObject1()+" -- "+((Cell)o1).getObject2()+" // "+o2.getObject1()+" -- "+o2.getObject2()); if ( o1 instanceof Cell && o2 instanceof Cell ) { - if ( ((Cell)o1).getStrength() > ((Cell)o2).getStrength() ){ + if ( o1.getStrength() > o2.getStrength() ){ return -1; - } else if ( ((Cell)o1).getStrength() < ((Cell)o2).getStrength() ){ + } else if ( o1.getStrength() < o2.getStrength() ){ return 1; //The comparator must always tell that things are different! - } else if ( (((Cell)o1).getObject1AsURI(align1).getFragment() == null) - || (((Cell)o2).getObject1AsURI(align2).getFragment() == null) ) { + } else if ( (o1.getObject1AsURI(align1).getFragment() == null) + || (o2.getObject1AsURI(align2).getFragment() == null) ) { return -1; - } else if ( ((Cell)o1).getObject1AsURI(align1).getFragment().compareTo(((Cell)o2).getObject1AsURI(align2).getFragment()) > 0) { + } else if ( o1.getObject1AsURI(align1).getFragment().compareTo(o2.getObject1AsURI(align2).getFragment()) > 0) { return -1; - } else if ( ((Cell)o1).getObject1AsURI(align1).getFragment().compareTo(((Cell)o2).getObject1AsURI(align2).getFragment()) < 0 ) { + } else if ( o1.getObject1AsURI(align1).getFragment().compareTo(o2.getObject1AsURI(align2).getFragment()) < 0 ) { return 1; - } else if ( (((Cell)o1).getObject2AsURI(align1).getFragment() == null) - || (((Cell)o2).getObject2AsURI(align2).getFragment() == null) ) { + } else if ( (o1.getObject2AsURI(align1).getFragment() == null) + || (o2.getObject2AsURI(align2).getFragment() == null) ) { return -1; - } else if ( ((Cell)o1).getObject2AsURI(align1).getFragment().compareTo(((Cell)o2).getObject2AsURI(align2).getFragment()) > 0) { + } else if ( o1.getObject2AsURI(align1).getFragment().compareTo(o2.getObject2AsURI(align2).getFragment()) > 0) { return -1; // We assume that they have different names } else { return 1; } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java index 4b239f90..b3d47311 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2009 + * Copyright (C) INRIA, 2004-2009, 2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -112,7 +112,7 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator { for ( Cell c1 : align1 ) { URI uri1 = c1.getObject2AsURI(); nbexpected++; - Set<Cell> s2 = (Set<Cell>)align2.getAlignCells1( c1.getObject1() ); + Set<Cell> s2 = align2.getAlignCells1( c1.getObject1() ); if( s2 != null ){ for( Iterator it2 = s2.iterator(); it2.hasNext() && c1 != null; ){ Cell c2 = (Cell)it2.next(); diff --git a/src/fr/inrialpes/exmo/align/impl/eval/SymMeanEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/SymMeanEvaluator.java index 5ca331cc..6c4c6201 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/SymMeanEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/SymMeanEvaluator.java @@ -81,7 +81,7 @@ public class SymMeanEvaluator extends BasicEvaluator { if ( onto1.isClass( c1.getObject1() ) ) nbClassCell++; else if ( onto1.isProperty( c1.getObject1() ) ) nbPropCell++; else nbIndCell++; - Set<Cell> s2 = (Set<Cell>)align2.getAlignCells1( c1.getObject1() ); + Set<Cell> s2 = align2.getAlignCells1( c1.getObject1() ); if( s2 != null ){ for ( Cell c2: s2 ){ if ( c1.getObject2() == c2.getObject2() ) { diff --git a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java index 524baa6a..b37617eb 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java @@ -35,7 +35,12 @@ import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontosim.string.StringDistances; -/** This class has been built for ISWC experiments with bibliography. +/** + * Establishes an alignment based on the comparison of the properties + * that classes have in common. These properties are themselves compared + * based on correspondences provided by an initial alignment. + * + * This class has been built for ISWC experiments with bibliography. * It implements a non iterative (one step) OLA algorithms based on * the name of classes and properties. It could be made iterative by * just adding range/domain on properties... @@ -132,7 +137,7 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment // check that there is a correspondance // in list of class2 atts and add their weights for ( Object prp : properties1 ){ - Set<Cell> s2 = (Set<Cell>)getAlignCells1( prp ); + Set<Cell> s2 = getAlignCells1( prp ); // Find the property with the higest similarity // that is matched here double currentValue = 0.; diff --git a/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java index 39f1d6d3..013f3cb0 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2009 + * Copyright (C) INRIA, 2003-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,7 +78,7 @@ public class StringDistAlignment extends DistanceAlignment implements AlignmentP /* Processing */ public void align( Alignment alignment, Properties params ) throws AlignmentException { // Get function from params - String f = (String)params.getProperty("stringFunction"); + String f = params.getProperty("stringFunction"); try { if ( f != null ) methodName = f.trim(); Class sClass = Class.forName("java.lang.String"); @@ -87,7 +87,7 @@ public class StringDistAlignment extends DistanceAlignment implements AlignmentP } catch (ClassNotFoundException e) { e.printStackTrace(); // never happens } catch (NoSuchMethodException e) { - throw new AlignmentException( "Unknown method for StringDistAlignment : "+(String)params.getProperty("stringFunction"), e ); + throw new AlignmentException( "Unknown method for StringDistAlignment : "+params.getProperty("stringFunction"), e ); } // JE2010: Strange: why does it is not equivalent to call diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLMetadataRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLMetadataRendererVisitor.java index e1a207e7..847361cd 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLMetadataRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLMetadataRendererVisitor.java @@ -82,7 +82,7 @@ public class HTMLMetadataRendererVisitor implements AlignmentVisitor for ( String[] ext : align.getExtensions() ){ String prefix = ext[0]; String name = ext[1]; - String tag = (String)nslist.get(prefix); + String tag = nslist.get(prefix); if ( tag == null ) { tag = "ns"+gen++; nslist.put( prefix, tag ); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java index 579fdec2..367d58c7 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java @@ -86,7 +86,7 @@ public class HTMLRendererVisitor implements AlignmentVisitor { for ( String[] ext : align.getExtensions() ){ String prefix = ext[0]; String name = ext[1]; - String tag = (String)nslist.get(prefix); + String tag = nslist.get(prefix); if ( tag == null ) { tag = "ns"+gen++; nslist.put( prefix, tag ); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/XMLMetadataRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/XMLMetadataRendererVisitor.java index 55014c01..f74d6cc0 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/XMLMetadataRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/XMLMetadataRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2007, 2009 + * Copyright (C) INRIA, 2007, 2009-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -75,7 +75,7 @@ public class XMLMetadataRendererVisitor implements AlignmentVisitor { for ( String[] ext : align.getExtensions() ){ String prefix = ext[0]; String name = ext[1]; - String tag = (String)nslist.get(prefix); + String tag = nslist.get(prefix); if ( tag == null ) { tag = "ns"+gen++; nslist.put( prefix, tag ); diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 64fec277..2c2e12b0 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -114,7 +114,7 @@ public class AServProtocolManager { myId = "http://"+prop.getProperty("host")+":"+prop.getProperty("http"); renderers = implementations( "org.semanticweb.owl.align.AlignmentVisitor" ); methods = implementations( "org.semanticweb.owl.align.AlignmentProcess" ); - methods.remove("fr.inrialpes.exmo.align.impl.DistanceAlignment"); // this one is generic + methods.remove("fr.inrialpes.exmo.align.impl.DistanceAlignment"); // this one is generic, but not abstract services = implementations( "fr.inrialpes.exmo.align.service.AlignmentServiceProfile" ); evaluators = implementations( "org.semanticweb.owl.align.Evaluator" ); } @@ -830,8 +830,6 @@ public class AServProtocolManager { } public static boolean implementsInterface( String classname, Class tosubclass, boolean debug ) { - // It is possible to suppress here abstract classes by: - //java.lang.reflect.Modifier.isAbstract( Class.forName(classname).getModifiers ); try { if ( classname.equals("org.apache.xalan.extensions.ExtensionHandlerGeneral") ) throw new ClassNotFoundException( "Stupid JAVA/Xalan bug"); // JE: Here there is a bug that is that it is not possible @@ -839,13 +837,16 @@ public class AServProtocolManager { // This is really stupid but that's life // So it is compulsory that AlignmentProcess be declared // as implemented - Class[] cls = Class.forName(classname).getInterfaces(); - for ( int i=0; i < cls.length ; i++ ){ - if ( cls[i] == tosubclass ) { + Class cl = Class.forName(classname); + // It is possible to suppress here abstract classes by: + if ( java.lang.reflect.Modifier.isAbstract( cl.getModifiers() ) ) return false; + Class[] interfaces = cl.getInterfaces(); + for ( int i=interfaces.length-1; i >= 0 ; i-- ){ + if ( interfaces[i] == tosubclass ) { if ( debug ) System.err.println(" -j-> "+classname); return true; } - if ( debug ) System.err.println(" I> "+cls[i] ); + if ( debug ) System.err.println(" I> "+interfaces[i] ); } // Not one of our classes } catch ( NoClassDefFoundError ncdex ) { diff --git a/src/fr/inrialpes/exmo/align/service/CacheImpl.java b/src/fr/inrialpes/exmo/align/service/CacheImpl.java index 4092c16c..3b378782 100644 --- a/src/fr/inrialpes/exmo/align/service/CacheImpl.java +++ b/src/fr/inrialpes/exmo/align/service/CacheImpl.java @@ -140,7 +140,7 @@ public class CacheImpl { } public void close() throws SQLException { - Statement st = (Statement)conn.createStatement(); + Statement st = conn.createStatement(); // unregister by the database st.executeUpdate("DELETE FROM server WHERE host='"+host+"' AND port='"+port+"'"); st.close(); @@ -168,7 +168,7 @@ public class CacheImpl { if (force) { // Retrieve the alignment ids - ResultSet rs = (ResultSet) st.executeQuery("SELECT id FROM alignment"); + ResultSet rs = st.executeQuery("SELECT id FROM alignment"); while(rs.next()) { id = rs.getString("id"); idInfo.add(id); @@ -225,7 +225,7 @@ public class CacheImpl { Statement st = createStatement(); // Get basic ontology metadata query = "SELECT * FROM alignment WHERE id = '" + id +"'"; - rs = (ResultSet) st.executeQuery(query); + rs = st.executeQuery(query); while(rs.next()) { // Either uri1 or file1 result.setFile1( new URI( rs.getString("file1") ) ); @@ -240,7 +240,7 @@ public class CacheImpl { // Get extension metadata query = "SELECT * FROM extension WHERE id = '" + id + "'"; - rs = (ResultSet) st.executeQuery(query); + rs = st.executeQuery(query); while(rs.next()) { tag = rs.getString("tag"); value = rs.getString("val"); @@ -279,7 +279,7 @@ public class CacheImpl { // Get cells query = "SELECT * FROM cell WHERE id = '" + id + "'"; - ResultSet rs = (ResultSet) st.executeQuery(query); + ResultSet rs = st.executeQuery(query); while(rs.next()) { ent1 = new URI(rs.getString("uri1")); ent2 = new URI(rs.getString("uri2")); @@ -295,7 +295,7 @@ public class CacheImpl { String cid = cell.getId(); if ( cid != null && !cid.equals("") ){ query = "SELECT * FROM extension WHERE id = '" + cid + "'"; - ResultSet rse = (ResultSet) st.executeQuery(query); + ResultSet rse = st.executeQuery(query); while ( rse.next() ){ cell.setExtension( rse.getString("uri"), rse.getString("tag"), @@ -730,7 +730,7 @@ public class CacheImpl { Statement st = createStatement(); // Check that no one else is connected... if ( force != true ){ - ResultSet rs = (ResultSet) st.executeQuery("SELECT COUNT(*) AS rowcount FROM server WHERE edit=1"); + ResultSet rs = st.executeQuery("SELECT COUNT(*) AS rowcount FROM server WHERE edit=1"); rs.next(); int count = rs.getInt("rowcount") ; rs.close() ; @@ -760,7 +760,7 @@ public class CacheImpl { public void updateDatabase() throws SQLException, AlignmentException { Statement st = createStatement(); // get the version number - ResultSet rs = (ResultSet) st.executeQuery("SELECT version FROM server WHERE port='port'"); + ResultSet rs = st.executeQuery("SELECT version FROM server WHERE port='port'"); rs.next(); int version = rs.getInt("version") ; if ( version < VERSION ) { @@ -770,7 +770,7 @@ public class CacheImpl { st.executeUpdate("ALTER TABLE extension CHANGE method val VARCHAR(500)"); st.executeUpdate("ALTER TABLE extension ADD uri VARCHAR(200);"); // Modify extensions - ResultSet rse = (ResultSet) st.executeQuery("SELECT * FROM extension"); + ResultSet rse = st.executeQuery("SELECT * FROM extension"); Statement st2 = createStatement(); while ( rse.next() ){ String tag = rse.getString("tag"); diff --git a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java index 500303f8..f9d816db 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java @@ -214,7 +214,7 @@ public class WSAServProfile implements AlignmentServiceProfile { // However, there is a way to pass SOAP messages with attachments // It would be better to implement this. See: // http://www.oracle.com/technology/sample_code/tech/java/codesnippet/webservices/attachment/index.html - message = ((String)param.getProperty("content")).trim(); + message = param.getProperty("content").trim(); // Create the DOM tree for the SOAP message Document domMessage = null; try { @@ -258,14 +258,14 @@ public class WSAServProfile implements AlignmentServiceProfile { if ( newparameters.getProperty( "id" ) == null ) { answer = new NonConformParameters(0,(Message)null,myId,"",message,(Properties)null); } else { - answer = manager.store( new Message(newId(),(Message)null,myId,serverURL,(String)newparameters.getProperty( "id" ), newparameters) ); + answer = manager.store( new Message(newId(),(Message)null,myId,serverURL,newparameters.getProperty( "id" ), newparameters) ); } msg += " <storeResponse>\n"+answer.SOAPString()+" </storeResponse>\n"; } else if ( method.equals("invertRequest") || method.equals("invert") ) { // URI -> URI if ( newparameters.getProperty( "id" ) == null ) { answer = new NonConformParameters(0,(Message)null,myId,"",message,(Properties)null); } else { - answer = manager.inverse( new Message(newId(),(Message)null,myId,serverURL, (String)newparameters.getProperty( "id" ), newparameters) ); + answer = manager.inverse( new Message(newId(),(Message)null,myId,serverURL, newparameters.getProperty( "id" ), newparameters) ); } msg += " <invertResponse>\n"+answer.SOAPString()+" </invertResponse>\n"; } else if ( method.equals("trimRequest") || method.equals("trim") ) { // URI * string * float -> URI @@ -277,7 +277,7 @@ public class WSAServProfile implements AlignmentServiceProfile { if ( newparameters.getProperty( "type" ) == null ) { newparameters.setProperty( "type", "hard" ); } - answer = manager.trim( new Message(newId(),(Message)null,myId,serverURL,(String)newparameters.getProperty( "id" ), newparameters) ); + answer = manager.trim( new Message(newId(),(Message)null,myId,serverURL,newparameters.getProperty( "id" ), newparameters) ); } msg += " <trimResponse>\n"+answer.SOAPString()+" </trimResponse>\n"; } else if ( method.equals("matchRequest") || method.equals("match") ) { // URL * URL * URI * String * boolean * (newparameters) -> URI @@ -299,7 +299,7 @@ public class WSAServProfile implements AlignmentServiceProfile { if ( newparameters.getProperty( "wsmethod" ) == null ) { newparameters.setProperty( "method", "fr.inrialpes.exmo.align.impl.method.StringDistAlignment" ); } else { - newparameters.setProperty( "method", (String)newparameters.getProperty( "wsmethod" ) ); + newparameters.setProperty( "method", newparameters.getProperty( "wsmethod" ) ); } // Match the two ontologies Message result = manager.align( new Message(newId(),(Message)null,myId,serverURL,"", newparameters) ); if ( result instanceof ErrorMsg ) { diff --git a/src/fr/inrialpes/exmo/align/service/WSAlignment.java b/src/fr/inrialpes/exmo/align/service/WSAlignment.java index c19c769f..f3c1a59e 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAlignment.java +++ b/src/fr/inrialpes/exmo/align/service/WSAlignment.java @@ -87,7 +87,7 @@ public class WSAlignment extends URIAlignment implements AlignmentProcess { public void align( Alignment alignment, Properties params ) throws AlignmentException { // Create the invokation message if ( params.getProperty("wserver") != null ) { - serviceAddress = (String)params.getProperty("wserver"); + serviceAddress = params.getProperty("wserver"); } else { throw new AlignmentException( "WSAlignment: required parameter : wserver" ); } diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java index 032434cb..4f147bf9 100755 --- a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java @@ -174,7 +174,7 @@ public class JadeFIPAAServiceAgent extends Agent { }else if (ce instanceof METADATA){ //TODO }else if (ce instanceof STORE){ - Message answer = manager.store(new Message(newId(), (Message)null,myId,serverId,(String)params.getParameter("id"),params)); + Message answer = manager.store(new Message(newId(), (Message)null,myId,serverId,params.getParameter("id"),params)); if(!(answer instanceof ErrorMsg)){ ACLMessage JADEanswer=msg.createReply(); JADEanswer.setLanguage(codec.getName()); @@ -262,7 +262,7 @@ public class JadeFIPAAServiceAgent extends Agent { BasicParameters toReturn = param; Action action= (Action)ce; for( Iterator<Parameter> iter = action.getAllHasParameter(); iter.hasNext(); ){ - Parameter OntoParam = (Parameter)iter.next(); + Parameter OntoParam = iter.next(); toReturn.setParameter( OntoParam.getName(), OntoParam.getValue() ); } return toReturn; diff --git a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java index a619104d..89bd86d0 100644 --- a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java @@ -237,7 +237,7 @@ public class ExtGroupEval { // store the result in a record // return the record. if ( debug > 1) System.err.println(" Considering result "+i); - Evaluator evaluator = (Evaluator)eval( prefix+reference, prefix+m+".rdf"); + Evaluator evaluator = eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); } @@ -292,7 +292,7 @@ public class ExtGroupEval { try { // Print result if ( filename == null ) { - writer = (PrintStream)System.out; + writer = System.out; } else { writer = new PrintStream(new FileOutputStream( filename )); } @@ -394,8 +394,8 @@ public class ExtGroupEval { int k = 0; for ( String m : listAlgo ) { if ( foundVect[k] != -1 ){ - double precision = (double)correctVect[k]/foundVect[k]; - double recall = (double)correctVect[k]/expected; + double precision = correctVect[k]/foundVect[k]; + double recall = correctVect[k]/expected; //for ( int i = 0 ; i < fsize; i++){ writer.print("<td>"); formatter.format("%1.2f", precision); diff --git a/src/fr/inrialpes/exmo/align/util/GroupAlign.java b/src/fr/inrialpes/exmo/align/util/GroupAlign.java index ff8935d5..6b1040db 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupAlign.java +++ b/src/fr/inrialpes/exmo/align/util/GroupAlign.java @@ -208,7 +208,7 @@ public class GroupAlign { //int i = g.getOptind(); if (debug == 0 && params.getParameter("debug") != null) { - debug = Integer.parseInt((String)params.getParameter("debug")); + debug = Integer.parseInt(params.getParameter("debug")); } if (debug > 0) params.setParameter( "debug", Integer.toString( debug-1 ) ); @@ -224,8 +224,7 @@ public class GroupAlign { else{ subdir = (new File(ontoDir)).listFiles(); } - } - catch (Exception e) { + } catch ( Exception e ) { System.err.println("Cannot stat dir "+ e.getMessage()); usage(); } diff --git a/src/fr/inrialpes/exmo/align/util/GroupEval.java b/src/fr/inrialpes/exmo/align/util/GroupEval.java index a4c80034..a3c918ce 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/GroupEval.java @@ -234,7 +234,7 @@ public class GroupEval { // store the result in a record // return the record. if ( debug > 2) System.err.println(" Considering result "+i); - Evaluator evaluator = (Evaluator)eval( prefix+reference, prefix+m+".rdf"); + Evaluator evaluator = eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); } @@ -417,7 +417,7 @@ which the program does... try { // Print result if ( filename == null ) { - writer = (PrintStream)System.out; + writer = System.out; } else { writer = new PrintStream(new FileOutputStream( filename )); } diff --git a/src/fr/inrialpes/exmo/align/util/GroupOutput.java b/src/fr/inrialpes/exmo/align/util/GroupOutput.java index f449c05f..d4ddb4f4 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/util/GroupOutput.java @@ -248,7 +248,7 @@ public class GroupOutput { // Unload the ontologies. OntologyFactory.clear(); - return (double)result/(double)tests.length; + return result/(double)tests.length; } public Evaluator eval( String alignName1, String alignName2 ) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/util/Procalign.java b/src/fr/inrialpes/exmo/align/util/Procalign.java index 5ff9847e..38f505a5 100644 --- a/src/fr/inrialpes/exmo/align/util/Procalign.java +++ b/src/fr/inrialpes/exmo/align/util/Procalign.java @@ -195,7 +195,7 @@ public class Procalign { if (debug > 0) { params.setParameter( "debug", Integer.toString(debug) ); } else if ( params.getParameter("debug") != null ) { - debug = Integer.parseInt((String)params.getParameter("debug")); + debug = Integer.parseInt( params.getParameter("debug") ); } try { diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java index f01bd69f..24057512 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi10/OWLAPIOntology.java @@ -99,10 +99,10 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public Object getEntity( URI uri ) throws AlignmentException { try { - OWLEntity result = ((OWLOntology)onto).getClass( uri ); - if ( result == null ) result = ((OWLOntology)onto).getDataProperty( uri ); - if ( result == null ) result = ((OWLOntology)onto).getObjectProperty( uri ); - if ( result == null ) result = ((OWLOntology)onto).getIndividual( uri ); + OWLEntity result = onto.getClass( uri ); + if ( result == null ) result = onto.getDataProperty( uri ); + if ( result == null ) result = onto.getObjectProperty( uri ); + if ( result == null ) result = onto.getIndividual( uri ); return result; } catch (OWLException ex) { throw new AlignmentException( "Cannot dereference URI : "+uri ); @@ -263,7 +263,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public Set<?> getClasses() { try { - return ((OWLOntology)onto).getClasses(); // [W:unchecked] + return onto.getClasses(); // [W:unchecked] //return getEntities(OWLClass.class); } catch (OWLException ex) { return null; @@ -272,7 +272,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public Set<?> getProperties() { try { - //return ((OWLOntology)onto).getProperties(); // [W:unchecked] + //return onto.getProperties(); // [W:unchecked] return getEntities(OWLProperty.class); } catch (OWLException ex) { return null; @@ -283,7 +283,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL try { // This first method returns also Properties not defined in the Onto // i.e. properties having an namespace different from the ontology uri - return ((OWLOntology)onto).getDataProperties(); // [W:unchecked] + return onto.getDataProperties(); // [W:unchecked] //return getEntities(OWLDataProperty.class); } catch (OWLException ex) { return null; @@ -295,7 +295,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL // [Warning:unchecked] due to OWL API not serving generic types // This first method returns also Properties not defined in the Onto // i.e. properties having an namespace different from the ontology uri - return ((OWLOntology)onto).getObjectProperties(); // [W:unchecked] + return onto.getObjectProperties(); // [W:unchecked] // This method works better (??) //return getEntities(OWLObjectProperty.class); } catch (OWLException ex) { @@ -305,7 +305,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public Set<?> getIndividuals() { try { - return ((OWLOntology)onto).getIndividuals(); // [W:unchecked] + return onto.getIndividuals(); // [W:unchecked] //return getEntities(OWLIndividual.class); } catch (OWLException ex) { return null; @@ -321,7 +321,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public int nbClasses() { if ( nbclasses != -1 ) return nbclasses; try { - nbclasses = ((OWLOntology)onto).getClasses().size(); + nbclasses = onto.getClasses().size(); return nbclasses; } catch (OWLException oex) { return 0; @@ -337,7 +337,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public int nbObjectProperties() { if ( nbobjectproperties != -1 ) return nbobjectproperties; try { - nbobjectproperties = ((OWLOntology)onto).getObjectProperties().size(); + nbobjectproperties = onto.getObjectProperties().size(); return nbobjectproperties; } catch (OWLException oex) { return 0; @@ -347,7 +347,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public int nbDataProperties() { if ( nbdataproperties != -1 ) return nbdataproperties; try { - nbdataproperties = ((OWLOntology)onto).getDataProperties().size(); + nbdataproperties = onto.getDataProperties().size(); return nbdataproperties; } catch (OWLException oex) { return 0; @@ -357,7 +357,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public int nbIndividuals() { if ( nbindividuals != -1 ) return nbindividuals; try { - nbindividuals = ((OWLOntology)onto).getIndividuals().size(); + nbindividuals = onto.getIndividuals().size(); return nbindividuals; } catch (OWLException oex) { return 0; @@ -366,7 +366,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL public void unload() { try { - ((OWLOntology)onto).getOWLConnection().notifyOntologyDeleted( ((OWLOntology)onto) ); + onto.getOWLConnection().notifyOntologyDeleted( onto ); } catch (OWLException ex) { System.err.println(ex); }; } diff --git a/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java b/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java index 20cfc2ea..123845ea 100644 --- a/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java +++ b/src/fr/inrialpes/exmo/ontowrap/owlapi30/OWLAPI3Ontology.java @@ -355,7 +355,7 @@ public class OWLAPI3Ontology extends BasicOntology<OWLOntology> implements if ( d instanceof OWLClass ) supers.add( (OWLClass)d ); } if ( local == OntologyFactory.LOCAL ) { - return (Set<Object>)supers; + return supers; } else { // inherits the superclasses (unless we have to reduce them...) Set<Object> newsupers = new HashSet<Object>(); -- GitLab