1414
1515public class GXProperties implements IGxJSONSerializable {
1616 private LinkedHashMap < String , GXProperty > properties = new LinkedHashMap < > ();
17+ private LinkedHashMap < String , GXProperty > originalProperties = new LinkedHashMap < > ();
1718 private boolean eof ;
1819 private int lastElement ;
1920
@@ -23,36 +24,40 @@ public void set(String name, String value) {
2324 this .put (name , value );
2425 }
2526
26- public void add (String name , String value ) {
27- properties .put (name , new GXProperty (name , value ));
28- }
27+ public void add (String name , String value ) { this .put (name , value ); }
2928
3029 public void put (String name , String value ) {
30+ originalProperties .put (name , new GXProperty (name , value ));
31+ name = name .toLowerCase ();
3132 properties .put (name , new GXProperty (name , value ));
3233 }
34+
3335 public String toString () {
3436 StringBuilder builder = new StringBuilder ();
35- for (GXProperty property : properties .values ()) {
37+ for (GXProperty property : properties .values ())
3638 builder .append (property .getValue ());
37- }
3839 return builder .toString ();
3940 }
4041
4142 public String get (String name ) {
43+ name = name .toLowerCase ();
4244 return containsKey (name ) ? properties .get (name ).getValue () : "" ;
4345 }
4446
4547 public void remove (String name ) {
48+ originalProperties .remove (name );
49+ name = name .toLowerCase ();
4650 properties .remove (name );
4751 }
4852
4953 public boolean containsKey (String name ) {
54+ name = name .toLowerCase ();
5055 return properties .containsKey (name );
5156 }
5257
5358 public GXProperty item (int i ) {
5459 int counter = 0 ;
55- for (Map .Entry < String , GXProperty > entry : properties .entrySet ()) {
60+ for (Map .Entry < String , GXProperty > entry : originalProperties .entrySet ()) {
5661 if (counter ++ == i ) {
5762 return entry .getValue ();
5863 }
@@ -76,7 +81,7 @@ public GXProperty first() {
7681 eof = false ;
7782 if (count () > 0 ) {
7883 lastElement = 0 ;
79- return properties .entrySet ().iterator ().next ().getValue ();
84+ return originalProperties .entrySet ().iterator ().next ().getValue ();
8085 } else {
8186 eof = true ;
8287 return null ;
@@ -114,12 +119,14 @@ public String toJSonString() {
114119 JSONObject jObj = (JSONObject ) GetJSONObject ();
115120 return jObj .toString ();
116121 }
122+
117123 public boolean fromJSonString (String s ) {
118124 return fromJSonString (s , null );
119125 }
126+
120127 public boolean fromJSonString (String s , GXBaseCollection < SdtMessages_Message > messages ) {
121128 this .clear ();
122- if (!s .equals ( "" )) {
129+ if (!s .isEmpty ( )) {
123130 try {
124131 JSONObject jObj = new JSONObject (s );
125132 Iterator < String > keys = jObj .keys ();
@@ -137,4 +144,4 @@ public boolean fromJSonString(String s, GXBaseCollection < SdtMessages_Message >
137144 return false ;
138145 }
139146 }
140- }
147+ }
0 commit comments