-
- All Superinterfaces:
Streamable
- All Known Subinterfaces:
SignatureWithPublicKeyRecovery
- All Known Implementing Classes:
BinaryType
,CryptoBinary
,EncryptedData
,Hash
,SignatureBinary
,SignatureEcBc
,SignatureEcBcPlain
,SignatureEcBcWithRecoveryId
,SignatureGeneric
,SignatureRsa
public interface Binary extends Streamable
Interface for smaller binary data (e.g. a cryptographic signature). Implementations shall be immutable.
Attention:
This API is designed for smaller binary data and will cause it to be fully loaded into memory (Java heap). For binary large objects (BLOB) (e.g. for generic files or documents) use other solutions like e.g.Blob
.- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
EMPTY_BYTE_ARRAY
An empty byte array (no data).
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
format(BinaryCodec codec)
This method avoids anarray-copy
ofgetData()
and is therefore more efficient than usingBinaryCodec
.encode
(getData()
).
ATTENTION:
Sub-types often represent sensible data.default String
formatBase64()
ATTENTION:
Sub-types often represent sensible data.default String
formatHex()
ATTENTION:
Sub-types often represent sensible data.byte[]
getData()
ATTENTION:
Sub-types often represent sensible data.void
getData(byte[] buffer, int offset)
Copies thedata
into the given buffer.byte
getDataByte(int index)
int
getLength()
boolean
isZeros()
-
Methods inherited from interface io.github.mmm.binary.Streamable
asStream, save
-
-
-
-
Method Detail
-
getDataByte
byte getDataByte(int index)
-
getData
byte[] getData()
ATTENTION:
Sub-types often represent sensible data. Be careful to pass these data in raw form (unencrypted).- Returns:
- the raw encoded data. Array will be copied to prevent manipulation. Hence, this method is expensive and subsequent calls shall be avoided.
-
getData
void getData(byte[] buffer, int offset)
Copies thedata
into the given buffer.- Parameters:
buffer
- the byte array to copy the data to. Has to have enough capacity left for thelength
of this BLOB.offset
- the index where to start copying tobuffer
.
-
getLength
int getLength()
- Returns:
- the length of this BLOB in bytes (array length of
getData()
).
-
format
String format(BinaryCodec codec)
This method avoids anarray-copy
ofgetData()
and is therefore more efficient than usingBinaryCodec
.encode
(getData()
).
ATTENTION:
Sub-types often represent sensible data. Be careful to pass the data in raw form (unencrypted).- Parameters:
codec
- theBinaryCodec
.- Returns:
- the
encoded
data
.
-
formatHex
default String formatHex()
ATTENTION:
Sub-types often represent sensible data. Be careful to pass the data in raw form (unencrypted).- Returns:
- a hex-dump of this BLOB. This form is more transparent but less compact to
base 64 representation
.
-
formatBase64
default String formatBase64()
ATTENTION:
Sub-types often represent sensible data. Be careful to pass the data in raw form (unencrypted).
-
isZeros
boolean isZeros()
- Returns:
true
if thedata
contains only zeros (0
values),false
otherwise.
-
-