Skip to content

Commit 341edba

Browse files
authored
Resolved compiler warnings
1 parent 802ab37 commit 341edba

File tree

1 file changed

+12
-5
lines changed
  • src/main/java/com/github/underscore

1 file changed

+12
-5
lines changed

src/main/java/com/github/underscore/Xml.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ object Xml {
235235
return if (foundAttrs == 0 && foundElements == 1 && foundListElements == 0) null else newRootName
236236
}
237237

238+
@Suppress("UNCHECKED_CAST")
238239
private operator fun getValue(name: String?, value: Any?, fromType: FromType): Any? {
239240
val localValue: Any? = if (value is Map<*, *> && (value as Map<String?, Any?>).entries.size == 1) {
240241
val (key, value1) = (value as Map<String, Any?>).entries.iterator().next()
@@ -251,8 +252,7 @@ object Xml {
251252

252253
@JvmStatic
253254
fun stringToNumber(number: String): Any {
254-
val localValue: Any
255-
localValue = if (number.contains(".") || number.contains("e") || number.contains("E")) {
255+
val localValue: Any = if (number.contains(".") || number.contains("e") || number.contains("E")) {
256256
if (number.length > 9
257257
|| number.contains(".") && number.length - number.lastIndexOf('.') > 2
258258
&& number[number.length - 1] == '0'
@@ -343,6 +343,7 @@ object Xml {
343343
return checkNumberAndBoolean(map, node.nodeName)
344344
}
345345

346+
@Suppress("UNCHECKED_CAST")
346347
private fun checkNumberAndBoolean(map: MutableMap<String?, Any?>, name: String): Any {
347348
val localMap: MutableMap<String?, Any?>
348349
if (map.containsKey(NUMBER) && TRUE == map[NUMBER] && map.containsKey(TEXT)) {
@@ -363,6 +364,7 @@ object Xml {
363364
return checkArray(localMap2, name)
364365
}
365366

367+
@Suppress("UNCHECKED_CAST")
366368
private fun checkArray(map: MutableMap<String?, Any?>, name: String): Any {
367369
val localMap = checkNullAndString(map)
368370
val `object`: Any = if (map.containsKey(ARRAY) && TRUE == map[ARRAY]) {
@@ -403,6 +405,7 @@ object Xml {
403405
return object2
404406
}
405407

408+
@Suppress("UNCHECKED_CAST")
406409
private fun checkNullAndString(map: MutableMap<String?, Any?>): Map<String?, Any?> {
407410
val localMap: MutableMap<String?, Any?>
408411
if (map.containsKey(NULL_ATTR) && TRUE == map[NULL_ATTR]) {
@@ -587,6 +590,7 @@ object Xml {
587590
return result.append(lastChars).toString()
588591
}
589592

593+
@Suppress("UNCHECKED_CAST")
590594
private fun addNodeValue(
591595
map: MutableMap<String?, Any?>,
592596
name: String,
@@ -678,6 +682,7 @@ object Xml {
678682
}
679683
}
680684

685+
@Suppress("UNCHECKED_CAST")
681686
private fun checkResult(
682687
xml: String,
683688
document: org.w3c.dom.Document,
@@ -855,6 +860,7 @@ object Xml {
855860
return toXml(result as Map<*, *>?, identStep, ROOT)
856861
}
857862

863+
@Suppress("UNCHECKED_CAST")
858864
@JvmStatic
859865
fun changeXmlEncoding(
860866
xml: String?, identStep: XmlStringBuilder.Step, encoding: String?
@@ -1243,6 +1249,7 @@ object Xml {
12431249
}
12441250

12451251
object XmlObject {
1252+
@Suppress("UNCHECKED_CAST")
12461253
fun writeXml(
12471254
map: Map<*, *>?,
12481255
name: String?,
@@ -1706,6 +1713,7 @@ object Xml {
17061713
}
17071714
}
17081715

1716+
@Suppress("UNCHECKED_CAST")
17091717
private fun processArrays2(
17101718
value: Any,
17111719
builder: XmlStringBuilder,
@@ -1803,8 +1811,7 @@ object Xml {
18031811
private fun escape(s: String, sb: StringBuilder) {
18041812
val len = s.length
18051813
for (i in 0 until len) {
1806-
val ch = s[i]
1807-
when (ch) {
1814+
when (val ch = s[i]) {
18081815
'\'' -> sb.append("'")
18091816
'&' -> sb.append("&amp;")
18101817
'<' -> sb.append("&lt;")
@@ -1815,7 +1822,7 @@ object Xml {
18151822
'\r' -> sb.append("&#xD;")
18161823
'\t' -> sb.append("\t")
18171824
'' -> sb.append("")
1818-
else -> if (ch <= '\u001F' || ch >= '\u007F' && ch <= '\u009F' || ch >= '\u2000' && ch <= '\u20FF') {
1825+
else -> if (ch <= '\u001F' || ch in '\u007F'..'\u009F' || ch in '\u2000'..'\u20FF') {
18191826
val ss = Integer.toHexString(ch.code)
18201827
sb.append("&#x")
18211828
sb.append("0".repeat(4 - ss.length))

0 commit comments

Comments
 (0)