Re: Binary AND Qualifier
Re: Binary AND Qualifier
- Subject: Re: Binary AND Qualifier
- From: Chuck Hill <email@hidden>
- Date: Fri, 26 Sep 2008 11:01:32 -0700
On Sep 26, 2008, at 10:27 AM, John Huss wrote:
How can I test an Integer attribute to see if it has a bit set, like
(myAttribute & 1 != 0)?
I'd like to do this with a qualifier, only in memory right now,
although having DB support would be cool (since FrontBase does allow
this).
I tried messing around with an EOKeyValueQualifier with a custom
selector but had no luck.
I could see this qualifier being useful as well as a Binary OR
qualifier and a MOD qualifier.
Your best best is probably to subclass EOQualifier into
EOBinaryQualifier and implement the method
public boolean evaluateWithObject(Object object)
That should (IIRC) handle your in-memory needs. Maybe something like
EOBinaryAndQualifier(String keyPath, long mask, boolean match)
so the implementation would be something like
boolean result = ((Number)object.valueForKeyPath(keyPath)).longValue()
& mask != 0
result = match ? result : ! result
Obviously, there is a lot more that could be handled, like passing in
a constant to indicate &, |, ^ etc.
DB support is more complicated. Wonder and the Houdah frameworks have
examples.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden