I use filters quite a lot, filters as supplied by the language (Perl and Shell), or filter frameworks written by me (Python). From what I have learned, your design is far too ambitious - you don't need an XML schema to store information about objects. You want your filters to comply to a simple, common interface - don't try to make filters optimize their connections, simply build optimized filter-pairs if you need them.

The filter pipeline setup can be well stored in an XML file, but if your interface is as simple as I recommend, there is not much difference between an XML file and your program, as most of your programming becomes declarative. To illustrate this, here is a small module/program, that filters a list out of one of our hosts into a csv file (Python code ahead) :

if __name__ == '__main__': InputFilename = sys.argv[1] output= Pipeline( FileFilter(), WVS19502Filter(), Date(["Valuta","DD.MM.YYYY"]), apply(Kommazahl,columns), SimpleCSVOutputFilter(["Broker","Valuta","Waehrung"]+c +olumns,","), ).run(files(InputFilename)) OutputFilename = "../OUTPUT/"+os.path.basename(InputFilename)+ +".csv" out = open(OutputFilename,"w") out.write(string.join(["Broker","Valuta","Waehrung"]+columns," +,")+"\n") for i in output: out.write(i["line"]+"\n") out.close

As you see, except for the setup and the output, everything is declarative. The interface each filter supports is simply two methods :

The whole pipeline is then (sequentially) processed. If I used Python 2.2, Ruby or Perl 6, I could use iterators, which would pass on the first result as soon as it became available, but not all filters can output one element for one element of input anyway, and memory is a technical problem.

As for the language of implementation, this concept can be implemented in almost any language, as it neither requires reflection nor multiple inheritance. If you're looking for a resource-eating multithreaded parallel implementation, you will feel at home in both languages, but as the interface is so simplicistic, the type-enforcement of Java will buy you nothing.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

In reply to Re: Filter objects? by Corion
in thread Filter objects? by matth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.