aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsurya-huawei <a.u.surya@huawei.com>2017-09-20 16:50:20 +0530
committersurya-huawei <a.u.surya@huawei.com>2017-09-20 17:01:51 +0530
commitff9dfa14ecc880d13dfc1ce4648fc4baee9f7d99 (patch)
tree70128847325f4c1b44387de5940e8fbc600df31c
parentba209b4de55c56e5c427e3389518966f2c896661 (diff)
Use entrySet instead of keySet
*Iterating over map entries with entrySet This is done because both key and value are needed and iterating over entryset is more efficient than keyset Issue-Id: CCSDK-87 Change-Id: I31d14239c8f7300ff2d3a629683e00b42e61ad86 Signed-off-by: surya-huawei <a.u.surya@huawei.com>
-rw-r--r--restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java25
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 b94f0a63..4a04d97d 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);
}