I am deserializing data using Simple XML in Java, but i get an exception telling me:
protokolsimulering.model.Terminal.<init>()
This is my serializing code:
public void saveSimulationState(String simulationFile) {
try{
Strategy strategy = new CycleStrategy("id", "ref");
Serializer serializer = new Persister(strategy);
File result = new File(simulationFile);
serializer.write(this.sm, result);
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
public void loadSimulationState(String simulationFile) {
try {
Strategy strategy = new CycleStrategy("id", "ref");
Serializer serializer = new Persister(strategy);
File source = new File(simulationFile);
this.sm = serializer.read(Simulation.class, source);
} catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
}
}
The code for Terminal.java is:
package protokolsimulering.model;
import java.util.ArrayList;
import protokolsimulering.model.DataPacket.*;
public class Terminal extends Sensor {
public Terminal(int x, int y, double r) {
super(x,y,r);
learnPosition();
}
@Override
public void init() {
this.broadcast(PacketFactory.newRutePacket(this,0));
}
@Override
public void step() {
ArrayList<AbstractPacket> packetsThisStep = (ArrayList<AbstractPacket>) this.getPackages();
for(AbstractPacket p : packetsThisStep) {
if(p instanceof HalloPacket) {
// Rutningsprotokol
send(p.getSender(),PacketFactory.newRutePacket(this,0));
// Lokaliseringsprotokol
send(p.getSender(), PacketFactory.newHerPacket(this, this.getKnownPosition()));
}
}
}
}
The entire source code can be found at:
http://code.google.com/p/sensor-protocol-simulation/source/browse/#svn/trunk/src/protokolsimulering