1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
public void build(String fileName) {
SAXBuilder sxb = new SAXBuilder();
try {
document = sxb.build(new File(fileName));
//document.addContent(new ProcessingInstruction("encoding","ISO-8859-1"));
root = document.getRootElement();
// load hashtable
loadCorrespondencesTable();
displayAll();
} catch (JDOMException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
}
/**
*
*/
private void loadCorrespondencesTable() {
List listMsg = root.getChildren("message");
List nodesList = null;
Iterator i = listMsg.iterator();
String currentMsg;
int j = 0;
Element ttcnNode, currentNode;
BehaviourLine bLine = null;
while (i.hasNext()) {
currentNode = (Element) i.next();
currentMsg = currentNode.getChild("settings").getAttributeValue(
"description");
if (!currentMsg.replaceAll("\\s", "").equals("")) {
System.out.println("current message : " + currentMsg);
ttcnNode = (Element) currentNode.getChild("ttcn");
bLine = new BehaviourLine(j++);
bLine.setCref(ttcnNode.getChildText("cref"));
bLine.setHeader(ttcnNode.getChildText("header"));
bLine.setLabelId(ttcnNode.getChildText("label-id"));
bLine.setLine(ttcnNode.getChildText("line"));
bLine.setVerdict(ttcnNode.getChildText("verdict-id"));
hCorrespondancesSpyTTCN.put(currentMsg, bLine);
}
}
}
/**
*
*/
private void displayAll() {
Enumeration e = hCorrespondancesSpyTTCN.keys();
while (e.hasMoreElements()) {
System.out.println(hCorrespondancesSpyTTCN.get(
e.nextElement().toString()).toString());
}
} |
Partager