You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Drac <th...@gmail.com> on 2007/10/16 06:34:54 UTC
Re: Thanks and a question
You don't need a new protocol class for this, just add a constructor overide
to the TextLineCodecFactory class (or extend the class) to take custom
encoder and decoder LineDelmiter strings like so:
public TextLineCodecFactory(Charset charset, String encoderDelimStr, String
decoderDelimStr) {
encoder = new TextLineEncoder(charset, new LineDelimiter(encoderDelimStr));
decoder = new TextLineDecoder(charset, new LineDelimiter(decoderDelimStr));
}
Then just construct your codec like so:
TextLineCodecFactory codec = new TextLineCodecFactory(Charset.forName(
"UTF-8"), "\0", "\0");
I was a little surprised that the line delimiters were hard coded into the
constructor to begin with, and that there was no way to access the
decoder/encoder to change them. Wouldn't this be one of the most varied
values from application to application? I'm not sure, I don't do much
networking stuff so maybe the defaults are used by most systems and Flash is
a bit of an oddball in that respect. I also guess it's easy enough to extend
the class and work this in, but it had me scratching my head for half a day
before I dug deep enough to find this.
Trustin Lee wrote:
>
> Hi Charles,
>
> On 8/7/07, Charles Woodson <cl...@yahoo.com> wrote:
>> Will do, Trustin. As for making this a part of the
>> general distribution and submitting the patch through
>> Jira, I assume that I should follow the guidelines in
>> the developer guide and then attach the patch's source
>> files for classes & unit tests to the jira issue. Am
>> I missing anything there?
>
> Yes. Until your patch is ready, you could just create a JIRA issue so
> that people find it's a known issue and work is in progress. :)
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>
>
--
View this message in context: http://www.nabble.com/Thanks-and-a-question-tf4221995s16868.html#a13226736
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Thanks and a question
Posted by Trustin Lee <tr...@gmail.com>.
On 10/16/07, Drac <th...@gmail.com> wrote:
>
> You don't need a new protocol class for this, just add a constructor overide
> to the TextLineCodecFactory class (or extend the class) to take custom
> encoder and decoder LineDelmiter strings like so:
>
> public TextLineCodecFactory(Charset charset, String encoderDelimStr, String
> decoderDelimStr) {
> encoder = new TextLineEncoder(charset, new LineDelimiter(encoderDelimStr));
> decoder = new TextLineDecoder(charset, new LineDelimiter(decoderDelimStr));
> }
>
> Then just construct your codec like so:
>
> TextLineCodecFactory codec = new TextLineCodecFactory(Charset.forName(
> "UTF-8"), "\0", "\0");
>
> I was a little surprised that the line delimiters were hard coded into the
> constructor to begin with, and that there was no way to access the
> decoder/encoder to change them. Wouldn't this be one of the most varied
> values from application to application? I'm not sure, I don't do much
> networking stuff so maybe the defaults are used by most systems and Flash is
> a bit of an oddball in that respect. I also guess it's easy enough to extend
> the class and work this in, but it had me scratching my head for half a day
> before I dug deep enough to find this.
Your concern already has been addressed in our development branch
(trunk); LineDelimiter.NUL and related constructors have been added.
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6