From 6ab65030ac6bd995d360b145c70c98e618590afa Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Fri, 13 Oct 2023 20:14:39 +0200 Subject: [PATCH] replace MATSim's UncheckedIOException with the one from Java --- .../christoph/ActivitiesAnalyzer.java | 2 +- .../analysis/christoph/TripsAnalyzer.java | 2 +- .../analysis/kai/KNAnalysisEventsHandler.java | 4 +- .../TripDistributionMatrix.java | 2 +- .../contrib/common/csv/CompactCSVWriter.java | 3 +- .../shifts/analysis/BreakCorridorXY.java | 2 +- .../shifts/analysis/ShiftDurationXY.java | 2 +- .../shifts/analysis/ShiftHistogram.java | 2 +- .../shifts/analysis/ShiftHistogramChart.java | 2 +- .../operations/shifts/io/DrtShiftsWriter.java | 2 +- .../shifts/io/OperationFacilitiesWriter.java | 2 +- .../java/org/matsim/contrib/zone/Zones.java | 15 +--- .../carriers/CarrierPlanXmlWriterV2_1.java | 2 +- .../usecases/analysis/CarrierScoreStats.java | 2 +- .../freightreceiver/ReceiverScoreStats.java | 2 +- .../freightreceiver/ReceiversWriter.java | 2 +- .../DestinationChoiceContext.java | 2 +- .../ReadOrComputeMaxDCScore.java | 2 +- .../frozenepsilons/ReadOrCreateKVals.java | 21 +++--- .../contrib/minibus/stats/PStatsOverview.java | 2 +- .../stats/operatorLogger/POperatorLogger.java | 2 +- .../distributed/SlaveControler.java | 3 +- .../listeners/controler/SlaveScoreWriter.java | 2 +- .../roadpricing/RoadPricingWriterXMLv1.java | 2 +- .../matsim/contrib/shared_mobility/RunIT.java | 1 - .../signals/data/AbstractSignalsReader.java | 2 +- .../signals/data/SignalsDataLoader.java | 6 +- .../ambertimes/v10/AmberTimesReader10.java | 6 +- .../io/ConflictingDirectionsWriter.java | 16 ++-- .../v10/IntergreenTimesReader10.java | 10 ++- .../v20/SignalControlReader20.java | 5 +- .../v20/SignalGroupsReader20.java | 5 +- .../v20/SignalSystemsReader20.java | 5 +- .../run/ReplanningAllocationDumper.java | 10 +-- .../socnetsim/run/ReplanningStatsDumper.java | 10 +-- .../analysis/CourtesyHistogramListener.java | 2 +- .../CountNSelectedJointTripsPerAgent.java | 2 +- .../scripts/DumpSizeOfSelectedJointPlans.java | 2 +- .../scripts/ExtractDriverBeeflyDetours.java | 2 +- .../analysis/FreightAnalysisEventHandler.java | 2 +- .../vsp/analysis/DefaultAnalysis_ik.java | 35 ++++----- .../TransitVehicleVolumeAnalyzer.java | 12 +-- .../org/matsim/analysis/CalcLegTimes.java | 2 +- .../org/matsim/analysis/LegHistogram.java | 2 +- .../matsim/analysis/LegHistogramChart.java | 2 +- .../analysis/LinkStatsControlerListener.java | 2 +- .../analysis/ModeStatsControlerListener.java | 2 +- .../analysis/ScoreStatsControlerListener.java | 18 ++--- .../matsim/analysis/TravelDistanceStats.java | 2 +- .../org/matsim/core/config/ConfigReader.java | 6 +- .../org/matsim/core/config/ConfigUtils.java | 4 +- .../org/matsim/core/config/ConfigWriter.java | 9 +-- .../config/ConfigWriterHandlerImplV1.java | 7 +- .../config/ConfigWriterHandlerImplV2.java | 2 +- .../core/controler/AbstractController.java | 3 +- .../matsim/core/events/EventsReaderJson.java | 14 ++-- .../events/algorithms/EventWriterJson.java | 4 +- .../events/algorithms/EventWriterXML.java | 6 +- .../matsim/core/network/io/NetworkWriter.java | 6 +- .../core/population/PopulationUtils.java | 2 +- .../io/ParallelPopulationWriterHandlerV6.java | 6 +- .../core/population/io/PopulationWriter.java | 2 +- .../io/StreamingPopulationWriter.java | 2 +- .../core/scenario/ScenarioLoaderImpl.java | 2 +- .../core/utils/gis/ShapeFileReader.java | 4 +- .../core/utils/gis/ShapeFileWriter.java | 8 +- .../core/utils/io/AbstractMatsimWriter.java | 3 +- .../org/matsim/core/utils/io/IOUtils.java | 73 ++++++++++--------- .../core/utils/io/MatsimFileTypeGuesser.java | 5 +- .../matsim/core/utils/io/MatsimXmlParser.java | 5 +- .../matsim/core/utils/io/MatsimXmlWriter.java | 1 + .../core/utils/io/OsmNetworkReader.java | 1 + .../core/utils/io/UncheckedIOException.java | 43 ----------- .../households/HouseholdsWriterV10.java | 15 ++-- .../TransitScheduleWriterV1.java | 2 +- .../TransitScheduleWriterV2.java | 2 +- .../api/TransitScheduleReader.java | 2 +- .../api/TransitScheduleWriter.java | 5 +- .../ObjectAttributesXmlWriter.java | 10 +-- .../AttributesXmlWriterDelegate.java | 2 +- .../matsim/vehicles/MatsimVehicleWriter.java | 8 +- .../org/matsim/vehicles/VehicleWriterV1.java | 6 +- .../org/matsim/vehicles/VehicleWriterV2.java | 2 +- .../org/matsim/visum/VisumNetworkReader.java | 6 +- .../OutputDirectoryHierarchyTest.java | 1 - .../org/matsim/testcases/MatsimTestUtils.java | 1 - 86 files changed, 227 insertions(+), 300 deletions(-) delete mode 100644 matsim/src/main/java/org/matsim/core/utils/io/UncheckedIOException.java diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java index f78d2eaa421..bb4239c27c9 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java @@ -39,11 +39,11 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.awt.*; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.*; import java.util.List; diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java index 02c4ddd82f8..390adb131b9 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java @@ -22,6 +22,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -45,7 +46,6 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; /** * Calculates: diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java index 3bde897e73c..ad1e9cfe938 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java @@ -43,13 +43,13 @@ import org.matsim.core.router.TripStructureUtils.Trip; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.utils.objectattributes.ObjectAttributes; import org.matsim.utils.objectattributes.ObjectAttributesXmlWriter; import org.matsim.vehicles.Vehicle; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.*; import java.util.Map.Entry; @@ -100,7 +100,7 @@ enum StatType { private Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler() ; - // general trip counter. Would, in theory, not necessary to do this per StatType, but I find it too brittle + // general trip counter. Would, in theory, not necessary to do this per StatType, but I find it too brittle // to avoid under- or over-counting with respect to loops. // private final Map legCount = new TreeMap() ; diff --git a/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java b/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java index 0f3a2f3dcfe..68c03dedb7e 100644 --- a/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java +++ b/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java @@ -35,7 +35,6 @@ import org.matsim.application.options.ShpOptions; import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; import org.opengis.feature.simple.SimpleFeature; @@ -43,6 +42,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.net.MalformedURLException; import java.nio.charset.StandardCharsets; import java.nio.file.Path; diff --git a/contribs/common/src/main/java/org/matsim/contrib/common/csv/CompactCSVWriter.java b/contribs/common/src/main/java/org/matsim/contrib/common/csv/CompactCSVWriter.java index c51911f531a..35d7ec5f660 100644 --- a/contribs/common/src/main/java/org/matsim/contrib/common/csv/CompactCSVWriter.java +++ b/contribs/common/src/main/java/org/matsim/contrib/common/csv/CompactCSVWriter.java @@ -21,10 +21,9 @@ package org.matsim.contrib.common.csv; import java.io.IOException; +import java.io.UncheckedIOException; import java.io.Writer; -import org.matsim.core.utils.io.UncheckedIOException; - import com.opencsv.CSVWriter; public class CompactCSVWriter extends CSVWriter { diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/BreakCorridorXY.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/BreakCorridorXY.java index 3a3b0762936..320b23977f9 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/BreakCorridorXY.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/BreakCorridorXY.java @@ -10,12 +10,12 @@ import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import jakarta.inject.Provider; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftDurationXY.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftDurationXY.java index f370d7f6b4f..d2ff4dda184 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftDurationXY.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftDurationXY.java @@ -9,11 +9,11 @@ import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogram.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogram.java index d4a519129fc..ce228469e50 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogram.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogram.java @@ -6,12 +6,12 @@ import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShift; import org.matsim.core.config.Config; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Time; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import java.io.UncheckedIOException; import java.util.Set; /** diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramChart.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramChart.java index bd877f2843d..d39236c91ee 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramChart.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramChart.java @@ -9,11 +9,11 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.matsim.core.utils.io.UncheckedIOException; import java.awt.*; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; /** * @author nkuehnel / MOIA diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/DrtShiftsWriter.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/DrtShiftsWriter.java index 92d3c43812d..0d5f56e5d75 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/DrtShiftsWriter.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/DrtShiftsWriter.java @@ -11,9 +11,9 @@ import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.*; import java.util.stream.Collectors; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/OperationFacilitiesWriter.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/OperationFacilitiesWriter.java index 22c3a1712e5..91b247738d1 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/OperationFacilitiesWriter.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/io/OperationFacilitiesWriter.java @@ -11,9 +11,9 @@ import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.*; import java.util.stream.Collectors; diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/zone/Zones.java b/contribs/dvrp/src/main/java/org/matsim/contrib/zone/Zones.java index 4a4be662672..34321d05068 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/zone/Zones.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/zone/Zones.java @@ -20,27 +20,14 @@ package org.matsim.contrib.zone; import java.io.File; +import java.io.UncheckedIOException; import java.net.MalformedURLException; import java.net.URL; -import java.util.List; import java.util.Map; -import org.geotools.geometry.jts.JTS; -import org.geotools.referencing.CRS; -import org.locationtech.jts.geom.MultiPolygon; -import org.locationtech.jts.geom.Polygon; -import org.locationtech.jts.geom.util.PolygonExtracter; import org.matsim.api.core.v01.Id; import org.matsim.contrib.zone.io.ZoneShpReader; -import org.matsim.contrib.zone.io.ZoneShpWriter; import org.matsim.contrib.zone.io.ZoneXmlReader; -import org.matsim.contrib.zone.io.ZoneXmlWriter; -import org.matsim.core.utils.geometry.geotools.MGC; -import org.matsim.core.utils.io.UncheckedIOException; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; public class Zones { public static Map, Zone> readZones(String zonesXmlFile, String zonesShpFile) { diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 76e47da676c..8b89b8f8216 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -29,7 +29,6 @@ import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Time; import org.matsim.utils.objectattributes.AttributeConverter; import org.matsim.utils.objectattributes.attributable.AttributesXmlWriterDelegate; @@ -37,6 +36,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/analysis/CarrierScoreStats.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/analysis/CarrierScoreStats.java index 84195625eeb..dd289a49b1b 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/analysis/CarrierScoreStats.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/analysis/CarrierScoreStats.java @@ -31,13 +31,13 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.CarrierPlan; import org.matsim.freight.carriers.Carriers; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Locale; /** diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java index 5e9534e4911..a9a63491a07 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java @@ -15,11 +15,11 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Locale; /** diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiversWriter.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiversWriter.java index d193d33284c..cd9e2f33a06 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiversWriter.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiversWriter.java @@ -25,9 +25,9 @@ import org.matsim.freight.carriers.TimeWindow; import org.matsim.core.api.internal.MatsimWriter; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import java.io.IOException; +import java.io.UncheckedIOException; /** * Writes a {@link Receivers} container in the MATSim XML format. diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java index 68e787690ce..2016faa9147 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java @@ -19,6 +19,7 @@ package org.matsim.contrib.locationchoice.frozenepsilons; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -43,7 +44,6 @@ import org.matsim.core.utils.collections.CollectionUtils; import org.matsim.core.utils.collections.QuadTree; import org.matsim.core.utils.collections.Tuple; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.facilities.ActivityFacility; import org.matsim.facilities.ActivityFacilityImpl; import org.matsim.facilities.ActivityOption; diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrComputeMaxDCScore.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrComputeMaxDCScore.java index 3d9c24759a9..b18968fa170 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrComputeMaxDCScore.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrComputeMaxDCScore.java @@ -19,6 +19,7 @@ package org.matsim.contrib.locationchoice.frozenepsilons; +import java.io.UncheckedIOException; import java.util.HashSet; import java.util.List; @@ -30,7 +31,6 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.contrib.locationchoice.utils.ScaleEpsilon; import org.matsim.core.router.TripStructureUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.utils.objectattributes.ObjectAttributes; import org.matsim.utils.objectattributes.ObjectAttributesXmlReader; diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrCreateKVals.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrCreateKVals.java index 4b374fe53cb..fd0ae4c124d 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrCreateKVals.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/ReadOrCreateKVals.java @@ -24,28 +24,29 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.facilities.ActivityFacility; import org.matsim.utils.objectattributes.ObjectAttributes; import org.matsim.utils.objectattributes.ObjectAttributesXmlReader; - class ReadOrCreateKVals { - +import java.io.UncheckedIOException; + +class ReadOrCreateKVals { + private static final Logger log = LogManager.getLogger(ReadOrCreateKVals.class); - + private Scenario scenario; private ObjectAttributes facilitiesKValues = new ObjectAttributes(); private ObjectAttributes personsKValues = new ObjectAttributes(); private RandomFromVarDistr rnd; - + public ReadOrCreateKVals(long seed, Scenario scenario) { this.scenario = scenario; this.rnd = new RandomFromVarDistr(); this.rnd.setSeed(seed); } - + /* - * return 0 if files are read and 1 if k values are created. + * return 0 if files are read and 1 if k values are created. * This is important to know for reading (case 0) or computation of maxDCScore (case 1) */ public int run() { @@ -58,7 +59,7 @@ public int run() { return 1; } log.info("at least one facility kValue or person kValue is missing, start crating all values"); - if (pkValuesFileName != null && fkValuesFileName != null && maxEpsValuesFileName != null) { + if (pkValuesFileName != null && fkValuesFileName != null && maxEpsValuesFileName != null) { ObjectAttributesXmlReader persKValuesReader = new ObjectAttributesXmlReader(this.personsKValues); ObjectAttributesXmlReader facKValuesReader = new ObjectAttributesXmlReader(this.facilitiesKValues); try { @@ -108,7 +109,7 @@ public void assignKValues() { this.assignKValuesPersons(); this.assignKValuesAlternatives(); } - + // does not matter which distribution is chosen here private void assignKValuesPersons() { for (Person p : this.scenario.getPopulation().getPersons().values()) { @@ -120,5 +121,5 @@ private void assignKValuesAlternatives() { facility.getAttributes().putAttribute("k", rnd.getUniform(1.0)); } } - + } diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java index 29bbb3292c2..1cdc24a12f5 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.List; @@ -45,7 +46,6 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; /** * Calculates at the end of each iteration the following statistics: diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/operatorLogger/POperatorLogger.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/operatorLogger/POperatorLogger.java index 16fe42875af..11732305d60 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/operatorLogger/POperatorLogger.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/operatorLogger/POperatorLogger.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.List; @@ -42,7 +43,6 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.pt.transitSchedule.api.TransitRoute; import org.matsim.pt.transitSchedule.api.TransitStopFacility; diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java index 6c5240a48f2..3d3508640a0 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.UncheckedIOException; import java.net.ConnectException; import java.net.Socket; import java.util.ArrayList; @@ -54,8 +55,6 @@ import org.matsim.core.router.util.TravelTime; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime; -import org.matsim.core.utils.io.UncheckedIOException; -import org.matsim.pt.router.TransitRouter; import com.google.inject.Inject; diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java index a4c11ab6293..2d0576c8a85 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java @@ -9,10 +9,10 @@ import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; public class SlaveScoreWriter implements IterationEndsListener, ShutdownListener, StartupListener { diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingWriterXMLv1.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingWriterXMLv1.java index 053359bf14e..6049a2a6d73 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingWriterXMLv1.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingWriterXMLv1.java @@ -21,13 +21,13 @@ package org.matsim.contrib.roadpricing; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.List; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.roadpricing.RoadPricingSchemeImpl.Cost; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Time; /** diff --git a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java index f28558a681b..36e3a978c99 100644 --- a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java +++ b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java @@ -32,7 +32,6 @@ import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.examples.ExamplesUtils; public class RunIT { diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/AbstractSignalsReader.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/AbstractSignalsReader.java index ecf64bfdb9e..14051c475ae 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/AbstractSignalsReader.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/AbstractSignalsReader.java @@ -4,11 +4,11 @@ import org.apache.logging.log4j.Logger; import org.matsim.core.api.internal.MatsimReader; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.xml.sax.InputSource; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.net.URL; /** diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/SignalsDataLoader.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/SignalsDataLoader.java index 62e4a3bf966..93f86f8c301 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/SignalsDataLoader.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/SignalsDataLoader.java @@ -31,16 +31,16 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.net.URL; /** * Loads all data files related to the traffic signal systems model. - * + * * @author dgrether * */ @@ -147,7 +147,7 @@ private void loadSystems(SignalsData data){ log.info("Signals: No signal systems file set, can't load signal systems information!"); } } - + private void loadConflicts(SignalsData data) { if (this.signalConfig.getConflictingDirectionsFile() != null) { ConflictingDirectionsReader reader = new ConflictingDirectionsReader(data.getConflictingDirectionsData()); diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesReader10.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesReader10.java index 56f621e8387..dfeab1679d9 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesReader10.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesReader10.java @@ -29,13 +29,15 @@ import org.matsim.contrib.signals.data.AbstractSignalsReader; import org.matsim.contrib.signals.model.Signal; import org.matsim.contrib.signals.model.SignalSystem; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.jaxb.amberTimes10.XMLAmberTimes; import org.matsim.jaxb.amberTimes10.XMLAmberTimes.XMLSignalSystem; import org.matsim.jaxb.amberTimes10.XMLAmberTimes.XMLSignalSystem.XMLSignal; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import java.io.IOException; +import java.io.UncheckedIOException; + /** * @author jbischoff * @author dgrether @@ -60,7 +62,7 @@ public void read( InputSource stream ) { u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("/dtd/amberTimes_v1.0.xsd"))); xmlatdefs = (XMLAmberTimes) u.unmarshal(stream); } catch (JAXBException | SAXException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } // convert from Jaxb types to MATSim-API conform types diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/conflicts/io/ConflictingDirectionsWriter.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/conflicts/io/ConflictingDirectionsWriter.java index 77f0fe953d3..4ec961748a0 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/conflicts/io/ConflictingDirectionsWriter.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/conflicts/io/ConflictingDirectionsWriter.java @@ -21,13 +21,13 @@ package org.matsim.contrib.signals.data.conflicts.io; import java.io.IOException; +import java.io.UncheckedIOException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.contrib.signals.data.conflicts.ConflictData; import org.matsim.core.api.internal.MatsimWriter; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; /** * @author tthunig @@ -35,20 +35,20 @@ public final class ConflictingDirectionsWriter extends MatsimXmlWriter implements MatsimWriter { private static final Logger LOG = LogManager.getLogger(ConflictingDirectionsWriter.class); - + private ConflictData conflictData; private ConflictingDirectionsWriterHandlerImpl handler; - - + + public ConflictingDirectionsWriter(ConflictData conflictData) { this.conflictData = conflictData; this.handler = new ConflictingDirectionsWriterHandlerImpl(); } - + @Override public void write(String filename) { LOG.info("Writing conflicting direction data to file: " + filename + "..."); - + try { this.openFile(filename); this.handler.writeHeaderAndStartElement(this.writer); @@ -57,11 +57,11 @@ public void write(String filename) { this.handler.endConflictData(this.writer); LOG.info("Conflict data written to: " + filename); } catch (IOException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } finally { this.close(); } - + LOG.info("done."); } diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesReader10.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesReader10.java index 3635967e656..c91244bb51a 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesReader10.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesReader10.java @@ -29,24 +29,26 @@ import org.matsim.contrib.signals.data.AbstractSignalsReader; import org.matsim.contrib.signals.model.SignalGroup; import org.matsim.contrib.signals.model.SignalSystem; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.jaxb.intergreenTimes10.XMLEndingSignalGroupType; import org.matsim.jaxb.intergreenTimes10.XMLIntergreenTimes; import org.matsim.jaxb.intergreenTimes10.XMLIntergreenTimes.XMLSignalSystem; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import java.io.IOException; +import java.io.UncheckedIOException; + /** * @author dgrether */ public final class IntergreenTimesReader10 extends AbstractSignalsReader{ - + private IntergreenTimesData intergreensData; public IntergreenTimesReader10(IntergreenTimesData intergreenTimesData) { this.intergreensData = intergreenTimesData; } - + public void read(InputSource stream) throws UncheckedIOException { try { Unmarshaller u = JAXBContext.newInstance(org.matsim.jaxb.intergreenTimes10.ObjectFactory.class).createUnmarshaller(); @@ -66,7 +68,7 @@ public void read(InputSource stream) throws UncheckedIOException { } } } catch (JAXBException | SAXException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } } } diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlReader20.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlReader20.java index 9cbd9f1a73d..35ead4e1f22 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlReader20.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlReader20.java @@ -19,7 +19,9 @@ * *********************************************************************** */ package org.matsim.contrib.signals.data.signalcontrol.v20; +import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import javax.xml.XMLConstants; import jakarta.xml.bind.JAXBContext; @@ -34,7 +36,6 @@ import org.matsim.contrib.signals.model.SignalGroup; import org.matsim.contrib.signals.model.SignalPlan; import org.matsim.contrib.signals.model.SignalSystem; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.jaxb.signalcontrol20.XMLSignalControl; import org.matsim.jaxb.signalcontrol20.XMLSignalGroupSettingsType; import org.matsim.jaxb.signalcontrol20.XMLSignalPlanType; @@ -63,7 +64,7 @@ private XMLSignalControl readSignalControl20Stream(InputStream stream) { u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("/dtd/signalControl_v2.0.xsd"))); return (XMLSignalControl) u.unmarshal(stream); } catch (JAXBException | SAXException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } } diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroupsReader20.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroupsReader20.java index 4128a60fe83..edbedf63002 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroupsReader20.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroupsReader20.java @@ -19,7 +19,9 @@ * *********************************************************************** */ package org.matsim.contrib.signals.data.signalgroups.v20; +import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.net.URL; import javax.xml.XMLConstants; @@ -34,7 +36,6 @@ import org.matsim.contrib.signals.model.SignalSystem; import org.matsim.core.api.internal.MatsimReader; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.jaxb.signalgroups20.XMLIdRefType; import org.matsim.jaxb.signalgroups20.XMLSignalGroupType; import org.matsim.jaxb.signalgroups20.XMLSignalGroups; @@ -97,7 +98,7 @@ private XMLSignalGroups readXmlSignalGroups( InputSource stream ) { u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("/dtd/signalGroups_v2.0.xsd"))); return (XMLSignalGroups) u.unmarshal(stream); } catch (SAXException | JAXBException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } } diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsReader20.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsReader20.java index 40a74ea839d..3d1bb1fab5a 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsReader20.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsReader20.java @@ -19,7 +19,9 @@ * *********************************************************************** */ package org.matsim.contrib.signals.data.signalsystems.v20; +import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import javax.xml.XMLConstants; import jakarta.xml.bind.JAXBContext; @@ -32,7 +34,6 @@ import org.matsim.contrib.signals.data.AbstractSignalsReader; import org.matsim.contrib.signals.model.Signal; import org.matsim.contrib.signals.model.SignalSystem; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.jaxb.signalsystems20.XMLIdRefType; import org.matsim.jaxb.signalsystems20.XMLSignalSystemType; import org.matsim.jaxb.signalsystems20.XMLSignalSystems; @@ -91,7 +92,7 @@ private XMLSignalSystems getXmlSignalSystems(InputStream stream) { u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("/dtd/signalSystems_v2.0.xsd"))); return (XMLSignalSystems) u.unmarshal(stream); } catch (JAXBException | SAXException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } } } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningAllocationDumper.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningAllocationDumper.java index 3b5fe3725c4..0c41c7bf2be 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningAllocationDumper.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningAllocationDumper.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import org.matsim.api.core.v01.population.Person; import org.matsim.core.controler.events.BeforeMobsimEvent; @@ -30,7 +31,6 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.contrib.socnetsim.framework.replanning.GroupPlanStrategy; import org.matsim.contrib.socnetsim.framework.replanning.GroupStrategyManager; @@ -54,7 +54,7 @@ public void notifyStartup(final StartupEvent event) { this.writer = IOUtils.getBufferedWriter( outPath ); try { this.writer.write( "iter\tagentId\tgroup\tstrategy" ); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } @@ -76,7 +76,7 @@ public void notifyAlloc( this.writer.write( strategy.toString() ); } group++; - } + } catch (IOException e) { throw new UncheckedIOException( e ); } @@ -86,7 +86,7 @@ public void notifyAlloc( public void notifyShutdown(ShutdownEvent event) { try { this.writer.close(); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } @@ -96,7 +96,7 @@ public void notifyShutdown(ShutdownEvent event) { public void notifyBeforeMobsim(BeforeMobsimEvent event) { try { this.writer.flush(); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningStatsDumper.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningStatsDumper.java index 3c8bf0793b1..c24b3dcf15d 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningStatsDumper.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/run/ReplanningStatsDumper.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import org.matsim.core.controler.events.BeforeMobsimEvent; import org.matsim.core.controler.events.ShutdownEvent; @@ -29,7 +30,6 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.contrib.socnetsim.framework.replanning.GroupPlanStrategy; import org.matsim.contrib.socnetsim.framework.replanning.GroupStrategyManager; @@ -52,7 +52,7 @@ public void notifyStartup(final StartupEvent event) { this.writer = IOUtils.getBufferedWriter( outPath ); try { this.writer.write( "iter\tgroupSize\tstrategy" ); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } @@ -71,7 +71,7 @@ public void notifyAlloc( this.writer.write( ""+g.getPersons().size() ); this.writer.write( "\t" ); this.writer.write( strategy.toString() ); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } @@ -81,7 +81,7 @@ public void notifyAlloc( public void notifyShutdown(ShutdownEvent event) { try { this.writer.close(); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } @@ -91,7 +91,7 @@ public void notifyShutdown(ShutdownEvent event) { public void notifyBeforeMobsim(BeforeMobsimEvent event) { try { this.writer.flush(); - } + } catch (IOException e) { throw new UncheckedIOException( e ); } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java index 824a87c16b4..c659828ea59 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java @@ -36,12 +36,12 @@ import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.listener.IterationEndsListener; import org.matsim.core.controler.listener.IterationStartsListener; -import org.matsim.core.utils.io.UncheckedIOException; import jakarta.inject.Singleton; import java.awt.*; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; /** * @author thibautd diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/CountNSelectedJointTripsPerAgent.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/CountNSelectedJointTripsPerAgent.java index a14e37a7865..b86e9e905fb 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/CountNSelectedJointTripsPerAgent.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/CountNSelectedJointTripsPerAgent.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.List; import org.matsim.api.core.v01.Scenario; @@ -32,7 +33,6 @@ import org.matsim.core.router.TripStructureUtils.Trip; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.contrib.socnetsim.jointtrips.population.JointActingTypes; diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/DumpSizeOfSelectedJointPlans.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/DumpSizeOfSelectedJointPlans.java index 2fca6b179bc..26a7c17c9e1 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/DumpSizeOfSelectedJointPlans.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/DumpSizeOfSelectedJointPlans.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -33,7 +34,6 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.io.MatsimXmlParser; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.xml.sax.Attributes; diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/ExtractDriverBeeflyDetours.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/ExtractDriverBeeflyDetours.java index a951ef14781..da34ee7ed57 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/ExtractDriverBeeflyDetours.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/scripts/ExtractDriverBeeflyDetours.java @@ -21,13 +21,13 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Stack; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.io.MatsimXmlParser; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.xml.sax.Attributes; diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java index 4ffe3ba7688..5a9daccf1cf 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java @@ -41,13 +41,13 @@ import org.matsim.freight.carriers.events.eventhandler.FreightShipmentDeliveryEventHandler; import org.matsim.freight.carriers.events.eventhandler.FreightShipmentPickupEventHandler; import org.matsim.core.network.NetworkUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.Vehicles; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.LinkedHashMap; import java.util.LinkedHashSet; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis_ik.java b/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis_ik.java index 7fcaa40fb41..59e04000322 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis_ik.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis_ik.java @@ -20,38 +20,35 @@ package playground.vsp.analysis; import java.io.File; +import java.io.UncheckedIOException; import java.util.LinkedList; import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.events.EventsReaderXMLv1; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.gbl.Gbl; import org.matsim.core.scenario.MutableScenario; -import org.matsim.core.utils.io.UncheckedIOException; import playground.vsp.analysis.modules.AbstractAnalysisModule; import playground.vsp.analysis.modules.waitingTimes.WaitingTimesAnalyzer; -import playground.vsp.analysis.modules.welfareAnalyzer.WelfareAnalyzer; /** - * + * * @author ikaddoura, aneumann * */ public class DefaultAnalysis_ik { - + private final static Logger log = LogManager.getLogger(DefaultAnalysis_ik.class); - + private final String outputDir; private final String eventsFile; private final MutableScenario scenario; - + private final List anaModules = new LinkedList(); public DefaultAnalysis_ik(MutableScenario scenario, String iterationOutputDir, String eventsFile) { @@ -62,7 +59,7 @@ public DefaultAnalysis_ik(MutableScenario scenario, String iterationOutputDir, S public void init(String aasRunnerConfigFile){ log.info("Configuration through config file is currently not implemented. Initializing all modules with defaults..."); - + // END of configuration file // EmissionEventsWriter emiWriter = new EmissionEventsWriter(ptDriverPrefix, this.outputDir); @@ -85,35 +82,35 @@ public void init(String aasRunnerConfigFile){ // vcg.setDetailedColdEmissionFactorsFile(detailedColdEmissionFactorsFile); // emiWriter.init(scenario); // this.anaModules.add(emiWriter); -// +// // // emission events file required for this analysis module: // String emissionsEventsFile = "/Users/Ihab/Documents/workspace/shared-svn/studies/ihab/test/output/test_fakePt/ITERS/it.0/analysis/EmissionEventsWriter/emission.events.xml"; // EmissionsAnalyzer emiAna = new EmissionsAnalyzer(ptDriverPrefix, emissionsEventsFile); // emiAna.init(scenario); // this.anaModules.add(emiAna); -// +// // // number of detailed slots required for this analysis module // int numberOfDetailedSlots = 5; // VehDelayAtStopHistogramAnalyzer delayHistogramAna = new VehDelayAtStopHistogramAnalyzer(ptDriverPrefix, numberOfDetailedSlots); // delayHistogramAna.init(scenario); // this.anaModules.add(delayHistogramAna); - + // WelfareAnalyzer welfareAna = new WelfareAnalyzer(); // welfareAna.init(scenario); // this.anaModules.add(welfareAna); - + WaitingTimesAnalyzer waitingTimeAna = new WaitingTimesAnalyzer(); waitingTimeAna.init(scenario); this.anaModules.add(waitingTimeAna); // END ugly code - Initialization needs to be configurable - + // for (Person person : this.scenario.getPopulation().getPersons().values()) { // if (person.getId().toString().startsWith(ptDriverPrefix)){ // throw new RuntimeException("Person " + person.getId() + " has the same prefix as the pt Driver: " + ptDriverPrefix + ". Aborting..."); // } // } - + log.info("Initializing all modules with defaults... done."); } @@ -124,7 +121,7 @@ public void preProcess(){ } log.info("Preprocessing all modules... done."); } - + public void run(){ EventsManager eventsManager = EventsUtils.createEventsManager(); for (AbstractAnalysisModule module : this.anaModules) { @@ -140,7 +137,7 @@ public void run(){ log.warn("Failed parsing " + this.eventsFile + ". Skipping events handling..."); } } - + public void postProcess(){ log.info("Postprocessing all modules..."); for (AbstractAnalysisModule module : this.anaModules) { @@ -148,12 +145,12 @@ public void postProcess(){ } log.info("Postprocessing all modules... done."); } - + public void writeResults(){ log.info("Writing results for all modules..."); log.info("Generating output directory " + this.outputDir); new File(this.outputDir).mkdir(); - + for (AbstractAnalysisModule module : this.anaModules) { String moduleOutputDir = this.outputDir + module.getName() + "/"; log.info("Writing results of module " + module.getName() + " to " + moduleOutputDir + "..."); diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java index db215077acb..0063fd989f6 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java @@ -18,6 +18,7 @@ * *********************************************************************** */ package playground.vsp.analysis.modules.transitVehicleVolume; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -40,7 +41,6 @@ import org.matsim.core.events.handler.EventHandler; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.ShapeFileWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.counts.Count; import org.matsim.counts.Counts; import org.matsim.counts.Volume; @@ -90,13 +90,13 @@ public void preProcessData() { public void postProcessData() { this.createTotals(); } - + private void createTotals() { // count totals this.mode2Link2Total = new HashMap>(); Double total; for(Entry> e: this.handler.getMode2Counts().entrySet()){ - Map temp = new HashMap(); + Map temp = new HashMap(); for(Count c: e.getValue().getCounts().values()){ total = new Double(0.); for(Volume v: c.getVolumes().values()){ @@ -114,7 +114,7 @@ public void writeResults(String outputFolder) { writeModeShape(e.getKey(), e.getValue(), this.mode2Link2Total.get(e.getKey()), outputFolder + e.getKey() + ".shp", this.targetCoordinateSystem); } } - + private void writeModeShape(String name, Counts counts, Map mode2Total, String file, String targetCoordinateSystem){ SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setCRS(MGC.getCRS(targetCoordinateSystem)); @@ -126,9 +126,9 @@ private void writeModeShape(String name, Counts counts, Map mo b.add(String.valueOf(i), Double.class); } SimpleFeatureBuilder builder = new SimpleFeatureBuilder(b.buildFeatureType()); - + Collection features = new ArrayList(); - + Object[] featureAttribs; for(Count c: counts.getCounts().values()){ featureAttribs = new Object[2 + this.handler.getMaxTimeSlice() + 1]; diff --git a/matsim/src/main/java/org/matsim/analysis/CalcLegTimes.java b/matsim/src/main/java/org/matsim/analysis/CalcLegTimes.java index 77b5dbb9057..f221045b9bb 100644 --- a/matsim/src/main/java/org/matsim/analysis/CalcLegTimes.java +++ b/matsim/src/main/java/org/matsim/analysis/CalcLegTimes.java @@ -34,12 +34,12 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Time; import jakarta.inject.Inject; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Map; import java.util.TreeMap; diff --git a/matsim/src/main/java/org/matsim/analysis/LegHistogram.java b/matsim/src/main/java/org/matsim/analysis/LegHistogram.java index 32b8f28b94e..aa912700fdb 100644 --- a/matsim/src/main/java/org/matsim/analysis/LegHistogram.java +++ b/matsim/src/main/java/org/matsim/analysis/LegHistogram.java @@ -32,7 +32,6 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Time; import jakarta.inject.Inject; @@ -40,6 +39,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import java.io.UncheckedIOException; import java.util.Map; import java.util.Set; import java.util.TreeMap; diff --git a/matsim/src/main/java/org/matsim/analysis/LegHistogramChart.java b/matsim/src/main/java/org/matsim/analysis/LegHistogramChart.java index 31d5a86c9c7..551f29e4cd2 100644 --- a/matsim/src/main/java/org/matsim/analysis/LegHistogramChart.java +++ b/matsim/src/main/java/org/matsim/analysis/LegHistogramChart.java @@ -31,11 +31,11 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.matsim.core.utils.io.UncheckedIOException; import java.awt.*; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; public class LegHistogramChart { static JFreeChart getGraphic(final LegHistogram.DataFrame dataFrame, final String mode, int iteration) { diff --git a/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java index 5d28e0b9852..771b2dc2b95 100644 --- a/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java @@ -37,10 +37,10 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.router.util.TravelTime; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import jakarta.inject.Inject; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.*; /** diff --git a/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java index 310c70fddc0..c9f4ff89ce0 100644 --- a/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java @@ -24,6 +24,7 @@ import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.*; import java.util.List; import java.util.Map.Entry; @@ -53,7 +54,6 @@ import org.matsim.core.utils.charts.StackedBarChart; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; /** diff --git a/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java index ecaea8e9aef..1593cec5243 100644 --- a/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java @@ -20,13 +20,18 @@ package org.matsim.analysis; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.*; +import java.util.stream.Collectors; + import jakarta.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.Config; import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.GlobalConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -40,17 +45,6 @@ import org.matsim.core.population.PopulationUtils; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeMap; -import java.util.stream.Collectors; /** * Calculates at the end of each iteration the following statistics: diff --git a/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java b/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java index 587e06d1d88..cc46e9434fd 100644 --- a/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java +++ b/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java @@ -34,11 +34,11 @@ import org.matsim.core.router.TripStructureUtils.Trip; import org.matsim.core.utils.charts.XYLineChart; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import jakarta.inject.Inject; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.DoubleSummaryStatistics; import java.util.Locale; import java.util.stream.Collectors; diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java index b39ba43eecf..f35d8adc593 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java @@ -20,17 +20,13 @@ package org.matsim.core.config; -import java.io.File; -import java.io.InputStream; +import java.io.UncheckedIOException; import java.util.Stack; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.core.api.internal.MatsimSomeReader; import org.matsim.core.utils.io.MatsimXmlParser; -import org.matsim.core.utils.io.UncheckedIOException; import org.xml.sax.Attributes; -import org.xml.sax.InputSource; /** * A reader for config-files of MATSim. This reader recognizes the format of the config-file and uses diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java index 8747648e176..df396f15b1a 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java @@ -27,16 +27,14 @@ import org.matsim.core.config.groups.VspExperimentalConfigGroup.VspDefaultsCheckingLevel; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.File; +import java.io.UncheckedIOException; import java.net.URL; import java.util.Arrays; /** * @author mrieser - */ -/** * @author nagel * */ diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigWriter.java b/matsim/src/main/java/org/matsim/core/config/ConfigWriter.java index 5be496a65e4..257775fb139 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigWriter.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigWriter.java @@ -22,15 +22,14 @@ import java.io.BufferedWriter; import java.io.IOException; -import java.util.Iterator; +import java.io.UncheckedIOException; import org.matsim.core.api.internal.MatsimWriter; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; public final class ConfigWriter extends MatsimXmlWriter implements MatsimWriter { - - public static enum Verbosity {all, minimal } + + public static enum Verbosity {all, minimal } ////////////////////////////////////////////////////////////////////// // member variables @@ -93,7 +92,7 @@ public final void writeFileV1(final String filename) { this.handler = new ConfigWriterHandlerImplV1(); write( filename ); } - + public final void writeFileV2(final String filename) { this.dtd = "http://www.matsim.org/files/dtd/config_v2.dtd"; this.handler = new ConfigWriterHandlerImplV2(Verbosity.all); diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV1.java b/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV1.java index f786998a614..53813b54e4b 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV1.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV1.java @@ -22,10 +22,9 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Map; -import org.matsim.core.utils.io.UncheckedIOException; - /*package*/ class ConfigWriterHandlerImplV1 extends ConfigWriterHandler { private String newline = "\n"; @@ -75,9 +74,9 @@ void writeModule(final ConfigGroup module, final BufferedWriter out) throws Unch out.write("\t"); out.write(this.newline); - + boolean lastHadComment = false; - + for (Map.Entry entry : params.entrySet()) { if (comments.get(entry.getKey()) != null) { out.write(this.newline); diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java b/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java index c7aaa094de9..c511b1952da 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java @@ -28,10 +28,10 @@ import org.matsim.core.config.groups.ScoringConfigGroup.ScoringParameterSet; import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; diff --git a/matsim/src/main/java/org/matsim/core/controler/AbstractController.java b/matsim/src/main/java/org/matsim/core/controler/AbstractController.java index ccccfcd92c2..5edf2d01b20 100644 --- a/matsim/src/main/java/org/matsim/core/controler/AbstractController.java +++ b/matsim/src/main/java/org/matsim/core/controler/AbstractController.java @@ -26,9 +26,10 @@ import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.listener.ControlerListener; import org.matsim.core.gbl.MatsimRandom; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.utils.MemoryObserver; +import java.io.UncheckedIOException; + /*package*/ abstract class AbstractController { // we already had one case where a method of this was removed, causing downstream failures; better just not // offer it at all; framework with injector should now be flexible enough. kai, mar'18 diff --git a/matsim/src/main/java/org/matsim/core/events/EventsReaderJson.java b/matsim/src/main/java/org/matsim/core/events/EventsReaderJson.java index 9c1f9dea65c..85d4e24fba0 100644 --- a/matsim/src/main/java/org/matsim/core/events/EventsReaderJson.java +++ b/matsim/src/main/java/org/matsim/core/events/EventsReaderJson.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.UncheckedIOException; import java.net.URL; import java.util.HashMap; import java.util.Iterator; @@ -63,7 +64,6 @@ import org.matsim.api.core.v01.events.HasPersonId; import org.matsim.core.events.MatsimEventsReader.CustomEventMapper; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.facilities.ActivityFacility; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -147,13 +147,13 @@ private void parseEvent(JsonNode o) { // === material related to wait2link below here === if (LinkLeaveEvent.EVENT_TYPE.equals(eventType)) { - this.events.processEvent(new LinkLeaveEvent(time, + this.events.processEvent(new LinkLeaveEvent(time, Id.create(o.get(LinkLeaveEvent.ATTRIBUTE_VEHICLE).asText(), Vehicle.class), Id.create(o.get(LinkLeaveEvent.ATTRIBUTE_LINK).asText(), Link.class) // had driver id in previous version )); } else if (LinkEnterEvent.EVENT_TYPE.equals(eventType)) { - this.events.processEvent(new LinkEnterEvent(time, + this.events.processEvent(new LinkEnterEvent(time, Id.create(o.get(LinkEnterEvent.ATTRIBUTE_VEHICLE).asText(), Vehicle.class), Id.create(o.get(LinkEnterEvent.ATTRIBUTE_LINK).asText(), Link.class) // had driver id in previous version @@ -161,7 +161,7 @@ private void parseEvent(JsonNode o) { } else if (VehicleEntersTrafficEvent.EVENT_TYPE.equals(eventType)) { // (this is the new version, marked by the new events name) - this.events.processEvent(new VehicleEntersTrafficEvent(time, + this.events.processEvent(new VehicleEntersTrafficEvent(time, Id.create(o.get(HasPersonId.ATTRIBUTE_PERSON).asText(), Person.class), Id.create(o.get(VehicleEntersTrafficEvent.ATTRIBUTE_LINK).asText(), Link.class), Id.create(o.get(VehicleEntersTrafficEvent.ATTRIBUTE_VEHICLE).asText(), Vehicle.class), @@ -189,7 +189,7 @@ private void parseEvent(JsonNode o) { position )); } else if (VehicleLeavesTrafficEvent.EVENT_TYPE.equals(eventType)) { - this.events.processEvent(new VehicleLeavesTrafficEvent(time, + this.events.processEvent(new VehicleLeavesTrafficEvent(time, Id.create(o.get(VehicleLeavesTrafficEvent.ATTRIBUTE_DRIVER).asText(), Person.class), Id.create(o.get(VehicleLeavesTrafficEvent.ATTRIBUTE_LINK).asText(), Link.class), o.has(VehicleLeavesTrafficEvent.ATTRIBUTE_VEHICLE) ? Id.create(o.get(VehicleLeavesTrafficEvent.ATTRIBUTE_VEHICLE).asText(), Vehicle.class) : null, @@ -206,7 +206,7 @@ else if (ActivityEndEvent.EVENT_TYPE.equals(eventType)) { coord = new Coord(xx, yy); } this.events.processEvent(new ActivityEndEvent( - time, + time, Id.create(o.get(HasPersonId.ATTRIBUTE_PERSON).asText(), Person.class), Id.create(o.get(HasLinkId.ATTRIBUTE_LINK).asText(), Link.class), o.has(HasFacilityId.ATTRIBUTE_FACILITY) ? Id.create(o.get(HasFacilityId.ATTRIBUTE_FACILITY).asText(), ActivityFacility.class) : null, @@ -297,7 +297,7 @@ else if (ActivityEndEvent.EVENT_TYPE.equals(eventType)) { this.events.processEvent(new PersonLeavesVehicleEvent(time, pId, vId)); } else if (TeleportationArrivalEvent.EVENT_TYPE.equals(eventType)) { this.events.processEvent(new TeleportationArrivalEvent( - time, + time, Id.create(o.get(TeleportationArrivalEvent.ATTRIBUTE_PERSON).asText(), Person.class), o.get(TeleportationArrivalEvent.ATTRIBUTE_DISTANCE).asDouble(), o.path(TeleportationArrivalEvent.ATTRIBUTE_MODE).asText(null))); diff --git a/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterJson.java b/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterJson.java index f4a9cd13eea..85c26e35e00 100644 --- a/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterJson.java +++ b/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterJson.java @@ -6,11 +6,11 @@ import org.matsim.api.core.v01.events.Event; import org.matsim.core.events.handler.BasicEventHandler; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.util.Map; /** @@ -69,4 +69,4 @@ public void handleEvent(final Event event) { public void reset(final int iter) { } -} \ No newline at end of file +} diff --git a/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterXML.java b/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterXML.java index a1968661df9..b6099c9e69b 100644 --- a/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterXML.java +++ b/matsim/src/main/java/org/matsim/core/events/algorithms/EventWriterXML.java @@ -23,12 +23,12 @@ import org.matsim.api.core.v01.events.Event; import org.matsim.core.events.handler.BasicEventHandler; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.Map; @@ -98,7 +98,7 @@ public void handleEvent(final Event event) { /** * Encodes the given string in such a way that it no longer contains * characters that have a special meaning in xml. - * + * * @see http://www.w3.org/International/questions/qa-escapes#use * @param attributeValue * @return String with some characters replaced by their xml-encoding. @@ -141,7 +141,7 @@ private String encodeAttributeValue(final String attributeValue) { bf.append(ch); } } - + return bf.toString(); } return attributeValue; diff --git a/matsim/src/main/java/org/matsim/core/network/io/NetworkWriter.java b/matsim/src/main/java/org/matsim/core/network/io/NetworkWriter.java index 9d02042583c..d8f7dc4e207 100644 --- a/matsim/src/main/java/org/matsim/core/network/io/NetworkWriter.java +++ b/matsim/src/main/java/org/matsim/core/network/io/NetworkWriter.java @@ -30,18 +30,18 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.utils.objectattributes.AttributeConverter; import java.io.IOException; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; public final class NetworkWriter extends MatsimXmlWriter implements MatsimWriter { - + private static final Logger log = LogManager.getLogger(NetworkWriter.class); - + private final Network network; private final CoordinateTransformation transformation; private final Map,AttributeConverter> converters = new HashMap<>(); diff --git a/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java b/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java index 7f187b285a4..739b890ce91 100644 --- a/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java +++ b/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -71,7 +72,6 @@ import org.matsim.core.scenario.MutableScenario; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.OptionalTime; import org.matsim.facilities.ActivityFacilities; import org.matsim.facilities.ActivityFacility; diff --git a/matsim/src/main/java/org/matsim/core/population/io/ParallelPopulationWriterHandlerV6.java b/matsim/src/main/java/org/matsim/core/population/io/ParallelPopulationWriterHandlerV6.java index c8755ed431d..975a926db40 100644 --- a/matsim/src/main/java/org/matsim/core/population/io/ParallelPopulationWriterHandlerV6.java +++ b/matsim/src/main/java/org/matsim/core/population/io/ParallelPopulationWriterHandlerV6.java @@ -29,7 +29,6 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.matsim.core.utils.misc.Time; import org.matsim.utils.objectattributes.AttributeConverter; @@ -41,6 +40,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -152,10 +152,10 @@ private void joinThreads() { } // pass on potential exceptions if (runnerException != null) { - throw new UncheckedIOException(runnerException); + throw new UncheckedIOException(new IOException(runnerException)); } if (writerException != null) { - throw new UncheckedIOException(writerException); + throw new UncheckedIOException(new IOException(writerException)); } } diff --git a/matsim/src/main/java/org/matsim/core/population/io/PopulationWriter.java b/matsim/src/main/java/org/matsim/core/population/io/PopulationWriter.java index 827eeed3ee3..71fbd029550 100644 --- a/matsim/src/main/java/org/matsim/core/population/io/PopulationWriter.java +++ b/matsim/src/main/java/org/matsim/core/population/io/PopulationWriter.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; @@ -36,7 +37,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.io.AbstractMatsimWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.matsim.utils.FeatureFlags; import org.matsim.utils.objectattributes.AttributeConverter; diff --git a/matsim/src/main/java/org/matsim/core/population/io/StreamingPopulationWriter.java b/matsim/src/main/java/org/matsim/core/population/io/StreamingPopulationWriter.java index 9f9d24ff438..09710e5a20d 100644 --- a/matsim/src/main/java/org/matsim/core/population/io/StreamingPopulationWriter.java +++ b/matsim/src/main/java/org/matsim/core/population/io/StreamingPopulationWriter.java @@ -31,7 +31,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.io.AbstractMatsimWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.matsim.utils.objectattributes.AttributeConverter; import org.matsim.utils.objectattributes.attributable.Attributes; @@ -39,6 +38,7 @@ import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.HashMap; import java.util.Map; diff --git a/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java b/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java index f203ab0d6c4..c0667068e67 100644 --- a/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java +++ b/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java @@ -36,7 +36,6 @@ import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.io.PopulationReader; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.facilities.MatsimFacilitiesReader; import org.matsim.households.HouseholdsReaderV10; import org.matsim.lanes.LanesReader; @@ -50,6 +49,7 @@ import org.matsim.vehicles.MatsimVehicleReader; +import java.io.UncheckedIOException; import java.net.URL; import java.util.*; diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java index c401aa351f9..33bb84d6982 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java @@ -31,7 +31,6 @@ import org.geotools.geometry.jts.ReferencedEnvelope; import org.matsim.core.api.internal.MatsimSomeReader; import org.matsim.core.gbl.Gbl; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.opengis.feature.Feature; import org.opengis.feature.simple.SimpleFeature; @@ -40,6 +39,7 @@ import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -213,7 +213,7 @@ public SimpleFeatureType getSchema() { public Collection getFeatureSet() { return featureSet; } - + public CoordinateReferenceSystem getCoordinateSystem(){ return this.crs; } diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java index f0257086934..2bb2650f814 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java @@ -26,12 +26,12 @@ import org.geotools.data.simple.SimpleFeatureStore; import org.geotools.feature.DefaultFeatureCollection; import org.matsim.core.api.internal.MatsimSomeWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; import java.net.URL; import java.util.Collection; /** @@ -43,10 +43,10 @@ public class ShapeFileWriter implements MatsimSomeWriter { private static final Logger log = LogManager.getLogger(ShapeFileWriter.class); - + public static void writeGeometries(final Collection features, final String filename) { if (features.isEmpty()) { - throw new UncheckedIOException("Cannot write empty collection"); + throw new UncheckedIOException(new IOException("Cannot write empty collection")); } log.info("Writing shapefile to " + filename); try { @@ -58,7 +58,7 @@ public static void writeGeometries(final Collection features, fin DefaultFeatureCollection coll = new DefaultFeatureCollection(); coll.addAll(features); - + SimpleFeatureType featureType = features.iterator().next().getFeatureType(); datastore.createSchema(featureType); SimpleFeatureStore featureSource = (SimpleFeatureStore) datastore.getFeatureSource(); diff --git a/matsim/src/main/java/org/matsim/core/utils/io/AbstractMatsimWriter.java b/matsim/src/main/java/org/matsim/core/utils/io/AbstractMatsimWriter.java index f8bd823b167..76508d882e8 100644 --- a/matsim/src/main/java/org/matsim/core/utils/io/AbstractMatsimWriter.java +++ b/matsim/src/main/java/org/matsim/core/utils/io/AbstractMatsimWriter.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.zip.GZIPOutputStream; @@ -75,7 +76,7 @@ protected final void openFile(final String filename) throws UncheckedIOException /** * Uses the specified OutputStream for writing. - * + * */ protected final void openOutputStream(OutputStream outputStream) { assertNotAlreadyOpen(); diff --git a/matsim/src/main/java/org/matsim/core/utils/io/IOUtils.java b/matsim/src/main/java/org/matsim/core/utils/io/IOUtils.java index e787add1b2b..e8667ea8c22 100644 --- a/matsim/src/main/java/org/matsim/core/utils/io/IOUtils.java +++ b/matsim/src/main/java/org/matsim/core/utils/io/IOUtils.java @@ -44,6 +44,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; +import java.io.UncheckedIOException; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; @@ -61,39 +62,39 @@ /** * This class provides helper methods for input/output in MATSim. - * + * * The whole I/O infrastructure is based on URLs, which allows more flexibility * than String-based paths or URLs. The structure follows three levels: Stream * level, writer/reader level, and convenience methods. - * + * *

