String sPaddedID;
Node oBlksNode = null;
NodeList oNodeList = null;
int iNodeListLen = 0;
Vector<Block> oLinkVctr = null;
SortedMap oSortedMap = new TreeMap();
if (DebugFile.trace) {
if (null==oNode.getFirstChild())
DebugFile.writeln("Node.getFirstChild() returned null");
}
for (oBlksNode=oNode.getFirstChild(); oBlksNode!=null; oBlksNode=oBlksNode.getNextSibling())
if (Node.ELEMENT_NODE==oBlksNode.getNodeType())
if (oBlksNode.getNodeName().equals("blocks")) break;
if (DebugFile.trace)
if (null==oBlksNode)
DebugFile.writeln("ERROR: blocks node not found");
if (null==oBlksNode)
throw new DOMException(DOMException.NOT_FOUND_ERR, "<blocks> node not found");
oNodeList = ((Element) oBlksNode).getElementsByTagName("block");
iNodeListLen = oNodeList.getLength();
if (DebugFile.trace)
DebugFile.writeln(String.valueOf(iNodeListLen) + " blocks found.");
oLinkVctr = new Vector<Block>(iNodeListLen);
for (int i=0; i<iNodeListLen; i++) {
if (DebugFile.trace) {
if (null==oNodeList.item(i).getAttributes().getNamedItem("id"))
DebugFile.writeln("ERROR: Block " + String.valueOf(i) + " does not have the required id attribute.");
else
if (null==oNodeList.item(i).getAttributes().getNamedItem("id").getNodeValue())
DebugFile.writeln("ERROR: Block " + String.valueOf(i) + " id attribute is null.");
else if (oNodeList.item(i).getAttributes().getNamedItem("id").getNodeValue().length()==0)
DebugFile.writeln("ERROR: Block " + String.valueOf(i) + " id attribute is empty.");
}
sPaddedID = "-" + Gadgets.leftPad(oNodeList.item(i).getAttributes().getNamedItem("id").getNodeValue(), '0', 3);
if (DebugFile.trace)
DebugFile.writeln("padded id = " + sPaddedID);
if (DebugFile.trace) {
if (((Element)oNodeList.item(i)).getElementsByTagName("metablock").getLength()==0)
DebugFile.writeln("ERROR: No MetaBlocks found");
else
if (null==((Element)oNodeList.item(i)).getElementsByTagName("metablock").item(0).getFirstChild())
DebugFile.writeln("ERROR: MetaBlock for Block " + String.valueOf(i) + " does not have the requiered id attribute");
else
if (((Element)oNodeList.item(i)).getElementsByTagName("metablock").item(0).getFirstChild().getNodeValue().length()==0)
DebugFile.writeln("ERROR: MetaBlock for Block " + String.valueOf(i) + " id attribute is empty.");
else
DebugFile.writeln("SortedMap.put(" + ((Element)oNodeList.item(i)).getElementsByTagName("metablock").item(0).getFirstChild().getNodeValue() + sPaddedID + ", " + oNodeList.item(i).toString()+")");
}
oSortedMap.put(((Element)oNodeList.item(i)).getElementsByTagName("metablock").item(0).getFirstChild().getNodeValue() + sPaddedID, oNodeList.item(i));
} // next (i)
Iterator oIterator = oSortedMap.keySet().iterator();
while (oIterator.hasNext()) {
Node oAux = (Node) oSortedMap.get(oIterator.next());
oLinkVctr.add(new Block(oAux));
if (DebugFile.trace)
DebugFile.writeln("Inserted " + ((Element)oAux).getElementsByTagName("metablock").item(0).getFirstChild().getNodeValue() + (new Integer(oAux.getAttributes().getNamedItem("id").getNodeValue())).intValue());
} // wend