All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.uni.freiburg.iig.telematik.sepia.serialize.PNSerializer Maven / Gradle / Ivy

package de.uni.freiburg.iig.telematik.sepia.serialize;

import java.io.IOException;

import de.invation.code.toval.validate.ParameterException;
import de.invation.code.toval.validate.ParameterException.ErrorCode;
import de.invation.code.toval.validate.Validate;
import de.uni.freiburg.iig.telematik.sepia.graphic.AbstractGraphicalPN;
import de.uni.freiburg.iig.telematik.sepia.graphic.netgraphics.AbstractPNGraphics;
import de.uni.freiburg.iig.telematik.sepia.petrinet.NetType;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractFlowRelation;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractMarking;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPetriNet;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPlace;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractTransition;

public abstract class PNSerializer

, T extends AbstractTransition, F extends AbstractFlowRelation, M extends AbstractMarking, S extends Object, N extends AbstractPetriNet, G extends AbstractPNGraphics> { protected N petriNet = null; protected G graphics = null; protected SerializationSupport support = null; public PNSerializer(N petriNet) { validatePetriNet(petriNet); this.petriNet = petriNet; } public PNSerializer(AbstractGraphicalPN petriNet) { Validate.notNull(petriNet); validatePetriNet(petriNet.getPetriNet()); this.petriNet = petriNet.getPetriNet(); this.graphics = petriNet.getPetriNetGraphics(); } private void validatePetriNet(N petriNet) { Validate.notNull(petriNet); Class requiredClassType = NetType.getClassType(acceptedNetType()); if(!(requiredClassType.isAssignableFrom(petriNet.getClass()))){ throw new ParameterException(ErrorCode.INCOMPATIBILITY, "This serializer requires nets of type \""+requiredClassType+"\"\n The given net is of type \""+petriNet.getClass()+"\""); } } public N getPetriNet(){ return petriNet; } public G getGraphics(){ return graphics; } public SerializationSupport getSupport(){ return support; } protected boolean hasGraphics(){ return graphics != null; } public abstract NetType acceptedNetType(); public abstract String serialize() throws SerializationException; public abstract void serialize(String path, String fileName) throws SerializationException, IOException; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy