Class Binary
java.lang.Object
ch.tocco.nice2.persist.core.api.entity.Binary
- All Implemented Interfaces:
- AutoCloseable
- Direct Known Subclasses:
- BinaryEntityServiceValuePostProcessorTypeAdapter.ConvertibleBinary,- BinaryQueryParameter,- FileBackedBinary
Representation of a chunk of binary data.
- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructorsConstructorDescriptionBinary(long size, com.google.common.hash.HashCode hash, Binary.Store store, @Nullable String mimeType, @Nullable String fileExtension, BinaryHashingService.ToStringGenerator toStringGenerator) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Release any resources associated with this binary.booleanTwo binaries are equals if their contents are equal.protected voidfinalize()@Nullable StringReturns the file extension when available.@Nullable Binary.BinaryUrlcom.google.common.hash.HashCodehash()Get the hash code of the data.inthashCode()Return aninthash code for the data.booleanOpen an input stream to read the data.longsize()Return the size of this binary in bytes.toString()
- 
Constructor Details- 
Binarypublic Binary(long size, com.google.common.hash.HashCode hash, Binary.Store store, @Nullable @Nullable String mimeType, @Nullable @Nullable String fileExtension, BinaryHashingService.ToStringGenerator toStringGenerator) 
- 
Binary
 
- 
- 
Method Details- 
openStreamOpen an input stream to read the data.- Throws:
- IOException
 
- 
hashpublic com.google.common.hash.HashCode hash()Get the hash code of the data. It's recommended to use SHA1.- Returns:
- A hash code of the data.
 
- 
hashAsString
- 
equalsTwo binaries are equals if their contents are equal. Two binaries should be considered equal if their hash code is equal. It's recommended to use SHA1.
- 
hashCodepublic int hashCode()Return aninthash code for the data. This should be theinthash code of the full hash code returned byhash().
- 
sizepublic long size()Return the size of this binary in bytes.- Returns:
- The size of the binary in bytes or a value < 0if the size is unknown.
 
- 
getMimeType
- 
getFileExtensionReturns the file extension when available. The file extension can be more specific than the mime-type.
- 
closepublic void close()Release any resources associated with this binary.- Specified by:
- closein interface- AutoCloseable
 
- 
finalize
- 
toString
- 
getBase64DataUri- Returns:
- a Stringcontaining thebase64encoded binary as it might be used assrcanimgtag.
- Throws:
- IOException
 
- 
getUrl
- 
mayBeStoredpublic boolean mayBeStored()- Returns:
- if false, this binary can only be used as query parameter and does not contain any data
 
 
-