* @throws IOException If there was an error parsing the JSON
*/
public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOException {
Map<String, Object> entry = new HashMap<String, Object>();
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(fmJson);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n == "name")
entry.put(StaticFlowEntryPusher.COLUMN_NAME, jp.getText());
else if (n == "switch")
entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, jp.getText());
else if (n == "actions")
entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, jp.getText());
else if (n == "priority")
entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, jp.getText());
else if (n == "active")
entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, jp.getText());
else if (n == "wildcards")
entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, jp.getText());
else if (n == "ingress-port")
entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, jp.getText());
else if (n == "src-mac")
entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, jp.getText());
else if (n == "dst-mac")
entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, jp.getText());
else if (n == "vlan-id")
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, jp.getText());
else if (n == "vlan-priority")
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, jp.getText());
else if (n == "ether-type")
entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, jp.getText());
else if (n == "tos-bits")
entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, jp.getText());
else if (n == "protocol")
entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, jp.getText());
else if (n == "src-ip")
entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, jp.getText());
else if (n == "dst-ip")
entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, jp.getText());
else if (n == "src-port")
entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, jp.getText());
else if (n == "dst-port")
entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, jp.getText());
}
return entry;
}