diff options
author | Dan Timoney <dtimoney@att.com> | 2017-09-20 20:00:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-20 20:00:51 +0000 |
commit | e599a8ec658120298ed16a1e9e47e23c485cde6b (patch) | |
tree | 5329d40bec1d4b103c0cf7300f83564d1c264521 | |
parent | 33bfbaf4a7c2c33fc0b0b5ab18a5553dd8884cf7 (diff) | |
parent | ff9dfa14ecc880d13dfc1ce4648fc4baee9f7d99 (diff) |
Merge "Use entrySet instead of keySet"
-rw-r--r-- | restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 359501fc4..965d3daaa 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -132,23 +132,24 @@ public final class XmlJsonUtil { if (o instanceof Map) { StringBuilder ss = new StringBuilder(); Map<String, Object> mm = (Map<String, Object>) o; - for (String k : mm.keySet()) { - Object v = mm.get(k); + for (Map.Entry<String, Object> entry: mm.entrySet()) { + Object v = entry.getValue(); + String key = entry.getKey(); if (v instanceof String) { String s = escape ? escapeXml((String) v) : (String) v; - ss.append(pad(indent)).append('<').append(k).append('>'); + ss.append(pad(indent)).append('<').append(key).append('>'); ss.append(s); - ss.append("</").append(k).append('>').append('\n'); + ss.append("</").append(key).append('>').append('\n'); } else if (v instanceof Map) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(pad(indent)).append('<').append(key).append('>').append('\n'); ss.append(generateXml(v, indent + 1, escape)); - ss.append(pad(indent)).append("</").append(k).append('>').append('\n'); + ss.append(pad(indent)).append("</").append(key).append('>').append('\n'); } else if (v instanceof List) { List<Object> ll = (List<Object>) v; for (Object o1 : ll) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(pad(indent)).append('<').append(key).append('>').append('\n'); ss.append(generateXml(o1, indent + 1, escape)); - ss.append(pad(indent)).append("</").append(k).append('>').append('\n'); + ss.append(pad(indent)).append("</").append(key).append('>').append('\n'); } } } @@ -185,13 +186,13 @@ public final class XmlJsonUtil { ss.append("{\n"); boolean first = true; - for (String k : mm.keySet()) { + for (Map.Entry<String, Object> entry : mm.entrySet()) { if (!first) ss.append(",\n"); first = false; - - Object v = mm.get(k); - ss.append(pad(indent + 1)).append('"').append(k).append("\": "); + Object v = entry.getValue(); + String key = entry.getKey(); + ss.append(pad(indent + 1)).append('"').append(key).append("\": "); generateJson(ss, v, indent + 1, false, escape); } |