IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

String tokenize

  • 1.  String tokenize

    Posted Thu December 12, 2002 12:49 AM

    How do we tokenize strings, based on delimiter ‘\n\r’ using the service Wmpublic.string:tokenize.

    The service seems to have a bug. It doesnt recognize the '' character.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: String tokenize

    Posted Thu December 12, 2002 09:44 AM

    if the delimiter is set to null or empty it will use ‘\n\t\r’ as the delimiter.

    hth


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 3.  RE: String tokenize

    Posted Thu December 12, 2002 02:20 PM

    Okay,
    to tokenize string, input a line feed in the field. That is

    1. right click on the field, select “Use Large Editor” and then just do an enter in that field. This will recognize the \n.
      God works in strange ways, so does webMethods.
      Have a great day!
      VR

    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 4.  RE: String tokenize

    Posted Thu December 12, 2002 02:26 PM

    Hi, VR. I thought about that, too, but wasn’t sure about one thing: Does the server recognize the [Enter] as \n or \r\n differently depending on its platform? So, a physical line break provided on a NT machine (\r\n) is automatically converted to \n when the code is migrated to a UNIX box?

    Thanks.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: String tokenize

    Posted Thu December 12, 2002 02:51 PM

    Hi,
    My knowledge is limited to Windows and in windows, the line feed in the field gets recognized as ‘\n’.
    Thanks
    VR


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: String tokenize

    Posted Thu December 12, 2002 04:24 PM

    I used enter before, as delimitter and it works just fine on both windows and solaris.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 7.  RE: String tokenize

    Posted Thu December 12, 2002 04:39 PM

    A couple of things about this service:

    • As with many, many built-in services, this is simply a wrapper for the corresponding Java class. In this case, java.util.StringTokenizer

    • The default behavior of StringTokenizer, if no delimiters are specified, is to use " \t\n\r\f" (note that space is part of the set). Specifying no delimiter probably won’t do what you want Suhesh.

    • StringTokenizer has behavior that can catch you off guard if you are unaware of how it works. For example, multiple delimiters that appear together in the source will not cause empty tokens to be returned. If the delimiter is '’ and you tokenize the string "12**4" you’ll get back 3 tokens, not 4. Whether or not this is an issue depends on what you’re trying to do. This behavior is exactly what you want though if you’re parsing lines terminated with \r\n.

    HTH


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 8.  RE: String tokenize

    Posted Thu December 12, 2002 04:44 PM

    One more thing–none of the services (with the exception of a couple in the EDI adapter) support Java character escape sequences. \n, \r, \t, etc. are special instructions to the compiler to create the character. To use these in the FLOW environment you need to convert these to the “real” characters yourself. The code for a service that converts Java and Unicode character escape literals can be found at [url=“wmusers.com”]wmusers.com (be sure to read the entire thread if you’re going to use that code)


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: String tokenize

    Posted Thu December 12, 2002 04:53 PM

    Apologies for the multiple posts…

    Forgot to mention that the technique Vinod describes works just fine to get \n or \t. For other chars, you’ll need the service I referenced above.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB