Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 9c0fb91

Browse files
调整代码路径,以后将以此为基准
1 parent 21b8849 commit 9c0fb91

22 files changed

+140
-86
lines changed

core/src/main/kotlin/com/github/open_edgn/data/format/utils/ArgsReader.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/ArgsReader.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
package com.github.open_edgn.data.format.utils
1+
package com.github.open_edgn.data.format
22

3-
import com.github.open_edgn.data.format.ArgsItem
4-
import com.github.open_edgn.data.format.Beta
5-
import com.github.open_edgn.data.format.FormatErrorException
6-
import com.github.open_edgn.data.format.Ignore
73
import org.slf4j.LoggerFactory
8-
import java.lang.RuntimeException
94
import kotlin.reflect.KClass
105
import kotlin.reflect.full.createInstance
116
import kotlin.reflect.full.declaredMemberProperties
127
import kotlin.reflect.full.findAnnotation
13-
import kotlin.reflect.jvm.*
8+
import kotlin.reflect.jvm.isAccessible
9+
import kotlin.reflect.jvm.javaField
10+
import kotlin.reflect.jvm.jvmErasure
11+
import kotlin.reflect.jvm.jvmName
1412

1513
/**
1614
* 解析 main 方法下的 Args 方案

core/src/main/kotlin/com/github/open_edgn/data/format/io/BaseDataProperties.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/BaseDataProperties.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

33
import org.slf4j.Logger
44
import org.slf4j.LoggerFactory
@@ -43,47 +43,47 @@ abstract class BaseDataProperties : IDataProperties {
4343
}
4444

4545
override fun putByte(key: String, value: Byte): IDataProperties {
46-
set(key,value)
46+
set(key, value)
4747
return this
4848
}
4949

5050
override fun putInt(key: String, value: Int): IDataProperties {
51-
set(key,value)
51+
set(key, value)
5252
return this
5353
}
5454

5555
override fun putFloat(key: String, value: Float): IDataProperties {
56-
set(key,value)
56+
set(key, value)
5757
return this
5858
}
5959

6060
override fun putLong(key: String, value: Long): IDataProperties {
61-
set(key,value)
61+
set(key, value)
6262
return this
6363
}
6464

6565
override fun putShort(key: String, value: Short): IDataProperties {
66-
set(key,value)
66+
set(key, value)
6767
return this
6868
}
6969

7070
override fun putDouble(key: String, value: Double): IDataProperties {
71-
set(key,value)
71+
set(key, value)
7272
return this
7373
}
7474

7575
override fun putBoolean(key: String, value: Boolean): IDataProperties {
76-
set(key,value)
76+
set(key, value)
7777
return this
7878
}
7979

8080
override fun putChar(key: String, value: Char): IDataProperties {
81-
set(key,value)
81+
set(key, value)
8282
return this
8383
}
8484

8585
override fun putString(key: String, value: String): IDataProperties {
86-
set(key,value)
86+
set(key, value)
8787
return this
8888
}
8989
}

core/src/main/kotlin/com/github/open_edgn/data/format/io/DataSerializableFactory.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/DataSerializableFactory.kt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

33
import java.io.PrintWriter
44
import java.io.Reader
@@ -45,25 +45,13 @@ interface DataSerializableFactory {
4545
}
4646

4747
override fun output(container: Map<String, String>, writer: Writer): Int {
48-
val printWriter = PrintWriter(writer.toString())
48+
val printWriter = PrintWriter(writer)
4949
var len = 0
5050
container.forEach { (k, v) ->
5151
len++
52-
printWriter.println("${char2Unicode(k)}=${char2Unicode(v)}")
52+
printWriter.println("$k=$v")
5353
}
5454
return len
5555
}
56-
57-
private fun char2Unicode(k: String): String {
58-
val unicode = StringBuffer()
59-
for (c in k) {
60-
if (c.isLetterOrDigit() || c.isJavaIdentifierStart()) {
61-
unicode.append(c)
62-
} else {
63-
unicode.append("\\u").append(c.toLong().toString(16))
64-
}
65-
}
66-
return unicode.toString()
67-
}
6856
}
6957
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.github.open_edgn.data.format
22

3-
import java.lang.RuntimeException
4-
53

64
/**
75
* 通用异常:未找到的异常
86
* @property message String? 异常消息,必须
97
*/
10-
class NotFoundException (override val message: String?): RuntimeException(message)
8+
class NotFoundException(override val message: String?) : RuntimeException(message)
119

1210
/**
1311
* 通用异常:格式化错误异常
1412
* @property message String? 异常消息,必须
1513
*/
16-
class FormatErrorException(override val message: String?, e: Throwable? = null): RuntimeException(message,e)
14+
class FormatErrorException(override val message: String?, e: Throwable? = null) : RuntimeException(message, e)

core/src/main/kotlin/com/github/open_edgn/data/format/Externals.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
package com.github.open_edgn.data.format
22

3-
import com.github.open_edgn.data.format.io.HashDataProperties
4-
import com.github.open_edgn.data.format.io.IDataProperties
5-
import com.github.open_edgn.data.format.utils.ObjectUtils
6-
import com.github.open_edgn.data.format.utils.StringFillUtils
7-
import com.github.open_edgn.data.format.utils.StringFormatUtils
8-
import com.github.open_edgn.data.format.utils.StringUtils
93
import java.io.InputStream
104
import java.io.Reader
115
import java.nio.charset.Charset

core/src/main/kotlin/com/github/open_edgn/data/format/io/HashDataProperties.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/HashDataProperties.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

3-
import com.github.open_edgn.data.format.utils.StringFillUtils
4-
import com.github.open_edgn.data.format.utils.StringFormatUtils
53
import java.io.Reader
64
import java.io.Writer
75
import java.util.*
@@ -26,6 +24,11 @@ class HashDataProperties(private val formatString: Boolean = true) : BaseDataPro
2624
return container.hashCode()
2725
}
2826

27+
override val keys: Set<String>
28+
get() = container.keys.toSet()
29+
30+
override fun get(key: String): Any? = container[key]
31+
2932
override fun equals(other: Any?): Boolean {
3033
if (this === other) return true
3134
if (javaClass != other?.javaClass) return false

core/src/main/kotlin/com/github/open_edgn/data/format/io/IDataBackups.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/IDataBackups.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

33
import java.io.Reader
44
import java.io.Writer

core/src/main/kotlin/com/github/open_edgn/data/format/io/IDataProperties.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/IDataProperties.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

33
/**
44
* 一个基于 (Key/Value) 关联的数据集合包装类
55
*/
66
interface IDataProperties : IDataBackups, IDataReader, IDataWriter {
77

8+
val keys: Set<String>
9+
10+
811
override fun toString(): String
912

1013
override fun hashCode(): Int
1114

1215
override fun equals(other: Any?): Boolean
1316

17+
operator fun get(key: String): Any?
18+
1419
}

core/src/main/kotlin/com/github/open_edgn/data/format/io/IDataReader.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/IDataReader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

33
import java.io.Serializable
44

5-
interface IDataReader: Serializable {
5+
interface IDataReader : Serializable {
66
/**
77
* 根据键值获取 Byte 类型的数据
88
*

core/src/main/kotlin/com/github/open_edgn/data/format/io/IDataWriter.kt renamed to core/src/main/kotlin/com/github/open_edgn/data/format/IDataWriter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.open_edgn.data.format.io
1+
package com.github.open_edgn.data.format
22

33
import java.io.Serializable
44

0 commit comments

Comments
 (0)