Add @JvmStatic and @JvmOverloads to more cache methods

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 3 years ago
parent bf12f41faf
commit bcc2fdf48e
  1. 2
      cache/src/main/kotlin/org/openrs2/cache/Cache.kt
  2. 2
      cache/src/main/kotlin/org/openrs2/cache/ChecksumTable.kt
  3. 3
      cache/src/main/kotlin/org/openrs2/cache/DiskStore.kt
  4. 2
      cache/src/main/kotlin/org/openrs2/cache/FlatFileStore.kt
  5. 1
      cache/src/main/kotlin/org/openrs2/cache/JagArchive.kt
  6. 1
      cache/src/main/kotlin/org/openrs2/cache/Js5CompressionType.kt
  7. 1
      cache/src/main/kotlin/org/openrs2/cache/Js5Index.kt
  8. 3
      cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt
  9. 6
      cache/src/main/kotlin/org/openrs2/cache/Js5Pack.kt
  10. 1
      cache/src/main/kotlin/org/openrs2/cache/Js5Protocol.kt
  11. 1
      cache/src/main/kotlin/org/openrs2/cache/Store.kt
  12. 1
      cache/src/main/kotlin/org/openrs2/cache/VersionList.kt

@ -250,6 +250,7 @@ public class Cache private constructor(
public const val MAX_ARCHIVE: Int = 254 public const val MAX_ARCHIVE: Int = 254
@JvmOverloads @JvmOverloads
@JvmStatic
public fun open( public fun open(
root: Path, root: Path,
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT,
@ -259,6 +260,7 @@ public class Cache private constructor(
} }
@JvmOverloads @JvmOverloads
@JvmStatic
public fun open( public fun open(
store: Store, store: Store,
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT,

@ -21,6 +21,7 @@ public class ChecksumTable(
} }
public companion object { public companion object {
@JvmStatic
public fun create(store: Store): ChecksumTable { public fun create(store: Store): ChecksumTable {
val table = ChecksumTable() val table = ChecksumTable()
@ -46,6 +47,7 @@ public class ChecksumTable(
return table return table
} }
@JvmStatic
public fun read(buf: ByteBuf): ChecksumTable { public fun read(buf: ByteBuf): ChecksumTable {
val table = ChecksumTable() val table = ChecksumTable()

@ -501,6 +501,7 @@ public class DiskStore private constructor(
} }
@JvmOverloads @JvmOverloads
@JvmStatic
public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store {
val js5DataPath = dataPath(root) val js5DataPath = dataPath(root)
val legacyDataPath = legacyDataPath(root) val legacyDataPath = legacyDataPath(root)
@ -549,6 +550,8 @@ public class DiskStore private constructor(
return DiskStore(root, data, musicData, archives, alloc, legacy) return DiskStore(root, data, musicData, archives, alloc, legacy)
} }
@JvmOverloads
@JvmStatic
public fun create( public fun create(
root: Path, root: Path,
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT,

@ -129,6 +129,7 @@ public class FlatFileStore private constructor(
private const val GROUP_EXTENSION = ".dat" private const val GROUP_EXTENSION = ".dat"
@JvmOverloads @JvmOverloads
@JvmStatic
public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store {
if (!Files.isDirectory(root)) { if (!Files.isDirectory(root)) {
throw FileNotFoundException() throw FileNotFoundException()
@ -138,6 +139,7 @@ public class FlatFileStore private constructor(
} }
@JvmOverloads @JvmOverloads
@JvmStatic
public fun create(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { public fun create(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store {
Files.createDirectories(root) Files.createDirectories(root)
return FlatFileStore(root, alloc) return FlatFileStore(root, alloc)

@ -230,6 +230,7 @@ public class JagArchive : Closeable {
* @param buf the compressed archive. * @param buf the compressed archive.
* @return the unpacked archive. * @return the unpacked archive.
*/ */
@JvmStatic
public fun unpack(buf: ByteBuf): JagArchive { public fun unpack(buf: ByteBuf): JagArchive {
val archive = JagArchive() val archive = JagArchive()

@ -41,6 +41,7 @@ public enum class Js5CompressionType {
public companion object { public companion object {
private val values = values() private val values = values()
@JvmStatic
public fun fromOrdinal(ordinal: Int): Js5CompressionType? { public fun fromOrdinal(ordinal: Int): Js5CompressionType? {
return if (ordinal >= 0 && ordinal < values.size) { return if (ordinal >= 0 && ordinal < values.size) {
values[ordinal] values[ordinal]

@ -280,6 +280,7 @@ public class Js5Index(
private const val FLAG_LENGTHS = 0x04 private const val FLAG_LENGTHS = 0x04
private const val FLAG_UNCOMPRESSED_CHECKSUMS = 0x08 private const val FLAG_UNCOMPRESSED_CHECKSUMS = 0x08
@JvmStatic
public fun read(buf: ByteBuf): Js5Index { public fun read(buf: ByteBuf): Js5Index {
val number = buf.readUnsignedByte().toInt() val number = buf.readUnsignedByte().toInt()
val protocol = Js5Protocol.fromId(number) val protocol = Js5Protocol.fromId(number)

@ -118,6 +118,7 @@ public data class Js5MasterIndex(
public companion object { public companion object {
private const val SIGNATURE_LENGTH = Whirlpool.DIGESTBYTES + 1 private const val SIGNATURE_LENGTH = Whirlpool.DIGESTBYTES + 1
@JvmStatic
public fun create(store: Store): Js5MasterIndex { public fun create(store: Store): Js5MasterIndex {
val masterIndex = Js5MasterIndex(MasterIndexFormat.ORIGINAL) val masterIndex = Js5MasterIndex(MasterIndexFormat.ORIGINAL)
@ -181,10 +182,12 @@ public data class Js5MasterIndex(
} }
@JvmOverloads @JvmOverloads
@JvmStatic
public fun read(buf: ByteBuf, format: MasterIndexFormat, key: RSAKeyParameters? = null): Js5MasterIndex { public fun read(buf: ByteBuf, format: MasterIndexFormat, key: RSAKeyParameters? = null): Js5MasterIndex {
return read(buf, format, key, true) return read(buf, format, key, true)
} }
@JvmStatic
public fun readUnverified(buf: ByteBuf, format: MasterIndexFormat): Js5MasterIndex { public fun readUnverified(buf: ByteBuf, format: MasterIndexFormat): Js5MasterIndex {
return read(buf, format, null, false) return read(buf, format, null, false)
} }

@ -91,6 +91,8 @@ public class Js5Pack private constructor(
} }
public companion object { public companion object {
@JvmOverloads
@JvmStatic
public fun create( public fun create(
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT,
unpackedCacheSize: Int = UnpackedCache.DEFAULT_CAPACITY unpackedCacheSize: Int = UnpackedCache.DEFAULT_CAPACITY
@ -107,6 +109,8 @@ public class Js5Pack private constructor(
} }
} }
@JvmOverloads
@JvmStatic
public fun read( public fun read(
path: Path, path: Path,
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT,
@ -117,6 +121,8 @@ public class Js5Pack private constructor(
} }
} }
@JvmOverloads
@JvmStatic
public fun read( public fun read(
input: InputStream, input: InputStream,
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT,

@ -12,6 +12,7 @@ public enum class Js5Protocol {
private const val OFFSET = 5 private const val OFFSET = 5
private val values = values() private val values = values()
@JvmStatic
public fun fromId(id: Int): Js5Protocol? { public fun fromId(id: Int): Js5Protocol? {
val ordinal = id - OFFSET val ordinal = id - OFFSET
return if (ordinal >= 0 && ordinal < values.size) { return if (ordinal >= 0 && ordinal < values.size) {

@ -136,6 +136,7 @@ public interface Store : Flushable, Closeable {
* @throws IOException if an underlying I/O error occurs. * @throws IOException if an underlying I/O error occurs.
*/ */
@JvmOverloads @JvmOverloads
@JvmStatic
public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store {
val hasDataFile = Files.isRegularFile(DiskStore.dataPath(root)) val hasDataFile = Files.isRegularFile(DiskStore.dataPath(root))
val hasLegacyDataFile = Files.isRegularFile(DiskStore.legacyDataPath(root)) val hasLegacyDataFile = Files.isRegularFile(DiskStore.legacyDataPath(root))

@ -20,6 +20,7 @@ public class VersionList(
public companion object { public companion object {
private val NAMES = listOf("model", "anim", "midi", "map") private val NAMES = listOf("model", "anim", "midi", "map")
@JvmStatic
public fun read(archive: JagArchive): VersionList { public fun read(archive: JagArchive): VersionList {
val files = mutableListOf<List<File>>() val files = mutableListOf<List<File>>()

Loading…
Cancel
Save