check differnet pattern match then perform an action

Discussion in 'Java' started by mike, Sep 17, 2008.

  1. mike

    mike Guest

    Hi,

    I will read output lines ( text strings) from another program. I have
    about, at the moment, 30 different ( text strings) to look for in the
    output and each match will result in an action from my program.

    Any ideas on how I can make the pattern matching design so that each
    line will be matched against each pattern?

    cheers,

    //mike
    mike, Sep 17, 2008
    #1
    1. Advertising

  2. In article
    <>,
    mike <> wrote:

    > Hi,
    >
    > I will read output lines ( text strings) from another program. I have
    > about, at the moment, 30 different ( text strings) to look for in the
    > output and each match will result in an action from my program.
    >
    > Any ideas on how I can make the pattern matching design so that each
    > line will be matched against each pattern?


    Are you considering the command pattern?

    <http://www.google.com/search?q=java+command+pattern>

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 17, 2008
    #2
    1. Advertising

  3. In article <>,
    "John B. Matthews" <> wrote:

    > In article
    > <>,
    > mike <> wrote:
    >
    > > Hi,
    > >
    > > I will read output lines ( text strings) from another program. I have
    > > about, at the moment, 30 different ( text strings) to look for in the
    > > output and each match will result in an action from my program.
    > >
    > > Any ideas on how I can make the pattern matching design so that each
    > > line will be matched against each pattern?

    >
    > Are you considering the command pattern?
    >
    > <http://www.google.com/search?q=java+command+pattern>


    On closer reading, you may be more interested in pattern matching than
    command dispatching. I'm not sure if you mean to match any of 30 literal
    strings or any of 30 regular expressions. In either case, you may be
    better off using StreamTokenizer to parse the input text (output from
    another program) into a HashMap of unique, non-trivial words. A literal
    match would then be constant-time. A regex match will take longer, but
    pre-compiling is especially beneficial for short target strings. If
    misspelling is a problem, consider a variation of Knuth's soundex
    algorithm:

    <http://www.java2s.com/Code/Java/Collections-Data-Structure/SoundextheSou
    ndexAlgorithmasdescribedbyKnuth.htm>

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 17, 2008
    #3
  4. mike

    mike Guest

    On 17 Sep, 20:28, "John B. Matthews" <> wrote:
    > In article <>,
    >  "John B. Matthews" <> wrote:
    >
    >
    >
    >
    >
    > > In article
    > > <>,
    > >  mike <> wrote:

    >
    > > > Hi,

    >
    > > > I will read output lines ( text strings) from another program. I have
    > > > about, at the moment, 30 different ( text strings) to look for in the
    > > > output and each match will result in an action from my program.

    >
    > > > Any ideas on how I can  make the pattern matching design so that each
    > > > line will be matched against each pattern?

    >
    > > Are you considering the command pattern?

    >
    > > <http://www.google.com/search?q=java+command+pattern>

    >
    > On closer reading, you may be more interested in pattern matching than
    > command dispatching. I'm not sure if you mean to match any of 30 literal
    > strings or any of 30 regular expressions. In either case, you may be
    > better off using StreamTokenizer to parse the input text (output from
    > another program) into a HashMap of unique, non-trivial words. A literal
    > match would then be constant-time. A regex match will take longer, but
    > pre-compiling is especially beneficial for short target strings. If
    > misspelling is a problem, consider a variation of Knuth's soundex
    > algorithm:
    >
    > <http://www.java2s.com/Code/Java/Collections-Data-Structure/SoundextheSou
    > ndexAlgorithmasdescribedbyKnuth.htm>
    >
    > --
    > John B. Matthews
    > trashgod at gmail dot com
    > home dot woh dot rr dot com slash jbmatthews- Dölj citerad text -
    >
    > - Visa citerad text -


    Hi,

    You led me to look at patterns. So I decided to test an implementaion
    using Composite pattern.
    http://pclc.pace.edu/~bergin/patterns/strategydecorator.html

    I will have a class for each scenario of output. Then the class will
    return a State object.

    I appreciated you leading me into patterns.

    cheers,

    //mike


    I will try using
    mike, Sep 18, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark

    .net ddls'' in differnet directories?

    Darren Clark, Aug 19, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    2,231
    Richard Grimes [MVP]
    Sep 3, 2003
  2. =?ISO-8859-1?Q?Mattias_Br=E4ndstr=F6m?=

    Two pointers to the same obejct, two differnet values...

    =?ISO-8859-1?Q?Mattias_Br=E4ndstr=F6m?=, Dec 18, 2003, in forum: C++
    Replies:
    3
    Views:
    283
    Jumbo
    Dec 18, 2003
  3. alf
    Replies:
    3
    Views:
    315
    Steve Holden
    Nov 2, 2006
  4. Replies:
    0
    Views:
    270
  5. Robert
    Replies:
    5
    Views:
    98
    Nathan Wagner
    Sep 22, 2005
Loading...

Share This Page