Package com.pnfsoftware.jeb.util.base
Class TypedContent
java.lang.Object
com.pnfsoftware.jeb.util.base.TypedContent
A buffer of data with a MIME type and contents properties.
-
Constructor Summary
ConstructorsConstructorDescriptionTypedContent(byte[] bytes, String mimeType) Create binary content.TypedContent(byte[] bytes, String mimeType, String charsetName) Create binary content.TypedContent(byte[] bytes, String mimeType, String charsetName, ITypedContentProperties properties) Create binary content.TypedContent(String text, String mimeType) Create text content.TypedContent(String text, String mimeType, ITypedContentProperties properties) Create text content. -
Method Summary
Modifier and TypeMethodDescriptionstatic TypedContentbytes(byte[] bytes) Create binary typed content.byte[]getBytes()Get this content as bytes.getText()Get this content as text.static TypedContentCreate HTML typed content.static TypedContentCreate HTML typed content with an optional anchor.booleanisBinary()booleanisText()static TypedContentCreate plain-text typed content.
-
Constructor Details
-
TypedContent
Create text content.- Parameters:
text- text contentmimeType- MIME type; defaults toMimeType.TEXT_PLAINif blank
-
TypedContent
Create text content.- Parameters:
text- text contentmimeType- MIME type; defaults toMimeType.TEXT_PLAINif blankproperties- optional content properties
-
TypedContent
Create binary content.- Parameters:
bytes- bytesmimeType- MIME type; defaults toMimeType.APPLICATION_OCTETSTREAMif blank
-
TypedContent
Create binary content.- Parameters:
bytes- bytesmimeType- MIME type; defaults toMimeType.APPLICATION_OCTETSTREAMif blankcharsetName- optional charset name used when converting to text
-
TypedContent
public TypedContent(byte[] bytes, String mimeType, String charsetName, ITypedContentProperties properties) Create binary content.- Parameters:
bytes- bytesmimeType- MIME type; defaults toMimeType.APPLICATION_OCTETSTREAMif blankcharsetName- optional charset name used when converting to textproperties- optional content properties
-
-
Method Details
-
html
Create HTML typed content with an optional anchor.- Parameters:
text- HTML textanchor- optional anchor to associate with the content- Returns:
- typed content
-
html
Create HTML typed content.- Parameters:
text- HTML text- Returns:
- typed content
-
text
Create plain-text typed content.- Parameters:
text- text- Returns:
- typed content
-
bytes
Create binary typed content.- Parameters:
bytes- bytes- Returns:
- typed content
-
getText
Get this content as text.- Returns:
- text, decoding bytes with the configured charset if needed
-
getBytes
public byte[] getBytes()Get this content as bytes.- Returns:
- bytes, encoding text with the configured charset if needed
-
getMimeType
- Returns:
- MIME type
-
getCharsetName
- Returns:
- charset name, or null to use the default charset
-
getProperties
- Returns:
- optional content properties
-
isText
public boolean isText()- Returns:
- true if this instance was created from text
-
isBinary
public boolean isBinary()- Returns:
- true if this instance was created from bytes
-