Package com.helger.commons.mime
Class MimeTypeContent
java.lang.Object
com.helger.commons.mime.MimeTypeContent
Represent a single mapping from content bytes to an
IMimeType.- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMimeTypeContent(byte[] aContentBytes, boolean bCopyBytes, IMimeType aMimeType) ConstructorMimeTypeContent(byte[] aContentBytes, IMimeType aMimeType) Constructor -
Method Summary
Modifier and TypeMethodDescriptionbooleanbyte[]intinthashCode()booleanmatchesBeginning(byte[] aCmpBytes) Check if the passed byte array starts with the bytes of this object.toString()voidWrite the content bytes to the specified output stream.
-
Field Details
-
DEFAULT_COPY_BYTES
public static final boolean DEFAULT_COPY_BYTES- See Also:
-
-
Constructor Details
-
MimeTypeContent
Constructor- Parameters:
aContentBytes- The beginning bytes. May neither benullnor empty.aMimeType- The corresponding mime type. May not benull.
-
MimeTypeContent
public MimeTypeContent(@Nonnull @Nonempty byte[] aContentBytes, boolean bCopyBytes, @Nonnull IMimeType aMimeType) Constructor- Parameters:
aContentBytes- The beginning bytes. May neither benullnor empty.bCopyBytes-trueto copy the bytes,falseto reuse the provided instance.aMimeType- The corresponding mime type. May not benull.
-
-
Method Details
-
getAllContentBytes
- Returns:
- A copy of the content bytes to use. Neither
nullnor empty.
-
getContentByteCount
- Returns:
- The number of content bytes available. Always > 0.
-
writeContentBytes
Write the content bytes to the specified output stream.- Parameters:
aOS- The output stream to write to. The stream is NOT closed. May not benull.- Throws:
IOException- In case of a write error
-
getMimeType
- Returns:
- The matching mime type. Never
null.
-
matchesBeginning
Check if the passed byte array starts with the bytes of this object.- Parameters:
aCmpBytes- The bytes to compare to. May not benull.- Returns:
trueif the passed bytes start with the bytes in this object.
-
equals
-
hashCode
public int hashCode() -
toString
-