private void writeTypes(BufferedWriter writer)throws IOException { writer.write("\t<vehicleTypes>\n"); for(CarrierVehicleType type : vehicleTypes.getVehicleTypes().values()){ writer.write("\t\t<vehicleType id=\"" + type.getId() + "\">\n"); writer.write("\t\t\t<description>" + type.getDescription() + "</description>\n"); EngineInformation engineInformation = type.getEngineInformation(); if(engineInformation != null) writer.write("\t\t\t<engineInformation fuelType=\"" + engineInformation.getFuelType().toString() + "\" gasConsumption=\"" + engineInformation.getGasConsumption() + "\"/>\n"); writer.write("\t\t\t<capacity>" + type.getCarrierVehicleCapacity() + "</capacity>\n"); VehicleCostInformation vehicleCostInformation = type.getVehicleCostInformation(); if(vehicleCostInformation == null) throw new IllegalStateException("vehicleCostInformation is missing."); writer.write("\t\t\t<costInformation fix=\"" + vehicleCostInformation.fix + "\" perMeter=\"" + vehicleCostInformation.perDistanceUnit + "\" perSecond=\"" + vehicleCostInformation.perTimeUnit + "\"/>\n"); writer.write("\t\t</vehicleType>\n"); } writer.write("\t</vehicleTypes>\n\n"); }
private void writeEngineInformation(EngineInformation ei) throws UncheckedIOException { this.writeStartTag(VehicleSchemaV1Names.ENGINEINFORMATION, null); this.writeStartTag(VehicleSchemaV1Names.FUELTYPE, null); this.writeContent(ei.getFuelType().toString(), false); this.writeEndTag(VehicleSchemaV1Names.FUELTYPE); atts.clear(); atts.add(this.createTuple(VehicleSchemaV1Names.LITERPERMETER, Double.toString(ei.getGasConsumption()))); this.writeStartTag(VehicleSchemaV1Names.GASCONSUMPTION, atts, true); this.writeEndTag(VehicleSchemaV1Names.ENGINEINFORMATION); }
assertEquals(23.23, vehType.getCapacity().getFreightCapacity().getVolume(), EPSILON); assertNotNull(vehType.getEngineInformation()); assertEquals(EngineInformation.FuelType.diesel, vehType.getEngineInformation().getFuelType()); assertEquals(0.23, vehType.getEngineInformation().getGasConsumption(), EPSILON); assertEquals(23.23, vehType.getAccessTime(), EPSILON);