Methods Summary |
---|
protected java.lang.Object | computeContent(javax.activation.DataSource aDataSource)
String encoding = getCharacterSet(aDataSource.getContentType());
Reader reader = null;
Writer writer = new StringWriter(2048);
String content = null;
try
{
reader = new BufferedReader(new InputStreamReader(aDataSource
.getInputStream(), encoding), 2048);
while (reader.ready())
writer.write(reader.read());
writer.flush();
content = writer.toString();
}
catch (IllegalArgumentException e)
{
throw new MessagingException("Encoding = \"" + encoding + "\"", e);
}
catch (IOException e)
{
throw new MessagingException(
"Exception obtaining content from DataSource", e);
}
finally
{
try
{
writer.close();
}
catch (IOException e1)
{
// No-op
}
}
return content;
|
protected javax.activation.ActivationDataFlavor | computeDataFlavor()
return new ActivationDataFlavor(String.class,
"message/disposition-notification", "Message String");
|
protected java.lang.String | getCharacterSet(java.lang.String aType)
String characterSet = null;
try
{
characterSet = new ContentType(aType).getParameter("charset");
}
catch (ParseException e)
{
// no-op
}
finally
{
if (null == characterSet)
characterSet = "us-ascii";
}
return MimeUtility.javaCharset(characterSet);
|
public void | writeTo(java.lang.Object aPart, java.lang.String aMimeType, java.io.OutputStream aStream)
if (!(aPart instanceof String))
throw new IOException("Type \"" + aPart.getClass().getName()
+ "\" is not supported.");
String encoding = getCharacterSet(getDataFlavor().getMimeType());
Writer writer = null;
try
{
writer = new BufferedWriter(new OutputStreamWriter(aStream,
encoding), 2048);
}
catch (IllegalArgumentException e)
{
throw new UnsupportedEncodingException(encoding);
}
writer.write((String) aPart);
writer.flush();
|