Class ByteBuffer

java.lang.Object
org.miaixz.bus.core.io.ByteString
org.miaixz.bus.core.io.buffer.ByteBuffer
All Implemented Interfaces:
Serializable, Comparable<ByteString>

public class ByteBuffer extends ByteString
由字节数组段组成的不可变字节字符串 该类的存在是为了实现 缓冲区的有效快照 它被实现为一个段数组,加上一个目录 两个半部分,描述段如何组成这个字节字符串
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • ByteBuffer

      public ByteBuffer(Buffer buffer, int byteCount)
  • Method Details

    • utf8

      public String utf8()
      Description copied from class: ByteString
      Constructs a new String by decoding the bytes as UTF-8.
      Overrides:
      utf8 in class ByteString
    • string

      public String string(Charset charset)
      Overrides:
      string in class ByteString
    • base64

      public String base64()
      Description copied from class: ByteString
      Returns this byte string encoded as Base64. In violation of the RFC, the returned string does not wrap lines at 76 columns.
      Overrides:
      base64 in class ByteString
    • hex

      public String hex()
      Description copied from class: ByteString
      Returns this byte string encoded in hexadecimal.
      Overrides:
      hex in class ByteString
    • toAsciiLowercase

      public ByteString toAsciiLowercase()
      Description copied from class: ByteString
      Returns a byte string equal to this byte string, but with the bytes 'A' through 'Z' replaced with the corresponding byte in 'a' through 'z'. Returns this byte string if it contains no bytes in 'A' through 'Z'.
      Overrides:
      toAsciiLowercase in class ByteString
    • toAsciiUppercase

      public ByteString toAsciiUppercase()
      Description copied from class: ByteString
      Returns a byte string equal to this byte string, but with the bytes 'a' through 'z' replaced with the corresponding byte in 'A' through 'Z'. Returns this byte string if it contains no bytes in 'a' through 'z'.
      Overrides:
      toAsciiUppercase in class ByteString
    • md5

      public ByteString md5()
      Description copied from class: ByteString
      Returns the 128-bit MD5 hash of this byte string.
      Overrides:
      md5 in class ByteString
    • sha1

      public ByteString sha1()
      Description copied from class: ByteString
      Returns the 160-bit SHA-1 hash of this byte string.
      Overrides:
      sha1 in class ByteString
    • sha256

      public ByteString sha256()
      Description copied from class: ByteString
      Returns the 256-bit SHA-256 hash of this byte string.
      Overrides:
      sha256 in class ByteString
    • hmacSha1

      public ByteString hmacSha1(ByteString key)
      Description copied from class: ByteString
      Returns the 160-bit SHA-1 HMAC of this byte string.
      Overrides:
      hmacSha1 in class ByteString
    • hmacSha256

      public ByteString hmacSha256(ByteString key)
      Description copied from class: ByteString
      Returns the 256-bit SHA-256 HMAC of this byte string.
      Overrides:
      hmacSha256 in class ByteString
    • base64Url

      public String base64Url()
      Description copied from class: ByteString
      Returns this byte string encoded as URL-safe Base64.
      Overrides:
      base64Url in class ByteString
    • substring

      public ByteString substring(int beginIndex)
      Description copied from class: ByteString
      Returns a byte string that is a substring of this byte string, beginning at the specified index until the end of this string. Returns this byte string if beginIndex is 0.
      Overrides:
      substring in class ByteString
    • substring

      public ByteString substring(int beginIndex, int endIndex)
      Description copied from class: ByteString
      Returns a byte string that is a substring of this byte string, beginning at the specified beginIndex and ends at the specified endIndex. Returns this byte string if beginIndex is 0 and endIndex is the length of this byte string.
      Overrides:
      substring in class ByteString
    • getByte

      public byte getByte(int pos)
      Description copied from class: ByteString
      Returns the byte at pos.
      Overrides:
      getByte in class ByteString
    • size

      public int size()
      Description copied from class: ByteString
      Returns the number of bytes in this ByteString.
      Overrides:
      size in class ByteString
    • toByteArray

      public byte[] toByteArray()
      Description copied from class: ByteString
      Returns a byte array containing a copy of the bytes in this ByteString.
      Overrides:
      toByteArray in class ByteString
    • asByteBuffer

      public ByteBuffer asByteBuffer()
      Description copied from class: ByteString
      Returns a ByteBuffer view of the bytes in this ByteString.
      Overrides:
      asByteBuffer in class ByteString
    • write

      public void write(OutputStream out) throws IOException
      Description copied from class: ByteString
      Writes the contents of this byte string to out.
      Overrides:
      write in class ByteString
      Throws:
      IOException
    • write

      public void write(Buffer buffer)
      Description copied from class: ByteString
      Writes the contents of this byte string to buffer.
      Overrides:
      write in class ByteString
    • rangeEquals

      public boolean rangeEquals(int offset, ByteString other, int otherOffset, int byteCount)
      Description copied from class: ByteString
      Returns true if the bytes of this in [offset..offset+byteCount) equal the bytes of other in [otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds.
      Overrides:
      rangeEquals in class ByteString
    • rangeEquals

      public boolean rangeEquals(int offset, byte[] other, int otherOffset, int byteCount)
      Description copied from class: ByteString
      Returns true if the bytes of this in [offset..offset+byteCount) equal the bytes of other in [otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds.
      Overrides:
      rangeEquals in class ByteString
    • indexOf

      public int indexOf(byte[] other, int fromIndex)
      Overrides:
      indexOf in class ByteString
    • lastIndexOf

      public int lastIndexOf(byte[] other, int fromIndex)
      Overrides:
      lastIndexOf in class ByteString
    • internalArray

      public byte[] internalArray()
      Description copied from class: ByteString
      Returns the bytes of this string without a defensive copy. Do not mutate!
      Overrides:
      internalArray in class ByteString
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class ByteString
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ByteString
    • toString

      public String toString()
      Overrides:
      toString in class Object