Skip to content

Commit a48745b

Browse files
committed
消除警告
1 parent 97a2b99 commit a48745b

File tree

31 files changed

+296
-315
lines changed

31 files changed

+296
-315
lines changed

async/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<plugin>
2424
<groupId>org.springframework.boot</groupId>
2525
<artifactId>spring-boot-maven-plugin</artifactId>
26+
<version>1.5.8.RELEASE</version>
2627
<executions>
2728
<execution>
2829
<goals>

core/src/main/java/info/xiaomo/core/untils/CastUtil.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ import java.util.*
2020

2121
class CastUtil {
2222
companion object {
23-
protected val OUT = ByteArrayOutputStream()
24-
protected var oos: ObjectOutputStream? = null
23+
private val OUT = ByteArrayOutputStream()
24+
private var oos: ObjectOutputStream? = null
2525

2626
fun toInteger(str: Any?): Int {
2727
return if (str == null) 0 else (str as? Number)?.toInt() ?: toInteger(str.toString())
2828
}
2929

3030
fun toDouble(number: Any?): Double {
31-
if (number == null) {
32-
return 0.0
31+
return if (number == null) {
32+
0.0
3333
} else if (number is Number) {
34-
return number.toDouble()
34+
number.toDouble()
3535
} else if (number is String) {
3636
val str = number as String?
37-
return if (isNumeric(str) > 0) java.lang.Double.valueOf(str!!) else 0.0
37+
if (isNumeric(str) > 0) java.lang.Double.valueOf(str!!) else 0.0
3838
} else {
39-
return 0.0
39+
0.0
4040
}
4141
}
4242

@@ -55,16 +55,16 @@ class CastUtil {
5555
}
5656

5757
fun toInteger(str: String?): Int {
58-
var str = str
59-
if (str == null) {
60-
return 0
58+
var intStr = str
59+
return if (intStr == null) {
60+
0
6161
} else {
62-
str = str.trim { it <= ' ' }
63-
if (str.length == 0) {
64-
return 0
62+
intStr = intStr.trim { it <= ' ' }
63+
if (intStr.isEmpty()) {
64+
0
6565
} else {
66-
val i = isNumeric(str)
67-
return if (i == 1) Integer.parseInt(str) else if (i == 2) java.lang.Double.valueOf(str).toInt() else 0
66+
val i = isNumeric(intStr)
67+
if (i == 1) Integer.parseInt(intStr) else if (i == 2) java.lang.Double.valueOf(intStr).toInt() else 0
6868
}
6969
}
7070
}
@@ -118,7 +118,7 @@ class CastUtil {
118118
val newmap = HashMap<Any, Any>(10)
119119

120120
for (key in map.keys) {
121-
newmap.put(key, map.get(key)!!)
121+
newmap.put(key, map[key]!!)
122122
}
123123

124124
return newmap
@@ -221,7 +221,6 @@ class CastUtil {
221221

222222
fun stringToBytes(str: String): ByteArray {
223223
val sb = StringBuffer(str)
224-
val c = sb[0]
225224
val buffer = ByteBuffer.allocate(sb.length * 2)
226225
var index = 0
227226

core/src/main/java/info/xiaomo/core/untils/CharUtil.kt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,33 @@ object CharUtil {
7474
* Utf8URL解码
7575
*/
7676
fun utf8urldecode(text: String?): String {
77-
var text = text
77+
var str = text
7878
var result = ""
7979
var p: Int
80-
if (text != null && text.length > 0) {
81-
text = text.toLowerCase()
82-
p = text.indexOf("%e")
80+
if (str != null && str.isNotEmpty()) {
81+
str = str.toLowerCase()
82+
p = str.indexOf("%e")
8383
if (p == -1) {
84-
return text
84+
return str
8585
}
8686
while (p != -1) {
87-
result += text!!.substring(0, p)
88-
text = text.substring(p, text.length)
89-
if (text == "" || text.length < 9) {
87+
result += str!!.substring(0, p)
88+
str = str.substring(p, str.length)
89+
if (str == "" || str.length < 9) {
9090
return result
9191
}
92-
result += codetoword(text.substring(0, 9))
93-
text = text.substring(9, text.length)
94-
p = text.indexOf("%e")
92+
result += codeToWord(str.substring(0, 9))
93+
str = str.substring(9, str.length)
94+
p = str.indexOf("%e")
9595
}
9696
}
97-
return result + text!!
97+
return result + str!!
9898
}
9999

100100
/**
101101
* utf8URL编码转字符
102102
*/
103-
private fun codetoword(text: String): String? {
103+
private fun codeToWord(text: String): String? {
104104
var result: String?
105105
if (utf8codecheck(text)) {
106106
val code = ByteArray(3)
@@ -142,14 +142,14 @@ object CharUtil {
142142
* 判断是否Utf8Url编码
143143
*/
144144
fun isUtf8Url(text: String): Boolean {
145-
var text = text
146-
text = text.toLowerCase()
147-
val p = text.indexOf("%")
145+
var textStr = text
146+
textStr = textStr.toLowerCase()
147+
val p = textStr.indexOf("%")
148148
val nine = 9
149-
if (p != -1 && text.length - p > nine) {
150-
text = text.substring(p, p + nine)
149+
if (p != -1 && textStr.length - p > nine) {
150+
textStr = textStr.substring(p, p + nine)
151151
}
152-
return utf8codecheck(text)
152+
return utf8codecheck(textStr)
153153
}
154154

155155
/**
@@ -158,19 +158,19 @@ object CharUtil {
158158
* @return char
159159
*/
160160
fun regularize(input: Char): Char {
161-
var input = input
162-
if (input.toInt() == 12288) {
163-
input = 32.toChar()
164-
} else if (input.toInt() > 65280 && input.toInt() < 65375) {
165-
input = (input.toInt() - 65248).toChar()
161+
var char = input
162+
if (char.toInt() == 12288) {
163+
char = 32.toChar()
164+
} else if (char.toInt() in 65281..65374) {
165+
char = (char.toInt() - 65248).toChar()
166166
} else {
167167
val a = 'A'
168168
val z = 'Z'
169-
if (input >= a && input <= z) {
170-
input += 32.toChar().toInt()
169+
if (char in a..z) {
170+
char += 32.toChar().toInt()
171171
}
172172
}
173-
return input
173+
return char
174174
}
175175

176176
@JvmStatic

core/src/main/java/info/xiaomo/core/untils/FileUtil.kt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ object FileUtil {
201201
}
202202

203203
val entries = dir.listFiles()
204-
val sz = entries?.size ?: 0
205204

206205
for (entry in entries ?: arrayOfNulls(0)) {
207206
if (entry.isDirectory) {
@@ -528,10 +527,10 @@ object FileUtil {
528527
*/
529528
@Throws(IOException::class)
530529
fun genModuleTpl(path: String, modulecontent: String): Boolean {
531-
var path = path
530+
var str = path
532531

533-
path = getUNIXfilePath(path)
534-
val patharray = path.split("\\/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
532+
str = getUNIXfilePath(str)
533+
val patharray = str.split("\\/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
535534
var modulepath = ""
536535
for (i in 0 until patharray.size - 1) {
537536
modulepath += "/" + patharray[i]
@@ -543,7 +542,7 @@ object FileUtil {
543542
}
544543
}
545544
//建立FileWriter对象,并实例化fw
546-
val fw = FileWriter(path)
545+
val fw = FileWriter(str)
547546
//将字符串写入文件
548547
fw.write(modulecontent)
549548
fw.close()
@@ -558,23 +557,23 @@ object FileUtil {
558557
* @since 1.0
559558
*/
560559
fun getPicExtendName(picPath: String): String {
561-
var picPath = picPath
562-
picPath = getUNIXfilePath(picPath)
560+
var pic = picPath
561+
pic = getUNIXfilePath(pic)
563562
var picExtend = ""
564563
val gif = ".gif"
565-
if (isFileExist(picPath + gif)) {
564+
if (isFileExist(pic + gif)) {
566565
picExtend = gif
567566
}
568567
val jpeg = ".jpeg"
569-
if (isFileExist(picPath + jpeg)) {
568+
if (isFileExist(pic + jpeg)) {
570569
picExtend = jpeg
571570
}
572571
val jpg = ".jpg"
573-
if (isFileExist(picPath + jpg)) {
572+
if (isFileExist(pic + jpg)) {
574573
picExtend = jpg
575574
}
576575
val png = ".png"
577-
if (isFileExist(picPath + png)) {
576+
if (isFileExist(pic + png)) {
578577
picExtend = png
579578
}
580579
//返回图片扩展名
@@ -672,15 +671,14 @@ object FileUtil {
672671
// 重新定义图片名字
673672
filename = FileUtil.getNewFileName(fileName, email)
674673
//上传服务器上 新文件路径
675-
val os = System.getProperty("os.name").toLowerCase()
676674
try {
677675
// 判断服务器上 文件夹是否存在
678676
val newFile = File(savePath)
679677
if (!newFile.exists()) {
680678
val result = newFile.mkdirs()
681679
println(result)
682680
}
683-
savePath = savePath + filename
681+
savePath += filename
684682
val out = FileOutputStream(savePath)
685683
// 写入文件
686684
out.write(file.bytes)
@@ -716,7 +714,6 @@ object FileUtil {
716714
var bytes: ByteArray? = ByteArray(len)
717715
val r = bufferedInputStream.read(bytes!!)
718716
if (len != r) {
719-
bytes = null
720717
throw IOException("读取文件不正确")
721718
}
722719
bufferedInputStream.close()
@@ -731,7 +728,6 @@ object FileUtil {
731728
var bytes: ByteArray? = ByteArray(len)
732729
val r = bufferedInputStream.read(bytes!!)
733730
if (len != r) {
734-
bytes = null
735731
throw IOException("读取文件不正确")
736732
}
737733
bufferedInputStream.close()
@@ -746,10 +742,9 @@ object FileUtil {
746742
* @return
747743
*/
748744
private fun getData(`in`: InputStream): String {
749-
val result = ""
750745
val sb = StringBuilder()
751746
val br = BufferedReader(InputStreamReader(`in`))
752-
var line = ""
747+
val line = ""
753748
try {
754749
while ((br.readLine()) != null) {
755750
// result = result + line;

core/src/main/java/info/xiaomo/core/untils/HtmlUtil.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ object HtmlUtil {
125125
* @since 1.0
126126
*/
127127
fun htmlDecode(strSrc: String?): String? {
128-
var strSrc: String? = strSrc ?: return ""
129-
strSrc = strSrc!!.replace("&lt;".toRegex(), "<")
130-
strSrc = strSrc.replace("&gt;".toRegex(), ">")
131-
strSrc = strSrc.replace("&quot;".toRegex(), "\"")
132-
strSrc = strSrc.replace("&#039;".toRegex(), "'")
133-
strSrc = strSrc.replace("&amp;".toRegex(), "&")
134-
return strSrc
128+
var str: String? = strSrc ?: return ""
129+
str = str!!.replace("&lt;".toRegex(), "<")
130+
str = str.replace("&gt;".toRegex(), ">")
131+
str = str.replace("&quot;".toRegex(), "\"")
132+
str = str.replace("&#039;".toRegex(), "'")
133+
str = str.replace("&amp;".toRegex(), "&")
134+
return str
135135
}
136136

137137
/**
@@ -141,7 +141,7 @@ object HtmlUtil {
141141
* @return string
142142
*/
143143
fun delHTMLTag(htmlStr: String): String {
144-
var htmlStr = htmlStr
144+
var text = htmlStr
145145
//定义script的正则表达式
146146
val regexScript = "<script[^>]*?>[\\s\\S]*?<\\/script>"
147147
//定义style的正则表达式
@@ -150,21 +150,21 @@ object HtmlUtil {
150150
val regexHtml = "<[^>]+>"
151151

152152
val pScript = Pattern.compile(regexScript, Pattern.CASE_INSENSITIVE)
153-
val mScript = pScript.matcher(htmlStr)
153+
val mScript = pScript.matcher(text)
154154
//过滤script标签
155-
htmlStr = mScript.replaceAll("")
155+
text = mScript.replaceAll("")
156156

157157
val pStyle = Pattern.compile(regexStyle, Pattern.CASE_INSENSITIVE)
158-
val mStyle = pStyle.matcher(htmlStr)
158+
val mStyle = pStyle.matcher(text)
159159
//过滤style标签
160-
htmlStr = mStyle.replaceAll("")
160+
text = mStyle.replaceAll("")
161161

162162
val pHtml = Pattern.compile(regexHtml, Pattern.CASE_INSENSITIVE)
163-
val mHtml = pHtml.matcher(htmlStr)
163+
val mHtml = pHtml.matcher(text)
164164
//过滤html标签
165-
htmlStr = mHtml.replaceAll("")
165+
text = mHtml.replaceAll("")
166166
//返回文本字符串
167-
return htmlStr.trim { it <= ' ' }
167+
return text.trim { it <= ' ' }
168168
}
169169

170170
}

core/src/main/java/info/xiaomo/core/untils/HttpUtil.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class HttpUtil {
126126
val read = BufferedReader(InputStreamReader(`in`, DEFAULT_CHARSET))
127127
val valueString: String? = null
128128
bufferRes = StringBuffer()
129-
while ((valueString == read.readLine()) != null) {
129+
while ((read.readLine()) != null) {
130130
bufferRes.append(valueString)
131131
}
132132
read.close()
@@ -141,13 +141,13 @@ class HttpUtil {
141141
}
142142

143143
fun post(url: String, params: String?, headers: Map<String, String>?): String? {
144-
var bufferRes: StringBuffer? = null
144+
var bufferRes: StringBuffer?
145145
try {
146-
var http: HttpURLConnection? = null
147-
if (isHttps(url)) {
148-
http = initHttps(url, POST, headers)
146+
var http: HttpURLConnection?
147+
http = if (isHttps(url)) {
148+
initHttps(url, POST, headers)
149149
} else {
150-
http = initHttp(url, POST, headers)
150+
initHttp(url, POST, headers)
151151
}
152152
val out = http.outputStream
153153
out.write(params!!.toByteArray(charset(DEFAULT_CHARSET)))

0 commit comments

Comments
 (0)