@@ -17,7 +17,6 @@ private const val UPPER_CASE_HEX_DIGITS = "0123456789ABCDEF"
17
17
* of each Byte value makes it possible to access the table only once per Byte.
18
18
* This noticeably improves performance, especially for large ByteArray's.
19
19
*/
20
- @ExperimentalStdlibApi
21
20
internal val BYTE_TO_LOWER_CASE_HEX_DIGITS = IntArray (256 ) {
22
21
(LOWER_CASE_HEX_DIGITS [(it shr 4 )].code shl 8 ) or LOWER_CASE_HEX_DIGITS [(it and 0xF )].code
23
22
}
@@ -79,8 +78,8 @@ private val HEX_DIGITS_TO_LONG_DECIMAL = LongArray(256) { -1 }.apply {
79
78
*
80
79
* @sample samples.text.HexFormats.Extensions.byteArrayToHexString
81
80
*/
82
- @ExperimentalStdlibApi
83
- @SinceKotlin(" 1.9 " )
81
+ @WasExperimental( ExperimentalStdlibApi :: class )
82
+ @SinceKotlin(" 2.2 " )
84
83
public fun ByteArray.toHexString (format : HexFormat = HexFormat .Default ): String = toHexString(0 , size, format)
85
84
86
85
/* *
@@ -108,8 +107,8 @@ public fun ByteArray.toHexString(format: HexFormat = HexFormat.Default): String
108
107
*
109
108
* @sample samples.text.HexFormats.Extensions.byteArrayToHexString
110
109
*/
111
- @ExperimentalStdlibApi
112
- @SinceKotlin(" 1.9 " )
110
+ @WasExperimental( ExperimentalStdlibApi :: class )
111
+ @SinceKotlin(" 2.2 " )
113
112
public fun ByteArray.toHexString (
114
113
startIndex : Int = 0,
115
114
endIndex : Int = size,
@@ -132,7 +131,6 @@ public fun ByteArray.toHexString(
132
131
return toHexStringSlowPath(startIndex, endIndex, bytesFormat, byteToDigits)
133
132
}
134
133
135
- @ExperimentalStdlibApi
136
134
private fun ByteArray.toHexStringNoLineAndGroupSeparator (
137
135
startIndex : Int ,
138
136
endIndex : Int ,
@@ -147,7 +145,6 @@ private fun ByteArray.toHexStringNoLineAndGroupSeparator(
147
145
return toHexStringNoLineAndGroupSeparatorSlowPath(startIndex, endIndex, bytesFormat, byteToDigits)
148
146
}
149
147
150
- @ExperimentalStdlibApi
151
148
private fun ByteArray.toHexStringShortByteSeparatorNoPrefixAndSuffix (
152
149
startIndex : Int ,
153
150
endIndex : Int ,
@@ -180,7 +177,6 @@ private fun ByteArray.toHexStringShortByteSeparatorNoPrefixAndSuffix(
180
177
}
181
178
}
182
179
183
- @ExperimentalStdlibApi
184
180
private fun ByteArray.toHexStringNoLineAndGroupSeparatorSlowPath (
185
181
startIndex : Int ,
186
182
endIndex : Int ,
@@ -209,7 +205,6 @@ private fun ByteArray.toHexStringNoLineAndGroupSeparatorSlowPath(
209
205
return charArray.concatToString()
210
206
}
211
207
212
- @ExperimentalStdlibApi
213
208
private fun ByteArray.toHexStringSlowPath (
214
209
startIndex : Int ,
215
210
endIndex : Int ,
@@ -362,8 +357,8 @@ private fun checkFormatLength(formatLength: Long): Int {
362
357
*
363
358
* @sample samples.text.HexFormats.Extensions.hexToByteArray
364
359
*/
365
- @ExperimentalStdlibApi
366
- @SinceKotlin(" 1.9 " )
360
+ @WasExperimental( ExperimentalStdlibApi :: class )
361
+ @SinceKotlin(" 2.2 " )
367
362
public fun String.hexToByteArray (format : HexFormat = HexFormat .Default ): ByteArray = hexToByteArray(0 , length, format)
368
363
369
364
/* *
@@ -387,7 +382,7 @@ public fun String.hexToByteArray(format: HexFormat = HexFormat.Default): ByteArr
387
382
* @throws IllegalArgumentException when `startIndex > endIndex`.
388
383
* @throws IllegalArgumentException if the substring does not conform to the specified [format].
389
384
*/
390
- @ExperimentalStdlibApi
385
+ // @ExperimentalStdlibApi
391
386
// @SinceKotlin("1.9")
392
387
private fun String.hexToByteArray (
393
388
startIndex : Int = 0,
@@ -410,7 +405,6 @@ private fun String.hexToByteArray(
410
405
return hexToByteArraySlowPath(startIndex, endIndex, bytesFormat)
411
406
}
412
407
413
- @ExperimentalStdlibApi
414
408
private fun String.hexToByteArrayNoLineAndGroupSeparator (
415
409
startIndex : Int ,
416
410
endIndex : Int ,
@@ -424,7 +418,6 @@ private fun String.hexToByteArrayNoLineAndGroupSeparator(
424
418
return hexToByteArrayNoLineAndGroupSeparatorSlowPath(startIndex, endIndex, bytesFormat)
425
419
}
426
420
427
- @ExperimentalStdlibApi
428
421
private fun String.hexToByteArrayShortByteSeparatorNoPrefixAndSuffix (
429
422
startIndex : Int ,
430
423
endIndex : Int ,
@@ -463,7 +456,6 @@ private fun String.hexToByteArrayShortByteSeparatorNoPrefixAndSuffix(
463
456
}
464
457
}
465
458
466
- @ExperimentalStdlibApi
467
459
private fun String.hexToByteArrayNoLineAndGroupSeparatorSlowPath (
468
460
startIndex : Int ,
469
461
endIndex : Int ,
@@ -499,7 +491,6 @@ private fun String.hexToByteArrayNoLineAndGroupSeparatorSlowPath(
499
491
return byteArray
500
492
}
501
493
502
- @ExperimentalStdlibApi
503
494
private fun String.hexToByteArraySlowPath (
504
495
startIndex : Int ,
505
496
endIndex : Int ,
@@ -660,8 +651,8 @@ private fun String.checkNewLineAt(index: Int, endIndex: Int): Int {
660
651
*
661
652
* @sample samples.text.HexFormats.Extensions.byteToHexString
662
653
*/
663
- @ExperimentalStdlibApi
664
- @SinceKotlin(" 1.9 " )
654
+ @WasExperimental( ExperimentalStdlibApi :: class )
655
+ @SinceKotlin(" 2.2 " )
665
656
public fun Byte.toHexString (format : HexFormat = HexFormat .Default ): String {
666
657
val digits = if (format.upperCase) UPPER_CASE_HEX_DIGITS else LOWER_CASE_HEX_DIGITS
667
658
val numberFormat = format.number
@@ -703,8 +694,8 @@ public fun Byte.toHexString(format: HexFormat = HexFormat.Default): String {
703
694
*
704
695
* @sample samples.text.HexFormats.Extensions.hexToByte
705
696
*/
706
- @ExperimentalStdlibApi
707
- @SinceKotlin(" 1.9 " )
697
+ @WasExperimental( ExperimentalStdlibApi :: class )
698
+ @SinceKotlin(" 2.2 " )
708
699
public fun String.hexToByte (format : HexFormat = HexFormat .Default ): Byte = hexToByte(0 , length, format)
709
700
710
701
/* *
@@ -731,7 +722,7 @@ public fun String.hexToByte(format: HexFormat = HexFormat.Default): Byte = hexTo
731
722
* @throws IllegalArgumentException if the substring does not conform to the specified [format], or if the hexadecimal
732
723
* digits represent a value that does not fit into a `Byte`.
733
724
*/
734
- @ExperimentalStdlibApi
725
+ // @ExperimentalStdlibApi
735
726
// @SinceKotlin("1.9")
736
727
private fun String.hexToByte (startIndex : Int = 0, endIndex : Int = length, format : HexFormat = HexFormat .Default ): Byte =
737
728
hexToIntImpl(startIndex, endIndex, format, typeHexLength = 2 ).toByte()
@@ -758,8 +749,8 @@ private fun String.hexToByte(startIndex: Int = 0, endIndex: Int = length, format
758
749
*
759
750
* @sample samples.text.HexFormats.Extensions.shortToHexString
760
751
*/
761
- @ExperimentalStdlibApi
762
- @SinceKotlin(" 1.9 " )
752
+ @WasExperimental( ExperimentalStdlibApi :: class )
753
+ @SinceKotlin(" 2.2 " )
763
754
public fun Short.toHexString (format : HexFormat = HexFormat .Default ): String {
764
755
val digits = if (format.upperCase) UPPER_CASE_HEX_DIGITS else LOWER_CASE_HEX_DIGITS
765
756
val numberFormat = format.number
@@ -803,8 +794,8 @@ public fun Short.toHexString(format: HexFormat = HexFormat.Default): String {
803
794
*
804
795
* @sample samples.text.HexFormats.Extensions.hexToShort
805
796
*/
806
- @ExperimentalStdlibApi
807
- @SinceKotlin(" 1.9 " )
797
+ @WasExperimental( ExperimentalStdlibApi :: class )
798
+ @SinceKotlin(" 2.2 " )
808
799
public fun String.hexToShort (format : HexFormat = HexFormat .Default ): Short = hexToShort(0 , length, format)
809
800
810
801
/* *
@@ -831,7 +822,7 @@ public fun String.hexToShort(format: HexFormat = HexFormat.Default): Short = hex
831
822
* @throws IllegalArgumentException if the substring does not conform to the specified [format], or if the hexadecimal
832
823
* digits represent a value that does not fit into a `Short`.
833
824
*/
834
- @ExperimentalStdlibApi
825
+ // @ExperimentalStdlibApi
835
826
// @SinceKotlin("1.9")
836
827
private fun String.hexToShort (startIndex : Int = 0, endIndex : Int = length, format : HexFormat = HexFormat .Default ): Short =
837
828
hexToIntImpl(startIndex, endIndex, format, typeHexLength = 4 ).toShort()
@@ -858,8 +849,8 @@ private fun String.hexToShort(startIndex: Int = 0, endIndex: Int = length, forma
858
849
*
859
850
* @sample samples.text.HexFormats.Extensions.intToHexString
860
851
*/
861
- @ExperimentalStdlibApi
862
- @SinceKotlin(" 1.9 " )
852
+ @WasExperimental( ExperimentalStdlibApi :: class )
853
+ @SinceKotlin(" 2.2 " )
863
854
public fun Int.toHexString (format : HexFormat = HexFormat .Default ): String {
864
855
val digits = if (format.upperCase) UPPER_CASE_HEX_DIGITS else LOWER_CASE_HEX_DIGITS
865
856
val numberFormat = format.number
@@ -907,8 +898,8 @@ public fun Int.toHexString(format: HexFormat = HexFormat.Default): String {
907
898
*
908
899
* @sample samples.text.HexFormats.Extensions.hexToInt
909
900
*/
910
- @ExperimentalStdlibApi
911
- @SinceKotlin(" 1.9 " )
901
+ @WasExperimental( ExperimentalStdlibApi :: class )
902
+ @SinceKotlin(" 2.2 " )
912
903
public fun String.hexToInt (format : HexFormat = HexFormat .Default ): Int = hexToInt(0 , length, format)
913
904
914
905
/* *
@@ -935,7 +926,7 @@ public fun String.hexToInt(format: HexFormat = HexFormat.Default): Int = hexToIn
935
926
* @throws IllegalArgumentException if the substring does not conform to the specified [format], or if the hexadecimal
936
927
* digits represent a value that does not fit into an `Int`.
937
928
*/
938
- @ExperimentalStdlibApi
929
+ // @ExperimentalStdlibApi
939
930
// @SinceKotlin("1.9")
940
931
internal fun String.hexToInt (startIndex : Int = 0, endIndex : Int = length, format : HexFormat = HexFormat .Default ): Int =
941
932
hexToIntImpl(startIndex, endIndex, format, typeHexLength = 8 )
@@ -962,8 +953,8 @@ internal fun String.hexToInt(startIndex: Int = 0, endIndex: Int = length, format
962
953
*
963
954
* @sample samples.text.HexFormats.Extensions.longToHexString
964
955
*/
965
- @ExperimentalStdlibApi
966
- @SinceKotlin(" 1.9 " )
956
+ @WasExperimental( ExperimentalStdlibApi :: class )
957
+ @SinceKotlin(" 2.2 " )
967
958
public fun Long.toHexString (format : HexFormat = HexFormat .Default ): String {
968
959
val digits = if (format.upperCase) UPPER_CASE_HEX_DIGITS else LOWER_CASE_HEX_DIGITS
969
960
val numberFormat = format.number
@@ -1019,8 +1010,8 @@ public fun Long.toHexString(format: HexFormat = HexFormat.Default): String {
1019
1010
*
1020
1011
* @sample samples.text.HexFormats.Extensions.hexToLong
1021
1012
*/
1022
- @ExperimentalStdlibApi
1023
- @SinceKotlin(" 1.9 " )
1013
+ @WasExperimental( ExperimentalStdlibApi :: class )
1014
+ @SinceKotlin(" 2.2 " )
1024
1015
public fun String.hexToLong (format : HexFormat = HexFormat .Default ): Long = hexToLong(0 , length, format)
1025
1016
1026
1017
/* *
@@ -1047,14 +1038,13 @@ public fun String.hexToLong(format: HexFormat = HexFormat.Default): Long = hexTo
1047
1038
* @throws IllegalArgumentException if the substring does not conform to the specified [format], or if the hexadecimal
1048
1039
* digits represent a value that does not fit into a `Long`.
1049
1040
*/
1050
- @ExperimentalStdlibApi
1041
+ // @ExperimentalStdlibApi
1051
1042
// @SinceKotlin("1.9")
1052
1043
internal fun String.hexToLong (startIndex : Int = 0, endIndex : Int = length, format : HexFormat = HexFormat .Default ): Long =
1053
1044
hexToLongImpl(startIndex, endIndex, format, typeHexLength = 16 )
1054
1045
1055
1046
// -------------------------- private format and parse functions --------------------------
1056
1047
1057
- @ExperimentalStdlibApi
1058
1048
private fun Long.toHexStringImpl (numberFormat : HexFormat .NumberHexFormat , digits : String , bits : Int ): String {
1059
1049
require(bits and 0x3 == 0 )
1060
1050
@@ -1102,7 +1092,6 @@ private fun String.toCharArrayIfNotEmpty(destination: CharArray, destinationOffs
1102
1092
return destinationOffset + length
1103
1093
}
1104
1094
1105
- @ExperimentalStdlibApi
1106
1095
private fun String.hexToIntImpl (startIndex : Int , endIndex : Int , format : HexFormat , typeHexLength : Int ): Int {
1107
1096
AbstractList .checkBoundsIndexes(startIndex, endIndex, length)
1108
1097
@@ -1120,7 +1109,6 @@ private fun String.hexToIntImpl(startIndex: Int, endIndex: Int, format: HexForma
1120
1109
return parseInt(startIndex + prefix.length, endIndex - suffix.length)
1121
1110
}
1122
1111
1123
- @ExperimentalStdlibApi
1124
1112
private fun String.hexToLongImpl (startIndex : Int , endIndex : Int , format : HexFormat , typeHexLength : Int ): Long {
1125
1113
AbstractList .checkBoundsIndexes(startIndex, endIndex, length)
1126
1114
0 commit comments