@Override public Attributes getAttributes() { // TODO yyyy should be made unmodifiable. kai, jan'17 return delegate.getAttributes() ; } }
private void startPlan(final Plan plan, final BufferedWriter out) throws IOException { out.write("\t\t<plan"); if (plan.getScore() != null) { out.write(" score=\""); out.write(plan.getScore().toString()); out.write("\""); } if (PersonUtils.isSelected(plan)) out.write(" selected=\"yes\""); else out.write(" selected=\"no\""); if ((plan.getType() != null)) { out.write(" type=\""); out.write(plan.getType()); out.write("\""); } out.write(">\n"); this.attributesWriter.writeAttributes( "\t\t\t\t" , out , plan.getAttributes() ); }
break; case PLAN: currAttributes = currplan.getAttributes(); break; case ACT:
@Test public void testPlanAttributesIO() { 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 ))); plan.getAttributes().putAttribute( "beauty" , 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 Plan readPlan = readPerson.getSelectedPlan() ; Assert.assertEquals( plan.getAttributes().getAttribute( "beauty" ) , readPlan.getAttributes().getAttribute( "beauty" ) ); }