I have a Map within a Map within a Map. The format is HashMap<String, Map> A sample data:
deviceName={commandName={dataKey1=[dataValue1], dataKey2=[dataValue2]}}
The way it’s setup is deviceName is the key and commandName is the value for it. To keep it simple there is only one now but there could be more than one command. At the second iteration commandName is the key and {dataKey1=[dataValue1], dataKey2=[dataValue2]} is the value. In the third iteration dataKey1 is the key and dataValue1 is the value(it’s an arrayList).
I can iterate through one but i am not sure how to do this.
public void analyseVersion(Map cmd) {
Iterator deviceIT = cmd.keySet().iterator();
while (deviceIT.hasNext()) {
String deviceName = (String) deviceIT.next();
//Map<String, Map> cmd = (Map<String, Map>) cmd.get(deviceName);//This will not work.
//At this point I want to iterate through each command and for each command iterate through each data set.
}
}
To echo jtahlborn, abstraction is your friend