public final class Blob extends Object implements FLEncodable
Modifier and Type | Field and Description |
---|---|
static String |
ENCODER_ARG_DB |
static String |
ENCODER_ARG_QUERY_PARAM |
Constructor and Description |
---|
Blob(String contentType,
byte[] content)
Construct a Blob with the given in-memory data.
|
Blob(String contentType,
InputStream stream)
Construct a Blob with the given stream of data.
|
Blob(String contentType,
URL fileURL)
Construct a Blob with the content of a file.
|
Modifier and Type | Method and Description |
---|---|
String |
digest()
The cryptographic digest of this Blob's contents, which uniquely identifies it.
|
void |
encodeTo(FLEncoder encoder)
This method is not part of the public API: Do not use it.
|
boolean |
equals(Object o)
Compare for equality.
|
byte[] |
getContent()
Gets the contents of this blob as in in-memory byte array.
|
InputStream |
getContentStream()
Get a the contents of this blob as a stream.
|
String |
getContentType()
Return the type of of the content this blob contains.
|
Map<String,Object> |
getProperties()
Get the blob metadata
|
int |
hashCode()
Get the blob hash code.
|
static boolean |
isBlob(Map<String,?> props) |
long |
length()
The number of byte of content this blob contains.
|
String |
toJSON() |
String |
toString()
Returns a string representation of the object.
|
public static final String ENCODER_ARG_DB
public static final String ENCODER_ARG_QUERY_PARAM
public Blob(@NonNull String contentType, @NonNull byte[] content)
contentType
- The type of content this Blob will representcontent
- The data that this Blob will containpublic Blob(@NonNull String contentType, @NonNull InputStream stream)
getContent
) or to the database.
If it is closed before that, by client code, the attempt to store the blob will fail.
The converse is also true: the stream for a blob that is not saved or copied to memory
will not be closed (except during garbage collection).contentType
- The type of content this Blob will representstream
- The stream of data that this Blob will consumepublic Blob(@NonNull String contentType, @NonNull URL fileURL) throws IOException
contentType
- The type of content this Blob will representfileURL
- A URL to a file containing the data that this Blob will represent.IOException
- on failure to open the file URL@Nullable public byte[] getContent()
@Nullable public InputStream getContentStream()
@NonNull public String getContentType()
@NonNull public String toJSON()
public long length()
@Nullable public String digest()
@NonNull public Map<String,Object> getProperties()
@Volatile public void encodeTo(@NonNull FLEncoder encoder)
encodeTo
in interface FLEncodable
encoder
- The FLEncoder to which to encode this object.@NonNull public String toString()
public int hashCode()
public boolean equals(Object o)