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
|
float calcNextOrderTime(String current_location) throws JDOMException, IOException
{
RetreivedHashmap map = new RetreivedHashmap();
TestDeserialization test = new TestDeserialization();
float time = 0;
float t1 = 0;
float t2 = 0;
List <Element> record = test.getXMLressources().getChildren("Record");
for (Element rec : record) {
List <Element> Row = rec.getChildren("Row");
Iterator<Element> it2 = Row.iterator();
Element row = it2.next();
String next_location = row.getAttributeValue("E");
current_order = (current_location+","+next_location);
t1 = map.hmap.get(current_order);
System.out.println("Order : " + current_order +" --> time for the order: "+ t1);
//Jusqu'ici tout va bien, mais c'est juste après, quand j'appelle le node que ya un probleme
// Node rootElement = getNextSiblingElement("Record"));
String go_next_order = (row.getAttributeValue("E")+","+getNextSiblingElement("Record")); // Cette ligne me dit incompatible types: String cannot be converted to Node
// t2 = map.hmap.get(go_next_order);
// System.out.println("Order : " + go_next_order +" --> time for the order: "+ t2);
}
time = t1+t2;
return time;
}
/** Finds and returns the next sibling element node. */
public static Element getNextSiblingElement(Node node)
{
TestDeserialization test = new TestDeserialization();
Element root = test.root;
// search for node
Node sibling = node.getNextSibling();
while (sibling != null) {
if (sibling.getNodeType() == Node.ELEMENT_NODE) {
return (Element)sibling;
}
sibling = sibling.getNextSibling();
}
// not found
return null;
} |
Partager