/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inport; import java.util.HashMap; import java.util.Map; /** * * @author topazh_ag */ public abstract class OperationTemplate { private int id; private Berth startLocation; Map timeWindows; /** * Get the value of id * * @return the value of id */ public int getId() { return id; } /** * Set the value of id * * @param id new value of id */ public void setId(int id) { this.id = id; } public Berth getStartLocation() { return startLocation; } public void setStartLocation(Berth startLocation) { this.startLocation = startLocation; } public Map getTimeWindows() { return timeWindows; } public void setBanWindows(Map timeWindows) { this.timeWindows = timeWindows; } protected String twtoString() { String res = ""; boolean first = true; for(Double s : timeWindows.keySet()) { if (!first) res += "," + s + ":" + timeWindows.get(s); else res += s + ":" + timeWindows.get(s); first = false; } return "[" + res +"]"; } public OperationTemplate(int id, Berth startLocation) { this.id = id; this.startLocation = startLocation; this.timeWindows = new HashMap<>(); } public OperationTemplate() { this.timeWindows = new HashMap<>(); } public void setTimeWindow(String s) { this.timeWindows = new HashMap<>(); String[] rs = s.replace("[", "").replace("]", "").split(","); for (String crs : rs) if (crs.length()>0) { String[] kv = crs.split(":"); Double key1 = Double.parseDouble(kv[0]); Double value1 = Double.parseDouble(kv[1]); timeWindows.put(key1, value1); } } }