<if-empty> test for Map does not do deep test

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

<if-empty> test for Map does not do deep test

jonwimp
Hey Chris (Howes),

I think you use Minilang a lot, so I really need your advice.

Currently, <if-empty field-name="someMap"> returns false even if "someMap" contains keys pointing
to empty values. See Java method ObjectType.isEmpty(Object value) where value is a java.util.Map.

Do you think we should add an attribute say "deep-test" (true/false value)?

I handle nested maps a lot, since it's more organized (structured) that way.

Jonathon
Reply | Threaded
Open this post in threaded view
|

Re: <if-empty> test for Map does not do deep test

cjhowe
Hi Jonathon,

(it's Howe btw, no "s")

I wouldn't agree with that approach.  A map is empty if it has no
name/value pairs, not if one (or all) of the name/value pairs is empty.
To attempt the test that you're trying, either test the actual field
that you're interested in or if unknown run an iterate-map and set the
value of some field (to if-not-empty test later) to a value if you
encounter an empty field.  Remember that the simple methods are
primarily for business logic not a replacement for java, so if you're
running into complicated scenarios you may want to rethink whether
logic is "business" or if it's application.

If you're simply looking to avoid resetting the server or rebuilding
your packages, you can still use the <call-bsh><![CDATA[ and run
beanshell inside of it, just make sure you return the field before
exiting ]]></call-bsh>.


--- Jonathon -- Improov <[hidden email]> wrote:

> Hey Chris (Howes),
>
> I think you use Minilang a lot, so I really need your advice.
>
> Currently, <if-empty field-name="someMap"> returns false even if
> "someMap" contains keys pointing
> to empty values. See Java method ObjectType.isEmpty(Object value)
> where value is a java.util.Map.
>
> Do you think we should add an attribute say "deep-test" (true/false
> value)?
>
> I handle nested maps a lot, since it's more organized (structured)
> that way.
>
> Jonathon
>

Reply | Threaded
Open this post in threaded view
|

Re: <if-empty> test for Map does not do deep test

Jacques Le Roux
Administrator
Just a quick note.

It's often in the other way, but would not this thread be better in dev
ML ?

Jacques

----- Message d'origine -----
De : "Chris Howe" <[hidden email]>
À : <[hidden email]>
Envoyé : dimanche 27 mai 2007 17:57
Objet : Re: <if-empty> test for Map does not do deep test


> Hi Jonathon,
>
> (it's Howe btw, no "s")
>
> I wouldn't agree with that approach.  A map is empty if it has no
> name/value pairs, not if one (or all) of the name/value pairs is
empty.

> To attempt the test that you're trying, either test the actual field
> that you're interested in or if unknown run an iterate-map and set the
> value of some field (to if-not-empty test later) to a value if you
> encounter an empty field.  Remember that the simple methods are
> primarily for business logic not a replacement for java, so if you're
> running into complicated scenarios you may want to rethink whether
> logic is "business" or if it's application.
>
> If you're simply looking to avoid resetting the server or rebuilding
> your packages, you can still use the <call-bsh><![CDATA[ and run
> beanshell inside of it, just make sure you return the field before
> exiting ]]></call-bsh>.
>
>
> --- Jonathon -- Improov <[hidden email]> wrote:
>
> > Hey Chris (Howes),
> >
> > I think you use Minilang a lot, so I really need your advice.
> >
> > Currently, <if-empty field-name="someMap"> returns false even if
> > "someMap" contains keys pointing
> > to empty values. See Java method ObjectType.isEmpty(Object value)
> > where value is a java.util.Map.
> >
> > Do you think we should add an attribute say "deep-test" (true/false
> > value)?
> >
> > I handle nested maps a lot, since it's more organized (structured)
> > that way.
> >
> > Jonathon
> >