Package com.helger.commons.mime
Class MimeTypeContent
- java.lang.Object
-
- com.helger.commons.mime.MimeTypeContent
-
@Immutable @MustImplementEqualsAndHashcode public class MimeTypeContent extends Object
Represent a single mapping from content bytes to anIMimeType.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_COPY_BYTES
-
Constructor Summary
Constructors Constructor Description MimeTypeContent(byte[] aContentBytes, boolean bCopyBytes, IMimeType aMimeType)ConstructorMimeTypeContent(byte[] aContentBytes, IMimeType aMimeType)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)byte[]getAllContentBytes()intgetContentByteCount()IMimeTypegetMimeType()inthashCode()booleanmatchesBeginning(byte[] aCmpBytes)Check if the passed byte array starts with the bytes of this object.StringtoString()voidwriteContentBytes(OutputStream aOS)Write the content bytes to the specified output stream.
-
-
-
Field Detail
-
DEFAULT_COPY_BYTES
public static final boolean DEFAULT_COPY_BYTES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MimeTypeContent
public MimeTypeContent(@Nonnull @Nonempty byte[] aContentBytes, @Nonnull IMimeType aMimeType)
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 Detail
-
getAllContentBytes
@Nonnull @Nonempty @ReturnsMutableCopy public byte[] getAllContentBytes()
- Returns:
- A copy of the content bytes to use. Neither
nullnor empty.
-
getContentByteCount
@Nonnegative public int getContentByteCount()
- Returns:
- The number of content bytes available. Always > 0.
-
writeContentBytes
public void writeContentBytes(@Nonnull @WillNotClose OutputStream aOS) throws IOException
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
-
matchesBeginning
public boolean matchesBeginning(@Nonnull byte[] aCmpBytes)
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.
-
-