From 66d65006c1959b30f19930d85583248352d4890f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:14:41 -0300 Subject: [PATCH 1/7] Make GXProperties case insensitive Issue:107775 --- .../main/java/com/genexus/util/GXProperties.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index 09f8585c0..d3650ecaf 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -24,12 +24,11 @@ public void set(String name, String value) { } public void add(String name, String value) { - properties.put(name, new GXProperty(name, value)); + this.put(name, value); } - public void put(String name, String value) { - properties.put(name, new GXProperty(name, value)); - } + public void put(String name, String value) { properties.put(name, new GXProperty(name, value)); } + public String toString() { StringBuilder builder = new StringBuilder(); for (GXProperty property: properties.values()) { @@ -47,7 +46,10 @@ public void remove(String name) { } public boolean containsKey(String name) { - return properties.containsKey(name); + for (String key : properties.keySet()) + if (key.equalsIgnoreCase(name)) + return true; + return false; } public GXProperty item(int i) { @@ -104,7 +106,7 @@ public Object GetJSONObject() { GXProperty prop = item(i); try { jObj.put(prop.getKey(), prop.getValue()); - } catch (JSONException e) {} + } catch (JSONException ignored) {} i++; } return jObj; @@ -119,7 +121,7 @@ public boolean fromJSonString(String s) { } public boolean fromJSonString(String s, GXBaseCollection < SdtMessages_Message > messages) { this.clear(); - if (!s.equals("")) { + if (!s.isEmpty()) { try { JSONObject jObj = new JSONObject(s); Iterator < String > keys = jObj.keys(); From 3da2a6e497600122af63d5fb8a224c373d9885dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Wed, 3 Apr 2024 11:10:02 -0300 Subject: [PATCH 2/7] Make the get and remove method case insenstivie --- .../main/java/com/genexus/util/GXProperties.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index d3650ecaf..fb052c51e 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -38,11 +38,22 @@ public String toString() { } public String get(String name) { - return containsKey(name) ? properties.get(name).getValue() : ""; + return containsKey(name) ? this.getCaseInsensitive(name).getValue() : ""; + } + + public GXProperty getCaseInsensitive(String name) { + for (Map.Entry entry : properties.entrySet()) + if (entry.getKey().equalsIgnoreCase(name)) + return entry.getValue(); + return null; } public void remove(String name) { - properties.remove(name); + this.removeCaseInsensitive(name); + } + + public void removeCaseInsensitive(String name) { + properties.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(name)); } public boolean containsKey(String name) { From 507c05ec6395f9f64dd2263bef4b080665547114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:34:42 -0300 Subject: [PATCH 3/7] Revert "Make GXProperties case insensitive" This reverts commit 66d65006c1959b30f19930d85583248352d4890f. --- .../main/java/com/genexus/util/GXProperties.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index fb052c51e..80ce4f98e 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -24,11 +24,12 @@ public void set(String name, String value) { } public void add(String name, String value) { - this.put(name, value); + properties.put(name, new GXProperty(name, value)); } - public void put(String name, String value) { properties.put(name, new GXProperty(name, value)); } - + public void put(String name, String value) { + properties.put(name, new GXProperty(name, value)); + } public String toString() { StringBuilder builder = new StringBuilder(); for (GXProperty property: properties.values()) { @@ -57,10 +58,7 @@ public void removeCaseInsensitive(String name) { } public boolean containsKey(String name) { - for (String key : properties.keySet()) - if (key.equalsIgnoreCase(name)) - return true; - return false; + return properties.containsKey(name); } public GXProperty item(int i) { @@ -117,7 +115,7 @@ public Object GetJSONObject() { GXProperty prop = item(i); try { jObj.put(prop.getKey(), prop.getValue()); - } catch (JSONException ignored) {} + } catch (JSONException e) {} i++; } return jObj; @@ -132,7 +130,7 @@ public boolean fromJSonString(String s) { } public boolean fromJSonString(String s, GXBaseCollection < SdtMessages_Message > messages) { this.clear(); - if (!s.isEmpty()) { + if (!s.equals("")) { try { JSONObject jObj = new JSONObject(s); Iterator < String > keys = jObj.keys(); From b878394873e622415123de0405ed888d4829afd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:34:48 -0300 Subject: [PATCH 4/7] Revert "Make the get and remove method case insenstivie" This reverts commit 3da2a6e497600122af63d5fb8a224c373d9885dd. --- .../main/java/com/genexus/util/GXProperties.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index 80ce4f98e..09f8585c0 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -39,22 +39,11 @@ public String toString() { } public String get(String name) { - return containsKey(name) ? this.getCaseInsensitive(name).getValue() : ""; - } - - public GXProperty getCaseInsensitive(String name) { - for (Map.Entry entry : properties.entrySet()) - if (entry.getKey().equalsIgnoreCase(name)) - return entry.getValue(); - return null; + return containsKey(name) ? properties.get(name).getValue() : ""; } public void remove(String name) { - this.removeCaseInsensitive(name); - } - - public void removeCaseInsensitive(String name) { - properties.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(name)); + properties.remove(name); } public boolean containsKey(String name) { From 138b7656785febdfe28e48305ba152ce733a18f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:49:12 -0300 Subject: [PATCH 5/7] Store and retrive all entries as lower case --- .../main/java/com/genexus/util/GXProperties.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index 09f8585c0..a632b5821 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -23,30 +23,32 @@ public void set(String name, String value) { this.put(name, value); } - public void add(String name, String value) { - properties.put(name, new GXProperty(name, value)); - } + public void add(String name, String value) { this.put(name, value); } public void put(String name, String value) { + name = name.toLowerCase(); properties.put(name, new GXProperty(name, value)); } + public String toString() { StringBuilder builder = new StringBuilder(); - for (GXProperty property: properties.values()) { + for (GXProperty property: properties.values()) builder.append(property.getValue()); - } return builder.toString(); } public String get(String name) { + name = name.toLowerCase(); return containsKey(name) ? properties.get(name).getValue() : ""; } public void remove(String name) { + name = name.toLowerCase(); properties.remove(name); } public boolean containsKey(String name) { + name = name.toLowerCase(); return properties.containsKey(name); } @@ -114,12 +116,14 @@ public String toJSonString() { JSONObject jObj = (JSONObject) GetJSONObject(); return jObj.toString(); } + public boolean fromJSonString(String s) { return fromJSonString(s, null); } + public boolean fromJSonString(String s, GXBaseCollection < SdtMessages_Message > messages) { this.clear(); - if (!s.equals("")) { + if (!s.isEmpty()) { try { JSONObject jObj = new JSONObject(s); Iterator < String > keys = jObj.keys(); From bd12dc9d67f7fc4e967d88aa4c647d4817aa05f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:57:42 -0300 Subject: [PATCH 6/7] Store and retrive the original unmodified property --- common/src/main/java/com/genexus/util/GXProperties.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index a632b5821..8de571f6f 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -14,6 +14,7 @@ public class GXProperties implements IGxJSONSerializable { private LinkedHashMap < String, GXProperty > properties = new LinkedHashMap < > (); + private LinkedHashMap < String, GXProperty > originalProperties = new LinkedHashMap < > (); private boolean eof; private int lastElement; @@ -26,6 +27,7 @@ public void set(String name, String value) { public void add(String name, String value) { this.put(name, value); } public void put(String name, String value) { + originalProperties.put(name, new GXProperty(name, value)); name = name.toLowerCase(); properties.put(name, new GXProperty(name, value)); } @@ -54,7 +56,7 @@ public boolean containsKey(String name) { public GXProperty item(int i) { int counter = 0; - for (Map.Entry < String, GXProperty > entry: properties.entrySet()) { + for (Map.Entry < String, GXProperty > entry: originalProperties.entrySet()) { if (counter++ == i) { return entry.getValue(); } @@ -78,7 +80,7 @@ public GXProperty first() { eof = false; if (count() > 0) { lastElement = 0; - return properties.entrySet().iterator().next().getValue(); + return originalProperties.entrySet().iterator().next().getValue(); } else { eof = true; return null; From ec8eea5aefa54f065538bb5f9d4f22ebaa7bff3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:27:01 -0300 Subject: [PATCH 7/7] Remove property from originalProperties --- common/src/main/java/com/genexus/util/GXProperties.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/genexus/util/GXProperties.java b/common/src/main/java/com/genexus/util/GXProperties.java index 8de571f6f..dc3f1be71 100644 --- a/common/src/main/java/com/genexus/util/GXProperties.java +++ b/common/src/main/java/com/genexus/util/GXProperties.java @@ -45,6 +45,7 @@ public String get(String name) { } public void remove(String name) { + originalProperties.remove(name); name = name.toLowerCase(); properties.remove(name); } @@ -143,4 +144,4 @@ public boolean fromJSonString(String s, GXBaseCollection < SdtMessages_Message > return false; } } -} \ No newline at end of file +}