protected boolean hasTokenOnIntermediatePlace() { for (Place place : net.getPlaces()) { if (!place.isFinalPlace() && this.getNumTokens(place) > 0) { return true; } } return false; }
protected boolean hasOneTokenOnFinalPlace() { for (Place place : net.getPlaces()) { if (place.isFinalPlace() && this.getNumTokens(place) == 1) { return true; } } return false; }
public JSONObject toJson() throws JSONException { JSONObject marking = new JSONObject(); for (Place place : net.getPlaces()) { marking.put(place.getResourceId(), this.getNumTokens(place)); } return marking; }
public String toString() { if (markingStr == null) { StringBuilder str = new StringBuilder(); str.append("{"); boolean firstEntry = true; for (Place p : net.getPlaces()) { int numt = getNumTokens(p); if (numt > 0) { if (firstEntry) firstEntry = false; else str.append(","); str.append(p.getId()); if (numt > 1) str.append(":").append(numt); } } str.append("}"); markingStr = str.toString(); } return markingStr; }