@Override public Attributes getAttributes() { // attributes should be made unmodifiable return delegate.getAttributes(); } }
private void startLeg(final Leg leg, final BufferedWriter out) throws IOException { out.write("\t\t\t<leg mode=\""); out.write(leg.getMode()); out.write("\""); if (!Time.isUndefinedTime(leg.getDepartureTime())) { out.write(" dep_time=\""); out.write(Time.writeTime(leg.getDepartureTime())); out.write("\""); } if (!Time.isUndefinedTime(leg.getTravelTime())) { out.write(" trav_time=\""); out.write(Time.writeTime(leg.getTravelTime())); out.write("\""); } // if (leg instanceof LegImpl) { // LegImpl l = (LegImpl)leg; // if (l.getDepartureTime() + l.getTravelTime() != Time.UNDEFINED_TIME) { // out.write(" arr_time=\""); // out.write(Time.writeTime(l.getDepartureTime() + l.getTravelTime())); // out.write("\""); // } // } // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 out.write(">\n"); this.attributesWriter.writeAttributes( "\t\t\t\t" , out , leg.getAttributes() ); }
break; case LEG: currAttributes = currleg.getAttributes(); break; default:
@Test public void testLegAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); population.addPerson( person ); final Plan plan = population.getFactory().createPlan(); person.addPlan( plan ); final Leg leg = population.getFactory().createLeg( "SUV" ); plan.addActivity( population.getFactory().createActivityFromLinkId( "speech" , Id.createLinkId( 1 ))); plan.addLeg( leg ); plan.addActivity( population.getFactory().createActivityFromLinkId( "tweet" , Id.createLinkId( 2 ))); leg.getAttributes().putAttribute( "mpg" , 0.000001d ); final String file = utils.getOutputDirectory()+"/population.xml"; new PopulationWriter( population ).writeV6( file ); final Scenario readScenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); new PopulationReader( readScenario ).readFile( file ); final Person readPerson = readScenario.getPopulation().getPersons().get( Id.createPersonId( "Donald Trump" ) ); final Leg readLeg = (Leg) readPerson.getSelectedPlan().getPlanElements().get( 1 ); Assert.assertEquals( "Unexpected Double attribute in " + readLeg.getAttributes(), leg.getAttributes().getAttribute( "mpg" ) , readLeg.getAttributes().getAttribute( "mpg" ) ); }
plan.addActivity( population.getFactory().createActivityFromLinkId( "tweet" , Id.createLinkId( 2 ))); leg.getAttributes().putAttribute( "mpg" , 0.000001d ); leg.getAttributes().getAttribute( "mpg" ), legCopy.getAttributes().getAttribute( "mpg" ) );
plan.addLeg( leg ); leg.getAttributes().putAttribute( "legAttribute" , new StupidClass() );