Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-655

Add a more general purpose text based decoder

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.0-M4
    • Fix Version/s: 2.0.8
    • Component/s: None
    • Labels:
      None
    • Environment:
      Mina 2.0.0-M4, Java 1.6, Fedora 10

      Description

      There are many text based protocols who have messages that are terminated by a delimiter other than an end of line. A protocol decoder that is more generic than TextLineDecoder would be a nice addition. It should also be easy to extend so developers can focus on coverting text messages to domain objects and not on converting and parsing IoBuffers.

      1. RegExDecoder.java
        15 kB
        Matthieu Chase Heimer

        Activity

        Hide
        elecharny Emmanuel Lecharny added a comment -

        I don't think it would bring a lot of benefit.

        First, most of the time the protocol is simple enough to use a TestLineDecoder.

        Second, using a regexp does not fit well with the very nature of NIO communication : we may receive the data in smal chunks, though that would require more than one macth to be sure we get all what we need.

        Show
        elecharny Emmanuel Lecharny added a comment - I don't think it would bring a lot of benefit. First, most of the time the protocol is simple enough to use a TestLineDecoder. Second, using a regexp does not fit well with the very nature of NIO communication : we may receive the data in smal chunks, though that would require more than one macth to be sure we get all what we need.
        Hide
        vrm Julien Vermillard added a comment -

        any progress here ?

        Show
        vrm Julien Vermillard added a comment - any progress here ?
        Hide
        chase@osdev.org Matthieu Chase Heimer added a comment -

        Yeah I see what you are saying about that case but as the second matching message would begin with the terminator it would be filtered out. I should probably separate out the multi-character and single-character patterns for line feeds into separate constants. I'll try to write some unit tests as time permits this week.

        Show
        chase@osdev.org Matthieu Chase Heimer added a comment - Yeah I see what you are saying about that case but as the second matching message would begin with the terminator it would be filtered out. I should probably separate out the multi-character and single-character patterns for line feeds into separate constants. I'll try to write some unit tests as time permits this week.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Thinking a bit more about the proposal :

        As you know, you have no guarantee that a terminated message will be transmitted in one single block. What if the received bytes just get decoded and the regexp is partially matched ?

        For instance using the LINE_TERM regexp, what if we receive \r\n in two messages ? I guess that you will match LINE_TERM twice, and potentially consider that you have two lines to deal with, when it's just an artefact, as the sender really wanted to terminate its message with a '\r\n'

        This is where it gets tricky ...

        Show
        elecharny Emmanuel Lecharny added a comment - Thinking a bit more about the proposal : As you know, you have no guarantee that a terminated message will be transmitted in one single block. What if the received bytes just get decoded and the regexp is partially matched ? For instance using the LINE_TERM regexp, what if we receive \r\n in two messages ? I guess that you will match LINE_TERM twice, and potentially consider that you have two lines to deal with, when it's just an artefact, as the sender really wanted to terminate its message with a '\r\n' This is where it gets tricky ...
        Hide
        elecharny Emmanuel Lecharny added a comment -

        That's an interesting addition.

        Just wondering if you also have some unit tests for it ? It would be cool to add something like the TextLineEncoder/DecoderTest classes to check this regexp codec.

        Thanks !

        Show
        elecharny Emmanuel Lecharny added a comment - That's an interesting addition. Just wondering if you also have some unit tests for it ? It would be cool to add something like the TextLineEncoder/DecoderTest classes to check this regexp codec. Thanks !
        Hide
        chase@osdev.org Matthieu Chase Heimer added a comment -

        A general purpose text decoder that uses regular expresions.

        Show
        chase@osdev.org Matthieu Chase Heimer added a comment - A general purpose text decoder that uses regular expresions.

          People

          • Assignee:
            Unassigned
            Reporter:
            chase@osdev.org Matthieu Chase Heimer
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development