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. Advertisements

  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. Advertisements

  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. Advertisements

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. CoX
    Replies:
    3
    Views:
    583
  2. Nathan Sokalski

    Using LIKE to perform a database match

    Nathan Sokalski, Jul 6, 2005, in forum: ASP .Net
    Replies:
    9
    Views:
    542
    Ron Allen
    Jul 11, 2005
  3. Replies:
    2
    Views:
    3,077
    Toby Inkster
    Aug 15, 2004
  4. Stuart A Yeates
    Replies:
    1
    Views:
    616
    Dimitre Novatchev
    Aug 20, 2003
  5. Benton
    Replies:
    10
    Views:
    889
    kferron
    Dec 5, 2006
  6. Replies:
    0
    Views:
    573
  7. Robert
    Replies:
    5
    Views:
    245
    Nathan Wagner
    Sep 22, 2005
  8. Replies:
    4
    Views:
    382
Loading...