Skip to content

Commit 8c14e96

Browse files
authored
Merge pull request #1017 from Md-Yasir/enhancement/refactors
Code Refactors
2 parents 25f355a + 0cdc5e5 commit 8c14e96

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/main/java/org/json/CDL.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public class CDL {
2727

2828
/**
2929
* Constructs a new CDL object.
30+
* @deprecated (Utility class cannot be instantiated)
3031
*/
32+
@Deprecated
3133
public CDL() {
3234
}
3335

src/main/java/org/json/Cookie.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public class Cookie {
1717

1818
/**
1919
* Constructs a new Cookie object.
20+
* @deprecated (Utility class cannot be instantiated)
2021
*/
22+
@Deprecated()
2123
public Cookie() {
2224
}
2325

src/main/java/org/json/CookieList.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public class CookieList {
1313

1414
/**
1515
* Constructs a new CookieList object.
16+
* @deprecated (Utility class cannot be instantiated)
1617
*/
18+
@Deprecated
1719
public CookieList() {
1820
}
1921

src/main/java/org/json/JSONML.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ public class JSONML {
1616

1717
/**
1818
* Constructs a new JSONML object.
19+
* @deprecated (Utility class cannot be instantiated)
1920
*/
21+
@Deprecated
2022
public JSONML() {
2123
}
2224

25+
2326
/**
2427
* Parse XML values and store them in a JSONArray.
2528
* @param x The XMLTokener containing the source string.
@@ -239,9 +242,21 @@ private static Object parse(
239242
}
240243
} else {
241244
if (ja != null) {
242-
ja.put(token instanceof String
243-
? (config.isKeepStrings() ? XML.unescape((String)token) : XML.stringToValue((String)token))
244-
: token);
245+
Object value;
246+
247+
if (token instanceof String) {
248+
String strToken = (String) token;
249+
if (config.isKeepStrings()) {
250+
value = XML.unescape(strToken);
251+
} else {
252+
value = XML.stringToValue(strToken);
253+
}
254+
} else {
255+
value = token;
256+
}
257+
258+
ja.put(value);
259+
245260
}
246261
}
247262
}

0 commit comments

Comments
 (0)