Stream level

- * + * * The two main methods on the stream level are {@link #getInputStream(URL)} and * {@link #getOutputStream(URL, boolean)}. Their use is rather obvious, the * boolean argument of the output stream is whether it is an appending output * stream. Depending on the extension of the reference file of the URL, * compression will be detected automatically. See below for a list of active * compression algorithms. - * + * *

Reader/Writer level

- * + * * Use {@link #getBufferedWriter(URL, Charset, boolean)} and its simplified * versions to obtained a BufferedWriter object. Use * {@link #getBufferedReader(URL)} to obtain a BufferedReader. These functions * should be used preferredly, because they allow for future movements of files * to servers etc. - * + * *

Convenience methods

- * + * * Two convenience methods exist: {@link #getBufferedReader(String)} and * {@link #getBufferedReader(String)}, which take a String-based path as input. * They intentionally do not allow for much flexibility (e.g. choosing the * character set of the files). If this is needed, please use the reader/writer * level methods and construct the URL via the helper functions that are * documented below. - * + * *

URL handling

- * + * * To convert a file name to a URL, use {@link #getFileUrl(String)}. This is * mostly useful to determine the URL for an output file. If you are working * with input files, the best is to make use of @@ -101,13 +102,13 @@ * certain file in the file system and then in the class path (i.e. in the Java * resources). This makes it easy to write versatile code that can work with * local files and resources at the same time. - * + * *

Compression

- * + * * Compressed files are automatically assumed if certain file types are * encountered. Currently, the following patterns match certain compression * algorithms: - * + * *
    *
  • *.gz: GZIP compression
  • *
  • *.lz4: LZ4 compression
  • @@ -190,7 +191,7 @@ public static void setZstdCompressionLevel(int level) { /** * This function takes a path and tries to find the file in the file system or * in the resource path. The order of resolution is as follows: - * + * *
      *
    1. Find path in file system
    2. *
    3. Find path in file system with compression extension (e.g. *.gz)
    4. @@ -200,7 +201,7 @@ public static void setZstdCompressionLevel(int level) { * * In case the filename is a URL (i.e. starting with "file:" or "jar:file:"), * then no resolution is done but the provided filename returned as URL. - * + * * @throws UncheckedIOException */ public static URL resolveFileOrResource(String filename) throws UncheckedIOException { @@ -274,7 +275,7 @@ private static CompressionType getCompression(URL url) { * Opens an input stream for a given URL. If the URL has a compression * extension, the method will try to open the compressed file using the proper * decompression algorithm. - * + * * @throws UncheckedIOException */ public static InputStream getInputStream(URL url) throws UncheckedIOException { @@ -303,8 +304,10 @@ public static InputStream getInputStream(URL url) throws UncheckedIOException { } return new UnicodeInputStream(new BufferedInputStream(inputStream)); - } catch (IOException | CompressorException | GeneralSecurityException e) { + } catch (IOException e) { throw new UncheckedIOException(e); + } catch (CompressorException | GeneralSecurityException e) { + throw new UncheckedIOException(new IOException(e)); } } @@ -312,7 +315,7 @@ public static InputStream getInputStream(URL url) throws UncheckedIOException { * Creates a reader for an input URL. If the URL has a compression extension, * the method will try to open the compressed file using the proper * decompression algorithm. A given character set is used for the reader. - * + * * @throws UncheckedIOException */ public static BufferedReader getBufferedReader(URL url, Charset charset) throws UncheckedIOException { @@ -323,7 +326,7 @@ public static BufferedReader getBufferedReader(URL url, Charset charset) throws /** * See {@link #getBufferedReader(URL, Charset)}. UTF-8 is assumed as the * character set. - * + * * @throws UncheckedIOException */ public static BufferedReader getBufferedReader(URL url) throws UncheckedIOException { @@ -335,21 +338,21 @@ public static BufferedReader getBufferedReader(URL url) throws UncheckedIOExcept * extension, the method will try to open the compressed file using the proper * decompression algorithm. Note that compressed files cannot be appended and * that it is only possible to write to the file system (i.e. file:// protocol). - * + * * @throws UncheckedIOException */ @SuppressWarnings("resource") public static OutputStream getOutputStream(URL url, boolean append) throws UncheckedIOException { try { if (!url.getProtocol().equals("file")) { - throw new UncheckedIOException("Can only write to file:// protocol URLs"); + throw new UncheckedIOException(new IOException("Can only write to file:// protocol URLs")); } File file = new File(url.toURI()); CompressionType compression = getCompression(url); if ((compression != null && compression != CompressionType.ZSTD) && append && file.exists()) { - throw new UncheckedIOException("Cannot append to compressed files."); + throw new UncheckedIOException(new IOException("Cannot append to compressed files.")); } OutputStream outputStream = new FileOutputStream(file, append); @@ -372,8 +375,10 @@ public static OutputStream getOutputStream(URL url, boolean append) throws Unche } return new BufferedOutputStream(outputStream); - } catch (IOException | CompressorException | URISyntaxException e) { + } catch (IOException e) { throw new UncheckedIOException(e); + } catch (CompressorException | URISyntaxException e) { + throw new UncheckedIOException(new IOException(e)); } } @@ -382,8 +387,6 @@ public static OutputStream getOutputStream(URL url, boolean append) throws Unche * the method will try to open the compressed file using the proper * decompression algorithm. Note that compressed files cannot be appended and * that it is only possible to write to the file system (i.e. file:// protocol). - * - * @throws UncheckedIOException */ public static BufferedWriter getBufferedWriter(URL url, Charset charset, boolean append) throws UncheckedIOException { @@ -394,7 +397,7 @@ public static BufferedWriter getBufferedWriter(URL url, Charset charset, boolean /** * See {@link #getBufferedWriter(URL, Charset, boolean)}. UTF-8 is assumed as * the character set and non-appending mode is used. - * + * * @throws UncheckedIOException */ public static BufferedWriter getBufferedWriter(URL url) throws UncheckedIOException { @@ -404,7 +407,7 @@ public static BufferedWriter getBufferedWriter(URL url) throws UncheckedIOExcept /** * Wrapper function for {@link #getBufferedWriter(URL)} that creates a * PrintStream. - * + * * @throws UncheckedIOException */ public static PrintStream getPrintStream(URL url) throws UncheckedIOException { @@ -416,7 +419,7 @@ public static PrintStream getPrintStream(URL url) throws UncheckedIOException { * * @param fromStream The stream containing the data to be copied * @param toStream The stream the data should be written to - * + * * @throws UncheckedIOException */ public static void copyStream(final InputStream fromStream, final OutputStream toStream) @@ -438,7 +441,7 @@ public static void copyStream(final InputStream fromStream, final OutputStream t * should not be any accidents like following symbolic links. * * @param path The directory to be deleted - * + * * @throws UncheckedIOException */ public static void deleteDirectoryRecursively(Path path) throws UncheckedIOException { @@ -463,10 +466,10 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx /** * Compares two InputStreams. - * + * * Source: * http://stackoverflow.com/questions/4245863/fast-way-to-compare-inputstreams - * + * * @throws UncheckedIOException */ public static boolean isEqual(InputStream first, InputStream second) throws UncheckedIOException { @@ -491,9 +494,9 @@ public static boolean isEqual(InputStream first, InputStream second) throws Unch /** * Returns a URL for a (not necessarily existing) file path. - * + * * @param filename File name. - * + * * @throws UncheckedIOException */ public static URL getFileUrl(String filename) throws UncheckedIOException { @@ -506,10 +509,10 @@ public static URL getFileUrl(String filename) throws UncheckedIOException { /** * Given a base URL, returns the extended URL. - * + * * @param context Base URL, e.g. from the Config object. * @param extension Extended path specification. - * + * * @throws UncheckedIOException */ public static URL extendUrl(URL context, String extension) throws UncheckedIOException { @@ -527,7 +530,7 @@ public static URL extendUrl(URL context, String extension) throws UncheckedIOExc /** * Convenience wrapper, see {@link #getBufferedReader(URL, Charset)}. - * + * * Note, that in general you should rather use URLs and the respective * {@link #getBufferedReader(URL)} function. You can obtain URLs for your file * paths either using {@link #resolveFileOrResource(String)} for an existing diff --git a/matsim/src/main/java/org/matsim/core/utils/io/MatsimFileTypeGuesser.java b/matsim/src/main/java/org/matsim/core/utils/io/MatsimFileTypeGuesser.java index c98380c2b0e..f8869bbb6f6 100644 --- a/matsim/src/main/java/org/matsim/core/utils/io/MatsimFileTypeGuesser.java +++ b/matsim/src/main/java/org/matsim/core/utils/io/MatsimFileTypeGuesser.java @@ -21,6 +21,7 @@ package org.matsim.core.utils.io; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Locale; import javax.xml.parsers.ParserConfigurationException; @@ -139,9 +140,9 @@ private void guessFileTypeXml(final String fileName) throws UncheckedIOException } catch (IOException e) { throw new UncheckedIOException(e); } catch (SAXException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException(e)); } catch (ParserConfigurationException e) { - throw new UncheckedIOException(e); + throw new UncheckedIOException(new IOException (e)); } catch (XMLTypeDetectionException e) { this.xmlPublicId = e.publicId; this.xmlSystemId = e.systemId; diff --git a/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlParser.java b/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlParser.java index 23f3753e48d..b245805efbc 100644 --- a/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlParser.java +++ b/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlParser.java @@ -35,6 +35,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.net.URL; import java.net.URLConnection; import java.util.Stack; @@ -224,8 +225,10 @@ public final void parse(final InputSource input) throws UncheckedIOException { parser.parse(input, this); } } - } catch (SAXException | ParserConfigurationException | IOException e) { + } catch (IOException e) { throw new UncheckedIOException(e); + } catch (SAXException | ParserConfigurationException e) { + throw new UncheckedIOException(new IOException(e)); } } diff --git a/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlWriter.java b/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlWriter.java index c5bba306501..0b115e866ee 100644 --- a/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlWriter.java +++ b/matsim/src/main/java/org/matsim/core/utils/io/MatsimXmlWriter.java @@ -24,6 +24,7 @@ import org.matsim.core.utils.misc.Time; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.List; import static org.matsim.core.utils.io.XmlUtils.encodeAttributeValue; diff --git a/matsim/src/main/java/org/matsim/core/utils/io/OsmNetworkReader.java b/matsim/src/main/java/org/matsim/core/utils/io/OsmNetworkReader.java index f967adccf76..f8e3f27c3f0 100644 --- a/matsim/src/main/java/org/matsim/core/utils/io/OsmNetworkReader.java +++ b/matsim/src/main/java/org/matsim/core/utils/io/OsmNetworkReader.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/matsim/src/main/java/org/matsim/core/utils/io/UncheckedIOException.java b/matsim/src/main/java/org/matsim/core/utils/io/UncheckedIOException.java deleted file mode 100644 index f3cca1e6e74..00000000000 --- a/matsim/src/main/java/org/matsim/core/utils/io/UncheckedIOException.java +++ /dev/null @@ -1,43 +0,0 @@ - -/* *********************************************************************** * - * project: org.matsim.* - * UncheckedIOException.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2019 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * 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 * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - - package org.matsim.core.utils.io; - -/** - * A simple (unchecked) exception class to typically wrap IOExceptions. - * - * @author mrieser - */ -public class UncheckedIOException extends RuntimeException { - private static final long serialVersionUID = 6186620063027481864L; - - public UncheckedIOException(final String message, final Throwable cause) { - super(message, cause); - } - - public UncheckedIOException(final Throwable cause) { - super(cause); - } - - public UncheckedIOException(final String message) { - super(message); - } -} diff --git a/matsim/src/main/java/org/matsim/households/HouseholdsWriterV10.java b/matsim/src/main/java/org/matsim/households/HouseholdsWriterV10.java index 9416e7f2a80..b7c18924a10 100644 --- a/matsim/src/main/java/org/matsim/households/HouseholdsWriterV10.java +++ b/matsim/src/main/java/org/matsim/households/HouseholdsWriterV10.java @@ -26,15 +26,14 @@ import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.Counter; import org.matsim.households.algorithms.HouseholdAlgorithm; import org.matsim.utils.objectattributes.AttributeConverter; -import org.matsim.utils.objectattributes.attributable.Attributes; import org.matsim.utils.objectattributes.attributable.AttributesXmlWriterDelegate; import org.matsim.vehicles.Vehicle; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,7 +45,7 @@ */ public class HouseholdsWriterV10 extends MatsimXmlWriter implements HouseholdAlgorithm{ private static final Logger log = LogManager.getLogger( HouseholdsWriterV10.class ) ; - + private List> atts = new ArrayList<>(); private Households households; private final Map,AttributeConverter> attributeConverters = new HashMap<>(); @@ -75,14 +74,14 @@ public void writeFile(String filename) throws UncheckedIOException { this.writeXmlHead(); this.writeHeader(); } - + /*package*/ void writeEndAndCloseFile(){ - + this.writeEndTag(HouseholdsSchemaV10Names.HOUSEHOLDS); this.close(); } - - + + private void writeHeader(){ atts.clear(); atts.add(createTuple(XMLNS, MatsimXmlWriter.MATSIM_NAMESPACE)); @@ -90,7 +89,7 @@ private void writeHeader(){ atts.add(createTuple("xsi:schemaLocation", MATSIM_NAMESPACE + " " + DEFAULT_DTD_LOCATION + "households_v1.0.xsd")); this.writeStartTag(HouseholdsSchemaV10Names.HOUSEHOLDS, atts); } - + private void writeHouseholds(Households basicHouseholds) throws UncheckedIOException { Counter counter = new Counter("[HouseholdsWriter] wrote household # "); for (Household h : basicHouseholds.getHouseholds().values()) { diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV1.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV1.java index 0bd60a2886b..233718e146e 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV1.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV1.java @@ -20,6 +20,7 @@ package org.matsim.pt.transitSchedule; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -33,7 +34,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV2.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV2.java index 581da9077ef..8e2c901d79d 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV2.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleWriterV2.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,7 +35,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.MinimalTransferTimes; import org.matsim.pt.transitSchedule.api.TransitLine; diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleReader.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleReader.java index 1e5b4dc34a3..ce785546de4 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleReader.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleReader.java @@ -26,13 +26,13 @@ import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.io.MatsimXmlParser; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.pt.transitSchedule.TransitScheduleReaderV1; import org.matsim.pt.transitSchedule.TransitScheduleReaderV2; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.net.URL; import java.util.Stack; diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleWriter.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleWriter.java index 83a97dde3b8..46e2049e68c 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleWriter.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/api/TransitScheduleWriter.java @@ -26,10 +26,11 @@ import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.pt.transitSchedule.TransitScheduleWriterV1; import org.matsim.pt.transitSchedule.TransitScheduleWriterV2; +import java.io.UncheckedIOException; + /** * Writes {@link TransitSchedule}s to file in one of the * supported file formats. @@ -38,7 +39,7 @@ */ public class TransitScheduleWriter implements MatsimSomeWriter { private static final Logger log = LogManager.getLogger( TransitScheduleWriter.class ) ; - + private final TransitSchedule schedule; private final CoordinateTransformation transformation; diff --git a/matsim/src/main/java/org/matsim/utils/objectattributes/ObjectAttributesXmlWriter.java b/matsim/src/main/java/org/matsim/utils/objectattributes/ObjectAttributesXmlWriter.java index 4050cf6429c..8955547cdef 100644 --- a/matsim/src/main/java/org/matsim/utils/objectattributes/ObjectAttributesXmlWriter.java +++ b/matsim/src/main/java/org/matsim/utils/objectattributes/ObjectAttributesXmlWriter.java @@ -19,12 +19,10 @@ package org.matsim.utils.objectattributes; -import java.util.HashMap; -import java.util.HashSet; +import java.io.UncheckedIOException; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import com.google.inject.Inject; @@ -32,12 +30,6 @@ import org.apache.logging.log4j.Logger; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; -import org.matsim.utils.objectattributes.attributeconverters.BooleanConverter; -import org.matsim.utils.objectattributes.attributeconverters.DoubleConverter; -import org.matsim.utils.objectattributes.attributeconverters.IntegerConverter; -import org.matsim.utils.objectattributes.attributeconverters.LongConverter; -import org.matsim.utils.objectattributes.attributeconverters.StringConverter; /** * Writes object attributes to a file. diff --git a/matsim/src/main/java/org/matsim/utils/objectattributes/attributable/AttributesXmlWriterDelegate.java b/matsim/src/main/java/org/matsim/utils/objectattributes/attributable/AttributesXmlWriterDelegate.java index 0423962e88d..acffcd10e40 100644 --- a/matsim/src/main/java/org/matsim/utils/objectattributes/attributable/AttributesXmlWriterDelegate.java +++ b/matsim/src/main/java/org/matsim/utils/objectattributes/attributable/AttributesXmlWriterDelegate.java @@ -21,13 +21,13 @@ package org.matsim.utils.objectattributes.attributable; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.io.XmlUtils; import org.matsim.utils.objectattributes.AttributeConverter; import org.matsim.utils.objectattributes.ObjectAttributesConverter; import java.io.BufferedWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.Map; /** diff --git a/matsim/src/main/java/org/matsim/vehicles/MatsimVehicleWriter.java b/matsim/src/main/java/org/matsim/vehicles/MatsimVehicleWriter.java index e8883a22bee..dc757046ba0 100644 --- a/matsim/src/main/java/org/matsim/vehicles/MatsimVehicleWriter.java +++ b/matsim/src/main/java/org/matsim/vehicles/MatsimVehicleWriter.java @@ -20,17 +20,11 @@ package org.matsim.vehicles; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.api.core.v01.Id; import org.matsim.core.gbl.Gbl; -import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; /** * This is the new default Writer for the vehicles file. @@ -38,7 +32,7 @@ * @author kturner */ public final class MatsimVehicleWriter extends MatsimXmlWriter { - + private static final Logger log = LogManager.getLogger(MatsimVehicleWriter.class); private VehicleWriterV2 delegate; diff --git a/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV1.java b/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV1.java index b69aedd4816..a5a443df95d 100644 --- a/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV1.java +++ b/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV1.java @@ -22,6 +22,7 @@ import static java.util.Comparator.comparing; import static java.util.stream.Collectors.toList; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -32,7 +33,6 @@ import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; /** * @author dgrether @@ -55,7 +55,7 @@ public VehicleWriterV1(Vehicles vehicles) { this.vehicleTypes = vehicles.getVehicleTypes(); this.vehicles = vehicles.getVehicles(); } - + public void writeFile(String filename) throws UncheckedIOException { log.info( Gbl.aboutToWrite( "vehicles", filename) ) ; this.openFile(filename); @@ -179,5 +179,5 @@ private void writeFreightCapacity(double fc) throws UncheckedIOException { this.writeStartTag(VehicleSchemaV1Names.VOLUME, atts, true); this.writeEndTag(VehicleSchemaV1Names.FREIGHTCAPACITY); } - + } diff --git a/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV2.java b/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV2.java index 26bbdc8126d..4d5efec3771 100644 --- a/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV2.java +++ b/matsim/src/main/java/org/matsim/vehicles/VehicleWriterV2.java @@ -23,6 +23,7 @@ import static java.util.stream.Collectors.toList; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -35,7 +36,6 @@ import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.io.MatsimXmlWriter; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.utils.objectattributes.AttributeConverter; import org.matsim.utils.objectattributes.attributable.AttributesXmlWriterDelegate; diff --git a/matsim/src/main/java/org/matsim/visum/VisumNetworkReader.java b/matsim/src/main/java/org/matsim/visum/VisumNetworkReader.java index a2daff64e36..866ff295215 100644 --- a/matsim/src/main/java/org/matsim/visum/VisumNetworkReader.java +++ b/matsim/src/main/java/org/matsim/visum/VisumNetworkReader.java @@ -22,6 +22,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.charset.Charset; import org.apache.logging.log4j.LogManager; @@ -31,7 +32,6 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.StringUtils; import org.matsim.visum.VisumNetwork.StopPoint; import org.matsim.visum.VisumNetwork.TransitLine; @@ -304,7 +304,7 @@ private void readStopPoints(final String tableAttributes, final BufferedReader r final String[] parts = StringUtils.explode(line, ';'); VisumNetwork.StopPoint stopPt = new VisumNetwork.StopPoint(Id.create(parts[idxNo], VisumNetwork.StopPoint.class), Id.create(parts[idxStopAreaNo], VisumNetwork.StopArea.class), - parts[idxName], + parts[idxName], Id.create(parts[idxRLNo], Link.class), Id.create(parts[idxNode], Node.class)); this.network.addStopPoint(stopPt); // proceed to next line @@ -413,7 +413,7 @@ private void readTimeProfileItems(final String tableAttributes, final BufferedRe while (line != null && line.length() > 0) { final String[] parts = StringUtils.explode(line, ';'); - VisumNetwork.TimeProfileItem tpi1 = new VisumNetwork.TimeProfileItem(parts[idxLineName], parts[idxLineRouteName], + VisumNetwork.TimeProfileItem tpi1 = new VisumNetwork.TimeProfileItem(parts[idxLineName], parts[idxLineRouteName], parts[idxTPName], parts[idxDCode], parts[idxIndex], parts[idxArr], parts[idxDep], Id.create(parts[idxLRIIndex], VisumNetwork.TimeProfileItem.class)); this.network.addTimeProfileItem(tpi1); diff --git a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java index 66facce68ab..1654d7d9e47 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java @@ -23,7 +23,6 @@ import org.junit.Test; import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.testcases.MatsimTestUtils; import java.io.BufferedWriter; diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java index 2f1b5b76dc7..adcd07b20e3 100644 --- a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java +++ b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java @@ -29,7 +29,6 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.CRCChecksum; import org.matsim.utils.eventsfilecomparison.EventsFileComparator;