You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Gary Gregory <ga...@gmail.com> on 2012/10/01 15:17:16 UTC
Creating a ContentType
Hi All:
Right now I have code that looks like this:
final Charset myCharset = ...
final ContentType ct = ContentType.create(*HTTP.OCTET_STREAM_TYPE*,
myCharset);
HTTP.OCTET_STREAM_TYPE is deprecated, so to avoild magic strings in the
code I can do:
final ContentType ct =
ContentType.create(ContentType.APPLICATION_OCTET_STREAM.getMimeType(),
myCharset);
What doing a fluent type of call instead:
final ContentType ct = ContentType.APPLICATION_OCTET_STREAM.with(myCharset);
?
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: Creating a ContentType
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2012-10-01 at 09:17 -0400, Gary Gregory wrote:
> Hi All:
>
> Right now I have code that looks like this:
>
> final Charset myCharset = ...
> final ContentType ct = ContentType.create(*HTTP.OCTET_STREAM_TYPE*,
> myCharset);
>
> HTTP.OCTET_STREAM_TYPE is deprecated, so to avoild magic strings in the
> code I can do:
>
> final ContentType ct =
> ContentType.create(ContentType.APPLICATION_OCTET_STREAM.getMimeType(),
> myCharset);
>
> What doing a fluent type of call instead:
>
> final ContentType ct = ContentType.APPLICATION_OCTET_STREAM.with(myCharset);
>
> ?
>
Sounds good to me. +1
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org