# Configurable filter node

**URL:** <https://forum.cloverdx.com/t/configurable-filter-node/517>\
**Category:** CloverDX Platform\
**Created:** [May 1, 2009, 12:00am UTC](https://forum.cloverdx.com/t/configurable-filter-node/517 "2009-05-01T00:00:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhgrove](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/mhgrove/32/95_2.png) [@mhgrove](https://forum.cloverdx.com/u/mhgrove)\
**Post date:** [May 1, 2009, 12:00am UTC](https://forum.cloverdx.com/t/configurable-filter-node/517/1 "2009-05-01T00:00:00Z")

</div>

Hi. I want to filter records using a method which is not translateable to the filter expression syntax used by the default Filter node. I ended up getting around this by extending the Filter node and setting a custom RecordFilter. This works fine but I had a few points of feedback for the next version of clover.

\* Can RecordFilter be an interface, or at least an abstract class that doesnt depend on a filter expression? Then current implementation become the default instantiation of that interface/abstract class? Right now, I have to pass a valid, but ultimately ignored filter expression to the constructor of my custom RecordFilter instance (which just overrides accepts) and that’s kind of crufty. Plus I don’t need all the filter expression logic floating around beneath the surface.  
\* Filter should provide an accessor method for its record filter instance. You can set it, but you can’t get it.  
\* can XML\_FILTEREXPRESSION\_ATTRIBUTE be protected rather than private so a class extending Filter can use it?

Thanks.

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [May 4, 2009, 7:52am UTC](https://forum.cloverdx.com/t/configurable-filter-node/517/2 "2009-05-04T07:52:05Z")

</div>

Hello,  
you can do it with Reformat component instead of Filter or ExtFilter. You can pass to Reformat transformation in CTL or java, so anything, that can be written in java can be passed as your filter expression. All you need is to return proper port number. See following code as a simple example:

```auto
function accept(){
	if (char_at($field1, length($field1) -1) == '1') return true;
	return false;
}

function mappingTo0(){
	$0.* := $0.*;
}

function mappingTo1(){
	$1.* := $0.*;
}

// Transforms input record into output record.
function transform() {
	if (accept()) {
		mappingTo0();
		return 0;
	}
	mappingTo1();
	return 1;
}

```

---

<div class="post-metadata">

**Author:** ![achan](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@achan](https://forum.cloverdx.com/u/achan)\
**Post date:** [May 21, 2009, 4:55pm UTC](https://forum.cloverdx.com/t/configurable-filter-node/517/3 "2009-05-21T16:55:25Z")

</div>

Hi Agata,

If I am using a Java class as my transformation, how can I return the proper port number since the Transform method can only return a boolean, right? So I am thinking of using a Partition node instead of a Reformat node since I can specify the port number in getOutputPort method, right?

Thanks,  
al

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [May 22, 2009, 7:03am UTC](https://forum.cloverdx.com/t/configurable-filter-node/517/4 "2009-05-22T07:03:37Z")

</div>

Hello Al,  
RecordTransform interface was changed in 2.6 version, so since this version function transform returns _int_ instead of _boolean_. The meanings of return value are:

- RecordTransform.ALL – send the data record(s) to all the output ports

- RecordTransform.SKIP – skip the data record(s)

- \>= 0 – send the data record(s) to a specified output port

- \< -1 – fatal error / user defined

---

<div class="post-metadata">

**Author:** ![achan](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@achan](https://forum.cloverdx.com/u/achan)\
**Post date:** [May 22, 2009, 4:23pm UTC](https://forum.cloverdx.com/t/configurable-filter-node/517/5 "2009-05-22T16:23:35Z")

</div>

Hi Agata,

Thanks 🙂

By the way, do you have plans to update the Javadoc? looks like the Javadoc for RecordTransform ([http://cloveretl.berlios.de/docs/JavaDo … sform.html](http://cloveretl.berlios.de/docs/JavaDoc/org/jetel/component/RecordTransform.html)) is for the previous version… or you actually have an updated doc somewhere else?

al

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [May 25, 2009, 7:18am UTC](https://forum.cloverdx.com/t/configurable-filter-node/517/6 "2009-05-25T07:18:59Z")

</div>

Hi Al,  
we are working on it 😉 ([http://bug.cloveretl.org/view.php?id=2087](http://bug.cloveretl.org/view.php?id=2087)). At time being up to date javadocs are distributed with Cloveretl engine sources.
