From 905d881564af4893b108221feab40909d99979d3 Mon Sep 17 00:00:00 2001 From: xdark Date: Fri, 12 Apr 2024 01:27:45 +0300 Subject: [PATCH] Rename LazyByteData to LazyMemorySegment --- .../format/model/AbstractZipFileHeader.java | 6 +++--- .../format/model/AdaptingLocalFileHeader.java | 10 +++++----- .../model/CentralDirectoryFileHeader.java | 4 ++-- .../lljzip/format/model/LocalFileHeader.java | 4 ++-- .../coley/lljzip/util/MemorySegmentUtil.java | 18 +++++++++--------- ...azyByteData.java => LazyMemorySegment.java} | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) rename src/main/java/software/coley/lljzip/util/lazy/{LazyByteData.java => LazyMemorySegment.java} (78%) diff --git a/src/main/java/software/coley/lljzip/format/model/AbstractZipFileHeader.java b/src/main/java/software/coley/lljzip/format/model/AbstractZipFileHeader.java index 6bc5134..9063c9a 100644 --- a/src/main/java/software/coley/lljzip/format/model/AbstractZipFileHeader.java +++ b/src/main/java/software/coley/lljzip/format/model/AbstractZipFileHeader.java @@ -3,7 +3,7 @@ import software.coley.lljzip.format.compression.Decompressor; import software.coley.lljzip.format.compression.ZipCompressions; import software.coley.lljzip.util.MemorySegmentUtil; -import software.coley.lljzip.util.lazy.LazyByteData; +import software.coley.lljzip.util.lazy.LazyMemorySegment; import software.coley.lljzip.util.lazy.LazyInt; import software.coley.lljzip.util.lazy.LazyLong; @@ -28,8 +28,8 @@ public abstract class AbstractZipFileHeader implements ZipPart, ZipRead { protected LazyLong uncompressedSize; protected LazyInt fileNameLength; protected LazyInt extraFieldLength; - protected LazyByteData fileName; - protected LazyByteData extraField; + protected LazyMemorySegment fileName; + protected LazyMemorySegment extraField; // Offset into the data this part is read from protected transient long offset = -1L; diff --git a/src/main/java/software/coley/lljzip/format/model/AdaptingLocalFileHeader.java b/src/main/java/software/coley/lljzip/format/model/AdaptingLocalFileHeader.java index fb193a3..3f9d6af 100644 --- a/src/main/java/software/coley/lljzip/format/model/AdaptingLocalFileHeader.java +++ b/src/main/java/software/coley/lljzip/format/model/AdaptingLocalFileHeader.java @@ -1,6 +1,6 @@ package software.coley.lljzip.format.model; -import software.coley.lljzip.util.lazy.LazyByteData; +import software.coley.lljzip.util.lazy.LazyMemorySegment; import software.coley.lljzip.util.lazy.LazyInt; import software.coley.lljzip.util.lazy.LazyLong; @@ -44,19 +44,19 @@ public AdaptingLocalFileHeader(@Nonnull ZipFile archive, @Nonnull ZipEntry entry lastModFileTime = new LazyInt(() -> 0); lastModFileDate = new LazyInt(() -> 0); fileNameLength = new LazyInt(entryName::length); - fileName = new LazyByteData(() -> MemorySegment.ofArray(entryName.getBytes())); + fileName = new LazyMemorySegment(() -> MemorySegment.ofArray(entryName.getBytes())); fileDataLength = new LazyLong(() -> entryData.length); - fileData = new LazyByteData(() -> MemorySegment.ofArray(entryData)); + fileData = new LazyMemorySegment(() -> MemorySegment.ofArray(entryData)); compressionMethod = new LazyInt(() -> 0); uncompressedSize = new LazyLong(() -> entryData.length); compressedSize = new LazyLong(() -> entryData.length); crc32 = new LazyInt(() -> (int) entry.getCrc()); if (extra != null) { extraFieldLength = new LazyInt(() -> extra.length); - extraField = new LazyByteData(() -> MemorySegment.ofArray(extra)); + extraField = new LazyMemorySegment(() -> MemorySegment.ofArray(extra)); } else { extraFieldLength = new LazyInt(() -> 0); - extraField = new LazyByteData(() -> MemorySegment.ofArray(new byte[0])); + extraField = new LazyMemorySegment(() -> MemorySegment.ofArray(new byte[0])); } data = MemorySegment.ofArray(new byte[0]); } diff --git a/src/main/java/software/coley/lljzip/format/model/CentralDirectoryFileHeader.java b/src/main/java/software/coley/lljzip/format/model/CentralDirectoryFileHeader.java index c3f39bc..399b844 100644 --- a/src/main/java/software/coley/lljzip/format/model/CentralDirectoryFileHeader.java +++ b/src/main/java/software/coley/lljzip/format/model/CentralDirectoryFileHeader.java @@ -1,7 +1,7 @@ package software.coley.lljzip.format.model; import software.coley.lljzip.util.MemorySegmentUtil; -import software.coley.lljzip.util.lazy.LazyByteData; +import software.coley.lljzip.util.lazy.LazyMemorySegment; import software.coley.lljzip.util.lazy.LazyInt; import software.coley.lljzip.util.lazy.LazyLong; @@ -43,7 +43,7 @@ public class CentralDirectoryFileHeader extends AbstractZipFileHeader { // CentralDirectoryFileHeader spec (plus common elements between this and local file) private LazyInt versionMadeBy; private LazyInt fileCommentLength; - private LazyByteData fileComment; + private LazyMemorySegment fileComment; private LazyInt diskNumberStart; private LazyInt internalFileAttributes; private LazyInt externalFileAttributes; diff --git a/src/main/java/software/coley/lljzip/format/model/LocalFileHeader.java b/src/main/java/software/coley/lljzip/format/model/LocalFileHeader.java index 18ed88c..e5fa62c 100644 --- a/src/main/java/software/coley/lljzip/format/model/LocalFileHeader.java +++ b/src/main/java/software/coley/lljzip/format/model/LocalFileHeader.java @@ -3,7 +3,7 @@ import software.coley.lljzip.format.compression.Decompressor; import software.coley.lljzip.format.read.ZipReader; import software.coley.lljzip.util.MemorySegmentUtil; -import software.coley.lljzip.util.lazy.LazyByteData; +import software.coley.lljzip.util.lazy.LazyMemorySegment; import software.coley.lljzip.util.lazy.LazyInt; import software.coley.lljzip.util.lazy.LazyLong; @@ -42,7 +42,7 @@ public class LocalFileHeader extends AbstractZipFileHeader { protected transient CentralDirectoryFileHeader linkedDirectoryFileHeader; // LocalFileHeader spec (plus common elements between this and central file) - protected LazyByteData fileData; + protected LazyMemorySegment fileData; // Caches protected transient LazyLong fileDataLength; diff --git a/src/main/java/software/coley/lljzip/util/MemorySegmentUtil.java b/src/main/java/software/coley/lljzip/util/MemorySegmentUtil.java index 909ba88..70b87c6 100644 --- a/src/main/java/software/coley/lljzip/util/MemorySegmentUtil.java +++ b/src/main/java/software/coley/lljzip/util/MemorySegmentUtil.java @@ -1,7 +1,7 @@ package software.coley.lljzip.util; import software.coley.lljzip.format.model.ZipPart; -import software.coley.lljzip.util.lazy.LazyByteData; +import software.coley.lljzip.util.lazy.LazyMemorySegment; import software.coley.lljzip.util.lazy.LazyInt; import software.coley.lljzip.util.lazy.LazyLong; @@ -399,8 +399,8 @@ public static LazyLong readLazyMaskedLongQuad(MemorySegment data, long headerOff * * @return Lazily populated slice. */ - public static LazyByteData readLazySlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyInt length) { - return new LazyByteData(() -> { + public static LazyMemorySegment readLazySlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyInt length) { + return new LazyMemorySegment(() -> { return data.asSlice(headerOffset + localOffset.get(), length.get()); }); } @@ -415,8 +415,8 @@ public static LazyByteData readLazySlice(MemorySegment data, long headerOffset, * * @return Lazily populated long slice. */ - public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyLong length) { - return new LazyByteData(() -> { + public static LazyMemorySegment readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyLong length) { + return new LazyMemorySegment(() -> { return data.asSlice(headerOffset + localOffset.get(), length.get()); }); } @@ -431,8 +431,8 @@ public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffs * * @return Lazily populated long slice. */ - public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffset, LazyLong localOffset, LazyLong length) { - return new LazyByteData(() -> { + public static LazyMemorySegment readLazyLongSlice(MemorySegment data, long headerOffset, LazyLong localOffset, LazyLong length) { + return new LazyMemorySegment(() -> { return data.asSlice(headerOffset + localOffset.get(), length.get()); }); } @@ -447,8 +447,8 @@ public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffs * * @return Lazily populated long slice. */ - public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, long length) { - return new LazyByteData(() -> { + public static LazyMemorySegment readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, long length) { + return new LazyMemorySegment(() -> { return data.asSlice(headerOffset + localOffset.get(), length); }); } diff --git a/src/main/java/software/coley/lljzip/util/lazy/LazyByteData.java b/src/main/java/software/coley/lljzip/util/lazy/LazyMemorySegment.java similarity index 78% rename from src/main/java/software/coley/lljzip/util/lazy/LazyByteData.java rename to src/main/java/software/coley/lljzip/util/lazy/LazyMemorySegment.java index 4aea330..983f2fb 100644 --- a/src/main/java/software/coley/lljzip/util/lazy/LazyByteData.java +++ b/src/main/java/software/coley/lljzip/util/lazy/LazyMemorySegment.java @@ -8,14 +8,14 @@ /** * Lazy {@link MemorySegment} getter. */ -public class LazyByteData extends Lazy> { +public class LazyMemorySegment extends Lazy> { private MemorySegment value; /** * @param lookup * Lazy lookup. */ - public LazyByteData(@Nonnull Supplier lookup) { + public LazyMemorySegment(@Nonnull Supplier lookup) { super(lookup); } @@ -23,8 +23,8 @@ public LazyByteData(@Nonnull Supplier lookup) { * @return Copy. */ @Nonnull - public LazyByteData copy() { - LazyByteData copy = new LazyByteData(lookup); + public LazyMemorySegment copy() { + LazyMemorySegment copy = new LazyMemorySegment(lookup); copy.id = id; if (set) copy.set(value); return copy; @@ -61,7 +61,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - LazyByteData that = (LazyByteData) o; + LazyMemorySegment that = (LazyMemorySegment) o; return Objects.equals(get(), that.get()); }