private void load_snap_from_xml(Element snap, StructureCollection structs, LinkedList tempList) throws VisualizerLoadException { Iterator iterator = snap.getChildren().iterator(); if (!iterator.hasNext()) throw new VisualizerLoadException("Ran out of elements"); structs.loadTitle((Element) (iterator.next()), tempList, this); structs.calcDimsAndStartPts(tempList, this); if (!iterator.hasNext()) return; Element child = (Element) iterator.next(); if (child.getName().compareTo("doc_url") == 0) { // load the doc_url add_a_documentation_URL(child.getText().trim()); if (!iterator.hasNext()) return; child = (Element) iterator.next(); } if (child.getName().compareTo("pseudocode_url") == 0) { // load the psuedocode_url add_a_pseudocode_URL(child.getText().trim()); if (!iterator.hasNext()) return; child = (Element) iterator.next(); } if (child.getName().compareTo("audio_text") == 0) { // load the psuedocode_url add_audio_text(child.getText().trim()); if (!iterator.hasNext()) return; child = (Element) iterator.next(); } // create & load the individual structures, hooking them into the StructureCollection. // linespernode : calculate it at end of loadStructure call while (child.getName().compareTo("question_ref") != 0) { StructureType child_struct = assignStructureType(child); child_struct.loadStructure(child, tempList, this); structs.addChild(child_struct); if (!iterator.hasNext()) return; child = (Element) iterator.next(); } if (child.getName().compareTo("question_ref") == 0) { // set up question ref add_a_question_xml(child.getAttributeValue("ref")); } else // should never happen throw new VisualizerLoadException( "Expected question_ref element, but found " + child.getName()); if (iterator.hasNext()) { child = (Element) iterator.next(); throw new VisualizerLoadException( "Found " + child.getName() + " when expecting end of snap."); } } // load_snap_from_xml
public int createericlist(Element snap) { int numsnaps = 0; StructureCollection structs = new StructureCollection(); LinkedList tempList = new LinkedList(); try { load_snap_from_xml(snap, structs, tempList); structs.calcDimsAndStartPts(tempList, this); structs.drawTitle(tempList, this); structs.drawStructure(tempList, this); } catch (VisualizerLoadException e) { System.out.println(e.toString()); } list_of_snapshots.append(tempList); Snaps++; return numsnaps; // this.. isnt used, and isnt what it says it is. } // createericlist(element)