Package io.keikai.doc.collab.lib0
Class Buffer
java.lang.Object
io.keikai.doc.collab.lib0.Buffer
Utility functions to work with buffers (Uint8Array).
-
Method Summary
Modifier and TypeMethodDescriptionstatic Uint8ArraycopyUint8Array(Uint8Array uint8Array) Copy the content of an Uint8Array view to a new ArrayBuffer.static Uint8ArraycreateUint8ArrayFromArrayBuffer(byte[] buffer) Create Uint8Array with initial content from bufferstatic Uint8ArraycreateUint8ArrayFromLen(int len) static Uint8ArraycreateUint8ArrayViewFromArrayBuffer(byte[] buffer, int byteOffset, int length) Create Uint8Array with initial content from bufferstatic ObjectdecodeAny(Uint8Array buf) Decode an any-encoded value.static Uint8ArrayEncode anything as a UInt8Array.static Uint8ArrayfromBase64(String s) static Uint8ArrayfromBase64UrlEncoded(String base64) static Uint8ArrayfromHexString(String hex) Note: This function expects that the hex doesn't start with 0x.static StringtoBase64(Uint8Array bytes) static StringImplements base64url - see https://datatracker.ietf.org/doc/html/rfc4648#section-5static StringtoHexString(Uint8Array buf) Base64 is always a more efficient choice.
-
Method Details
-
createUint8ArrayFromLen
- Parameters:
len-- Returns:
-
createUint8ArrayViewFromArrayBuffer
public static Uint8Array createUint8ArrayViewFromArrayBuffer(byte[] buffer, int byteOffset, int length) Create Uint8Array with initial content from buffer- Parameters:
buffer-byteOffset-length-- Returns:
-
createUint8ArrayFromArrayBuffer
Create Uint8Array with initial content from buffer- Parameters:
buffer-- Returns:
-
toBase64
-
fromBase64
-
toBase64UrlEncoded
Implements base64url - see https://datatracker.ietf.org/doc/html/rfc4648#section-5- Parameters:
buf-- Returns:
-
fromBase64UrlEncoded
- Parameters:
base64-- Returns:
-
toHexString
Base64 is always a more efficient choice. This exists for utility purposes only.- Parameters:
buf-- Returns:
-
fromHexString
Note: This function expects that the hex doesn't start with 0x.- Parameters:
hex-- Returns:
-
copyUint8Array
Copy the content of an Uint8Array view to a new ArrayBuffer.- Parameters:
uint8Array-- Returns:
-
encodeAny
Encode anything as a UInt8Array.- Parameters:
data-- Returns:
-
decodeAny
Decode an any-encoded value.- Parameters:
buf-- Returns:
-