public Hashtable<String, Integer> getAllRequirements() { if (associatedRequirements == null) { associatedRequirements = new Hashtable<String, Integer>(); Vector<AbstractElement> abstractElements = new Vector<AbstractElement>(); abstractElements.addAll(getAllVertices()); abstractElements.addAll(getAllEdges()); for (AbstractElement abstractElement : abstractElements) { String reqtags = abstractElement.getReqTagKey(); if (!reqtags.isEmpty()) { String[] tags = reqtags.split(","); for (String tag : tags) { associatedRequirements.put(tag, 0); } } } } return associatedRequirements; }
/** * This method finds and returns all the strings found in the graph used to give a variable its * value. Each found string will be splitted with comma and the results will be treated as unique * values. For example In graph: reqtag1 = "REQ1" + ",REQ2," reqtag1 = reqtag1 + "REQ3" reqtag2 = * "REQ3,REQ4" reqtag3 = "RE" + "Q5," reqtag4 = getValueFromExternalFunction("REQ6"); * * @return Hashmap with the variable name as key, and a string containing 1 to many colon * separated values, as the value For example In HashMap ({key,value} { * reqtag1,"REQ1:REQ2:REQ3" reqtag2,"REQ3:REQ4" reqtag3,"RE:Q5" reqtag4,"REQ6" */ public Hashtable<String, String> getAllVariableValues() { Hashtable<String, String> varVal = new Hashtable<String, String>(); Vector<AbstractElement> abstractElements = new Vector<AbstractElement>(); abstractElements.addAll(getAllVertices()); abstractElements.addAll(getAllEdges()); for (AbstractElement abstractElement : abstractElements) { String actionkey = abstractElement.getActionsKey(); if (!actionkey.isEmpty()) { String[] tags = actionkey.split(";"); for (int j = 0; j < tags.length; j++) { if (!tags[j].contains("=")) continue; String[] variableAndValue = tags[j].split("="); variableAndValue[0] = variableAndValue[0].replaceAll("[ ]*", ""); while (variableAndValue[1].contains("\"")) { String[] splittedValue = variableAndValue[1].split("\"", 3); String[] reqs = splittedValue[1].split(","); for (String s : reqs) { if (s.length() == 0) continue; // fetching previously stored values for this variable String tmpVal = varVal.get(variableAndValue[0]); String newValue; if (tmpVal == null) { newValue = s; } else newValue = tmpVal + ":" + s; varVal.put(variableAndValue[0], newValue); } variableAndValue[1] = splittedValue[2]; } } } } return varVal; }
public void setAsUnvisited(AbstractElement e) { Integer visits = e.getVisitedKey(); e.setVisitedKey(e.getVisitedKey() - 1); if (e instanceof Edge) { if (e.getVisitedKey() < 1) { numOfCoveredEdges--; } } else if (e instanceof Vertex) { if (e.getVisitedKey() < 1) { numOfCoveredVertices--; } } if (visits <= 0) logger.error(e + ", has a negative number in VISITED_KEY"); if (!e.getReqTagKey().isEmpty()) { Hashtable<String, Integer> reqs = getAllRequirements(); String[] tags = e.getReqTagKey().split(","); for (String tag : tags) { reqs.put(tag, reqs.get(tag) - 1); } } }
public void setAsVisited(AbstractElement e) { if (e instanceof Edge) { if (e.getVisitedKey() < 1) { numOfCoveredEdges++; } } else if (e instanceof Vertex) { if (e.getVisitedKey() < 1) { numOfCoveredVertices++; } } e.setVisitedKey(e.getVisitedKey() + 1); if (!e.getReqTagKey().isEmpty()) { Hashtable<String, Integer> reqs = getAllRequirements(); String[] tags = e.getReqTagKey().split(","); for (String tag : tags) { reqs.put(tag, reqs.get(tag) + 1); } } }