Author: chatellier Date: 2009-06-30 08:13:59 +0000 (Tue, 30 Jun 2009) New Revision: 152 Modified: trunk/exports/GrossValueOfLandingsOtherSpecies.java Log: Affichage d'un message si le resultat n'est pas disponible (NPE) Modified: trunk/exports/GrossValueOfLandingsOtherSpecies.java =================================================================== --- trunk/exports/GrossValueOfLandingsOtherSpecies.java 2009-06-24 10:36:06 UTC (rev 151) +++ trunk/exports/GrossValueOfLandingsOtherSpecies.java 2009-06-30 08:13:59 UTC (rev 152) @@ -15,12 +15,11 @@ import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.Date; import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.datastore.ResultStorage; import fr.ifremer.isisfish.util.Doc; // pour pouvoir afficher une aide contextuelle (BUG#1605) /** - * VesselMargin.java + * GrossValueOfLandingsOtherSpecies.java * * Created: 23 novembre 2006 * @@ -30,7 +29,7 @@ * Last update: $Date: 2007-05-24 09:30:07 $ * by : $Author: bpoussin $ */ - @Doc(value="do the doc of class VesselMargin") +@Doc(value="do the doc of class VesselMargin") public class GrossValueOfLandingsOtherSpecies implements Export { /** to use log facility, just put in your code: log.info("..."); */ @@ -39,7 +38,7 @@ protected String [] necessaryResult = { ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET }; - + public String[] getNecessaryResult() { return this.necessaryResult; } @@ -47,26 +46,34 @@ public String getExportFilename() { return "GrossValueOfLandingsOtherSpecies"; } - + public String getExtensionFilename() { return ".csv"; } - + public String getDescription() { return _("cvs out strategy;date;value"); } public void export(SimulationStorage simulation, Writer out) throws Exception { MatrixND mat = simulation.getResultStorage().getMatrix(ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET); - for (MatrixIterator i=mat.iterator(); i.hasNext();) { - i.next(); - Object [] sems = i.getSemanticsCoordinates(); - Date date = (Date)sems[0]; - Strategy str = (Strategy)sems[1]; - Metier met = (Metier) sems[2]; - double val = i.getValue(); - out.write(str.getName() +";"+met.getName() +";"+ date.getDate() +";"+ val +"\n"); + if (mat == null) { + if (log.isWarnEnabled()) { + log.warn(_("Can't export GrossValueOfLandingsOtherSpecies, no '" + + ResultName.MATRIX_GROSS_VALUE_OF_LANDINGS_OTHER_SPECIES_PER_STRATEGY_MET + "' result")); + } } + else { + for (MatrixIterator i=mat.iterator(); i.hasNext();) { + i.next(); + Object [] sems = i.getSemanticsCoordinates(); + Date date = (Date)sems[0]; + Strategy str = (Strategy)sems[1]; + Metier met = (Metier) sems[2]; + double val = i.getValue(); + out.write(str.getName() +";"+met.getName() +";"+ date.getDate() +";"+ val +"\n"); + } + } /* var Parametre=sim.getParametre(); var PDate=Packages.fr.ifremer.nodb.Date;
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org