Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22678/com/sun/xacml/cond
Modified Files:
HigherOrderFunction.java
Log Message:
fixed a bug in the any-of-all and all-of-any functions
Index: HigherOrderFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/HigherOrderFunction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** HigherOrderFunction.java 24 May 2004 21:39:22 -0000 1.6
--- HigherOrderFunction.java 15 Jul 2004 18:14:06 -0000 1.7
***************
*** 259,263 ****
// true, otherwise return false
! result = any(args[0], (BagAttribute)(args[1]), function, context);
break;
}
--- 259,264 ----
// true, otherwise return false
! result = any(args[0], (BagAttribute)(args[1]), function, context,
! false);
break;
}
***************
*** 283,288 ****
// any evaluation is true return true, otherwise return false
! result = anyOfAny((BagAttribute)(args[0]), (BagAttribute)(args[1]),
! function, context);
break;
}
--- 284,301 ----
// any evaluation is true return true, otherwise return false
! Iterator it = ((BagAttribute)args[0]).iterator();
! BagAttribute bag = (BagAttribute)(args[1]);
!
! while (it.hasNext()) {
! AttributeValue value = (AttributeValue)(it.next());
! result = any(value, bag, function, context, false);
!
! if (result.indeterminate())
! return result;
!
! if (((BooleanAttribute)(result.
! getAttributeValue())).getValue())
! break;
! }
break;
}
***************
*** 292,298 ****
// param: boolean-function, bag, bag of same type
// return: boolean
! // iterate through the second bag, and for each of those values
! // if one of them matches every value in the first bag using the
! // given function, then return true, otherwise return false
result = allOfAny((BagAttribute)(args[1]), (BagAttribute)(args[0]),
--- 305,311 ----
// param: boolean-function, bag, bag of same type
// return: boolean
! // iterate through the first bag, and if for each of those values
! // one of the values in the second bag matches then return true,
! // otherwise return false
result = allOfAny((BagAttribute)(args[1]), (BagAttribute)(args[0]),
***************
*** 305,311 ****
// param: boolean-function, bag, bag of same type
// return: boolean
! // iterate through the first bag, and for each of those values
! // if one of them matches every value in the second bag using
! // the given function, then return true, otherwise return false
result = anyOfAll((BagAttribute)(args[0]), (BagAttribute)(args[1]),
--- 318,324 ----
// param: boolean-function, bag, bag of same type
// return: boolean
! // iterate through the second bag, and if for each of those values
! // one of the values in the first bag matches then return true,
! // otherwise return false
result = anyOfAll((BagAttribute)(args[0]), (BagAttribute)(args[1]),
***************
*** 335,342 ****
if (! ((BooleanAttribute)(result.
getAttributeValue())).getValue())
! return result;
}
!
! result = new EvaluationResult(BooleanAttribute.getTrueInstance());
}
--- 348,354 ----
if (! ((BooleanAttribute)(result.
getAttributeValue())).getValue())
! break;
}
! break;
}
***************
*** 411,423 ****
/**
! * Perform the any operation...function must return a boolean
*/
private EvaluationResult any(AttributeValue value, BagAttribute bag,
! Function function, EvaluationCtx context) {
! return anyAndAllHelper(value, bag, function, context, false, false);
}
/**
! * Perform the all operation...function must return a boolean
*/
private EvaluationResult all(AttributeValue value, BagAttribute bag,
--- 423,438 ----
/**
! * Private helper function that performs the any function, but lets you
! * swap the argument order (so it can be used by any-of-all)
*/
private EvaluationResult any(AttributeValue value, BagAttribute bag,
! Function function, EvaluationCtx context,
! boolean argumentsAreSwapped) {
! return anyAndAllHelper(value, bag, function, context, false,
! argumentsAreSwapped);
}
/**
! * Private helper function that performs the all function
*/
private EvaluationResult all(AttributeValue value, BagAttribute bag,
***************
*** 427,431 ****
/**
! * Generic code for any & all functions
*/
private EvaluationResult anyAndAllHelper(AttributeValue value,
--- 442,446 ----
/**
! * Private helper for any & all functions
*/
private EvaluationResult anyAndAllHelper(AttributeValue value,
***************
*** 433,438 ****
Function function,
EvaluationCtx context,
! boolean foo, boolean swap) {
! BooleanAttribute attr = BooleanAttribute.getInstance(foo);
Iterator it = bag.iterator();
--- 448,454 ----
Function function,
EvaluationCtx context,
! boolean allFunction,
! boolean argumentsAreSwapped) {
! BooleanAttribute attr = BooleanAttribute.getInstance(allFunction);
Iterator it = bag.iterator();
***************
*** 440,444 ****
List params = new ArrayList();
! if (! swap) {
params.add(value);
params.add((AttributeValue)(it.next()));
--- 456,460 ----
List params = new ArrayList();
! if (! argumentsAreSwapped) {
params.add(value);
params.add((AttributeValue)(it.next()));
***************
*** 455,459 ****
BooleanAttribute bool =
(BooleanAttribute)(result.getAttributeValue());
! if (bool.getValue() != foo) {
attr = bool;
break;
--- 471,475 ----
BooleanAttribute bool =
(BooleanAttribute)(result.getAttributeValue());
! if (bool.getValue() != allFunction) {
attr = bool;
break;
***************
*** 465,477 ****
/**
- * any-of-any
- */
- private EvaluationResult anyOfAny(BagAttribute bag1, BagAttribute bag2,
- Function function,
- EvaluationCtx context) {
- return anyOfAnyOrAllHelper(bag1, bag2, function, context, true, false);
- }
-
- /**
* any-of-all
*/
--- 481,484 ----
***************
*** 479,484 ****
Function function,
EvaluationCtx context) {
! return anyOfAnyOrAllHelper(anyBag, allBag, function, context, false,
! false);
}
--- 486,490 ----
Function function,
EvaluationCtx context) {
! return allAnyHelper(anyBag, allBag, function, context, true);
}
***************
*** 489,526 ****
Function function,
EvaluationCtx context) {
! return anyOfAnyOrAllHelper(anyBag, allBag, function, context, false,
! true);
}
/**
! * Generic code for the any-of-any and all-of-any/any-of-all routines
*/
! private EvaluationResult anyOfAnyOrAllHelper(BagAttribute bag1,
! BagAttribute bag2,
! Function function,
! EvaluationCtx context,
! boolean any, boolean swap) {
! Iterator it = bag1.iterator();
!
while (it.hasNext()) {
- EvaluationResult result;
AttributeValue value = (AttributeValue)(it.next());
!
! if (any)
! result = anyAndAllHelper(value, bag2, function, context,
! false, swap);
! else
! result = anyAndAllHelper(value, bag2, function, context,
! true, swap);
if (result.indeterminate())
return result;
! if (((BooleanAttribute)(result.
! getAttributeValue())).getValue())
return result;
}
!
! return new EvaluationResult(BooleanAttribute.getFalseInstance());
}
--- 495,525 ----
Function function,
EvaluationCtx context) {
! return allAnyHelper(anyBag, allBag, function, context, false);
}
/**
! * Private helper for the all-of-any and any-of-all functions
*/
! private EvaluationResult allAnyHelper(BagAttribute anyBag,
! BagAttribute allBag,
! Function function,
! EvaluationCtx context,
! boolean argumentsAreSwapped) {
! Iterator it = allBag.iterator();
!
while (it.hasNext()) {
AttributeValue value = (AttributeValue)(it.next());
! EvaluationResult result =
! any(value, anyBag, function, context, argumentsAreSwapped);
if (result.indeterminate())
return result;
! if (! ((BooleanAttribute)(result.
! getAttributeValue())).getValue())
return result;
}
!
! return new EvaluationResult(BooleanAttribute.getTrueInstance());
}
|