OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

xacml message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: RE: [xacml] Proposal of Model for comparing two sequences


On Thu, 12 Sep 2002, Daniel Engovatov wrote:

>
> >
> > NO!!!  It will make API for extensions a living hell..
>
> >How so?
>
> Please provide an example of an API for extension functions n this
> case, in Java or C++..

Okay. To the list:
--Forwarded--
From polar@syr.edu Thu Sep 12 14:23:24 2002
Date: Thu, 12 Sep 2002 14:22:01 -0400 (EDT)
From: Polar Humenn <polar@syr.edu>
To: Daniel Engovatov <dengovatov@crosslogix.com>
Subject: RE: [xacml] Proposal of Model for comparing two sequences


> Write me an example of an API in a language them more then 10 people outside
> computer science departments are using ( I mostly mean Java, C++ and
> friends).  Without using function pointers/methods, void*/Object etc.

Well, you have to be clever in the way you design your interfaces.
If I must, in Java:

interface Function {}

interface BooleanFunction
	extends Function
{
	boolean eval(Object o1, Object o2)
}

interface  ListBooleanFunction
	extends Function
{
    boolean eval(BooleanFunction f,List a, List b);
}

class StringEqual
	implements BooleanFunction
{
    public boolean eval(Object o1, Object o2)
    {
         return ((String)o1).equal((String)o2);
    }
}

class AtLeastOne
	implements ListFunction
{
    boolean eval(BooleanFunction f, List a, List b)
    {
         Iterator ai = a.iterator();
         while(ai.hasNext())
         {
	      Object a_item = ai.next();
              Iterator bi = b.iterator();
              while(bi.hasNext())
              {
                 if (f.eval(a_item,bi.next()))
                 {
                       return true;
                 }
              }
         }
         return false;
    }
}

Example:

List a = .....;
List b = .....;

// Expression that determines if one string is common to
// both lists of strings

 boolean result = new AtLeaseOne().eval(new StringEqual(),a,b);


There!

-Polar




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC