Package org.aoju.bus.core.io.buffer
Class ByteBuffer
java.lang.Object
org.aoju.bus.core.io.ByteString
org.aoju.bus.core.io.buffer.ByteBuffer
- All Implemented Interfaces:
Serializable,Comparable<ByteString>
由字节数组段组成的不可变字节字符串 该类的存在是为了实现 缓冲区的有效快照 它被实现为一个段数组,加上一个目录 两个半部分,描述段如何组成这个字节字符串
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.aoju.bus.core.io.ByteString
data, EMPTY, hashCode, utf8 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns aByteBufferview of the bytes in thisByteString.base64()Returns this byte string encoded as Base64.Returns this byte string encoded as URL-safe Base64.booleanbytegetByte(int pos) Returns the byte atpos.inthashCode()hex()Returns this byte string encoded in hexadecimal.hmacSha1(ByteString key) Returns the 160-bit SHA-1 HMAC of this byte string.hmacSha256(ByteString key) Returns the 256-bit SHA-256 HMAC of this byte string.intindexOf(byte[] other, int fromIndex) byte[]Returns the bytes of this string without a defensive copy.intlastIndexOf(byte[] other, int fromIndex) md5()Returns the 128-bit MD5 hash of this byte string.booleanrangeEquals(int offset, byte[] other, int otherOffset, int byteCount) Returns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount).booleanrangeEquals(int offset, ByteString other, int otherOffset, int byteCount) Returns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount).sha1()Returns the 160-bit SHA-1 hash of this byte string.sha256()Returns the 256-bit SHA-256 hash of this byte string.intsize()Returns the number of bytes in this ByteString.substring(int beginIndex) Returns a byte string that is a substring of this byte string, beginning at the specified index until the end of this string.substring(int beginIndex, int endIndex) Returns a byte string that is a substring of this byte string, beginning at the specifiedbeginIndexand ends at the specifiedendIndex.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 a byte string equal to this byte string, but with the bytes 'a' through 'z' replaced with the corresponding byte in 'A' through 'Z'.byte[]Returns a byte array containing a copy of the bytes in thisByteString.toString()utf8()Constructs a newStringby decoding the bytes asUTF-8.voidwrite(OutputStream out) Writes the contents of this byte string toout.voidWrites the contents of this byte string tobuffer.Methods inherited from class org.aoju.bus.core.io.ByteString
compareTo, decodeBase64, decodeHex, encodeString, encodeUtf8, endsWith, endsWith, hmacSha512, indexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexOf, of, of, of, read, sha512, startsWith, startsWith
-
Constructor Details
-
ByteBuffer
-
-
Method Details
-
utf8
Description copied from class:ByteStringConstructs a newStringby decoding the bytes asUTF-8.- Overrides:
utf8in classByteString
-
string
- Overrides:
stringin classByteString
-
base64
Description copied from class:ByteStringReturns this byte string encoded as Base64. In violation of the RFC, the returned string does not wrap lines at 76 columns.- Overrides:
base64in classByteString
-
hex
Description copied from class:ByteStringReturns this byte string encoded in hexadecimal.- Overrides:
hexin classByteString
-
toAsciiLowercase
Description copied from class:ByteStringReturns 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:
toAsciiLowercasein classByteString
-
toAsciiUppercase
Description copied from class:ByteStringReturns 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:
toAsciiUppercasein classByteString
-
md5
Description copied from class:ByteStringReturns the 128-bit MD5 hash of this byte string.- Overrides:
md5in classByteString
-
sha1
Description copied from class:ByteStringReturns the 160-bit SHA-1 hash of this byte string.- Overrides:
sha1in classByteString
-
sha256
Description copied from class:ByteStringReturns the 256-bit SHA-256 hash of this byte string.- Overrides:
sha256in classByteString
-
hmacSha1
Description copied from class:ByteStringReturns the 160-bit SHA-1 HMAC of this byte string.- Overrides:
hmacSha1in classByteString
-
hmacSha256
Description copied from class:ByteStringReturns the 256-bit SHA-256 HMAC of this byte string.- Overrides:
hmacSha256in classByteString
-
base64Url
Description copied from class:ByteStringReturns this byte string encoded as URL-safe Base64.- Overrides:
base64Urlin classByteString
-
substring
Description copied from class:ByteStringReturns 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 ifbeginIndexis 0.- Overrides:
substringin classByteString
-
substring
Description copied from class:ByteStringReturns a byte string that is a substring of this byte string, beginning at the specifiedbeginIndexand ends at the specifiedendIndex. Returns this byte string ifbeginIndexis 0 andendIndexis the length of this byte string.- Overrides:
substringin classByteString
-
getByte
public byte getByte(int pos) Description copied from class:ByteStringReturns the byte atpos.- Overrides:
getBytein classByteString
-
size
public int size()Description copied from class:ByteStringReturns the number of bytes in this ByteString.- Overrides:
sizein classByteString
-
toByteArray
public byte[] toByteArray()Description copied from class:ByteStringReturns a byte array containing a copy of the bytes in thisByteString.- Overrides:
toByteArrayin classByteString
-
asByteBuffer
Description copied from class:ByteStringReturns aByteBufferview of the bytes in thisByteString.- Overrides:
asByteBufferin classByteString
-
write
Description copied from class:ByteStringWrites the contents of this byte string toout.- Overrides:
writein classByteString- Throws:
IOException
-
write
Description copied from class:ByteStringWrites the contents of this byte string tobuffer.- Overrides:
writein classByteString
-
rangeEquals
Description copied from class:ByteStringReturns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds.- Overrides:
rangeEqualsin classByteString
-
rangeEquals
public boolean rangeEquals(int offset, byte[] other, int otherOffset, int byteCount) Description copied from class:ByteStringReturns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds.- Overrides:
rangeEqualsin classByteString
-
indexOf
public int indexOf(byte[] other, int fromIndex) - Overrides:
indexOfin classByteString
-
lastIndexOf
public int lastIndexOf(byte[] other, int fromIndex) - Overrides:
lastIndexOfin classByteString
-
internalArray
public byte[] internalArray()Description copied from class:ByteStringReturns the bytes of this string without a defensive copy. Do not mutate!- Overrides:
internalArrayin classByteString
-
equals
- Overrides:
equalsin classByteString
-
hashCode
public int hashCode()- Overrides:
hashCodein classByteString
-
toString
-