@NotThreadSafe public class CSSDataURL extends Object
| Constructor and Description |
|---|
CSSDataURL()
Default constructor.
|
CSSDataURL(com.helger.commons.mime.IMimeType aMimeType,
boolean bBase64Encoded,
byte[] aContent)
Constructor
|
CSSDataURL(com.helger.commons.mime.IMimeType aMimeType,
boolean bBase64Encoded,
byte[] aContent,
Charset aCharset,
String sContent)
Full constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
String |
getAsString() |
String |
getAsString(boolean bOptimizedVersion) |
Charset |
getCharset() |
static Charset |
getCharsetFromMimeTypeOrDefault(com.helger.commons.mime.IMimeType aMimeType)
Determine the charset from the passed MIME type.
|
String |
getContentAsBase64EncodedString()
|
String |
getContentAsString()
Get the data content of this Data URL as String.
|
String |
getContentAsString(Charset aCharset)
Get the data content of this Data URL as String in the specified charset.
|
byte[] |
getContentBytes()
Get a copy of all content bytes.
|
int |
getContentLength() |
com.helger.commons.mime.IMimeType |
getMimeType() |
int |
hashCode() |
boolean |
isBase64Encoded() |
String |
toString() |
void |
writeContentBytes(OutputStream aOS)
Write all the binary content to the passed output stream.
|
public CSSDataURL()
public CSSDataURL(@Nonnull com.helger.commons.mime.IMimeType aMimeType, boolean bBase64Encoded, @Nonnull byte[] aContent)
aMimeType - The MIME type to be used. If it contains a charset, this charset
will be used otherwise the default charset will be used.bBase64Encoded - true if the content of this data should be Base64
encoded. It is recommended to set this to true if you
have binary data like images.aContent - The content of the data URL as a byte array. May not be
null.public CSSDataURL(@Nonnull com.helger.commons.mime.IMimeType aMimeType, boolean bBase64Encoded, @Nonnull byte[] aContent, @Nonnull Charset aCharset, @Nullable String sContent)
aMimeType - The MIME type to be used. May not be null. If you don't
know provide the default MIME type from
CSSDataURLHelper.DEFAULT_MIME_TYPE.bBase64Encoded - true if the data URL String representation should be
Base64 encoded, false if not. It is recommended to set
this to true if you have binary data like images.aContent - The content of the data URL as a byte array. May not be
null but may be empty. This content may not be Base64
encoded!aCharset - The charset to be used to encode the String. May not be
null. The default is
CSSDataURLHelper.DEFAULT_CHARSET.sContent - The String representation of the content. It must match the byte
array in the specified charset. If this parameter is
null than the String content representation is lazily
created in getContentAsString().@Nonnull public static Charset getCharsetFromMimeTypeOrDefault(@Nullable com.helger.commons.mime.IMimeType aMimeType)
aMimeType - The MIME type to investigate.null.@Nonnull public com.helger.commons.mime.IMimeType getMimeType()
CSSDataURLHelper.DEFAULT_MIME_TYPE must
be used.public boolean isBase64Encoded()
true if the parsed data URL was Base64 encoded or if
this data URL should be Base64 encoded.@Nonnegative public int getContentLength()
@Nonnull @ReturnsMutableCopy public byte[] getContentBytes()
null but maybe empty.public void writeContentBytes(@Nonnull @WillNotClose OutputStream aOS) throws IOException
aOS - The output stream to write to. May not be null.IOException - from OutputStream@Nonnull public Charset getCharset()
null. The default is
CSSDataURLHelper.DEFAULT_CHARSET.@Nonnull public String getContentAsString()
null String was provided in the
constructor, this object is immutable. No Base64 encoding is performed in
this method.null.@Nonnull public String getContentAsBase64EncodedString()
String in the Charset
specified by getCharset(). The encoding is applied independent of
the isBase64Encoded() state.null.@Nonnull public String getContentAsString(@Nonnull Charset aCharset)
aCharset - The charset to be used. May not be null.null.@Nonnull public String getAsString()
@Nonnull public String getAsString(boolean bOptimizedVersion)
bOptimizedVersion - true to create optimized versionCopyright © 2014–2022 Philip Helger. All rights reserved.