Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond
In directory sc8-pr-cvs1:/tmp/cvs-serv22177/com/sun/xacml/cond
Modified Files:
Apply.java Function.java FunctionBase.java
HigherOrderFunction.java MapFunction.java
Log Message:
Added accessor methods for Target-related and Function-related classes
Index: Apply.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Apply.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Apply.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- Apply.java 29 Jul 2003 22:01:47 -0000 1.2
***************
*** 49,52 ****
--- 49,53 ----
import java.util.ArrayList;
+ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
***************
*** 80,85 ****
* @param function the <code>Function</code> to use in evaluating the
* elements in the apply
! * @param evals the contents of the apply, which will be the parameters
! * to the function
*/
public Apply(Function function, List evals)
--- 81,87 ----
* @param function the <code>Function</code> to use in evaluating the
* elements in the apply
! * @param evals the contents of the apply which will be the parameters
! * to the function, each of which is an
! * <code>Evaluatable</code>
*/
public Apply(Function function, List evals)
***************
*** 96,101 ****
* @param function the <code>Function</code> to use in evaluating the
* elements in the apply
! * @param evals the contents of the apply, which will be the parameters
! * to the function
* @param bagFunction the higher-order function to use
*/
--- 98,104 ----
* @param function the <code>Function</code> to use in evaluating the
* elements in the apply
! * @param evals the contents of the apply which will be the parameters
! * to the function, each of which is an
! * <code>Evaluatable</code>
* @param bagFunction the higher-order function to use
*/
***************
*** 114,118 ****
// if everything checks out, then store the inputs
this.function = function;
! this.evals = evals;
this.bagFunction = bagFunction;
}
--- 117,121 ----
// if everything checks out, then store the inputs
this.function = function;
! this.evals = Collections.unmodifiableList(evals);
this.bagFunction = bagFunction;
}
***************
*** 232,235 ****
--- 235,268 ----
}
}
+ }
+
+ /**
+ * Returns the <code>Function</code> used by this <code>Apply</code>.
+ *
+ * @return the <code>Function</code>
+ */
+ public Function getFunction() {
+ return function;
+ }
+
+ /**
+ * Returns the <code>List</code> of children for this <code>Apply</code>.
+ * The <code>List</code> contains <code>Evaluatable</code>s. The list is
+ * unmodifiable.
+ *
+ * @return a <code>List</code> of <code>Evaluatable</code>s
+ */
+ public List getChildren() {
+ return evals;
+ }
+
+ /**
+ * Returns the higher order bag function used by this <code>Apply</code>
+ * if it exists, or null if no higher order function is used.
+ *
+ * @return the higher order <code>Function</code> or null
+ */
+ public Function getHigherOrderFunction() {
+ return bagFunction;
}
Index: Function.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Function.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Function.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- Function.java 29 Jul 2003 22:01:47 -0000 1.2
***************
*** 92,95 ****
--- 92,103 ----
/**
+ * Returns the identifier of this function as known by the factories.
+ * In the case of the standard XACML functions, this will be one of the
+ * URIs defined in the standard namespace. This function must always
+ * return the complete namespace and identifier of this function.
+ */
+ public URI getIdentifier();
+
+ /**
* Provides the type of <code>AttributeValue</code> that this function
* returns from <code>evaluate</code> in a successful evaluation.
Index: FunctionBase.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/FunctionBase.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** FunctionBase.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- FunctionBase.java 29 Jul 2003 22:01:47 -0000 1.2
***************
*** 44,47 ****
--- 44,48 ----
import java.net.URI;
+ import java.net.URISyntaxException;
import java.util.ArrayList;
***************
*** 221,224 ****
--- 222,243 ----
/**
+ * Returns the full identifier of this function, as known by the factories.
+ *
+ * @return the function's identifier
+ *
+ * @throws IllegalArgumentException if the identifier isn't a valid URI
+ */
+ public URI getIdentifier() {
+ // this is to get around the exception handling problems, but may
+ // change if this code changes to include exceptions from the
+ // constructors
+ try {
+ return new URI(functionName);
+ } catch (URISyntaxException use) {
+ throw new IllegalArgumentException("invalid URI");
+ }
+ }
+
+ /**
* Returns the name of the function to be handled by this particular
* object.
***************
*** 244,248 ****
*
* @return a <code>URI</code> indicating the attribute type
! * returned by this function ("boolean", in this case)
*/
public URI getReturnType() {
--- 263,267 ----
*
* @return a <code>URI</code> indicating the attribute type
! * returned by this function
*/
public URI getReturnType() {
Index: HigherOrderFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/HigherOrderFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** HigherOrderFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- HigherOrderFunction.java 29 Jul 2003 22:01:47 -0000 1.2
***************
*** 44,47 ****
--- 44,48 ----
import java.net.URI;
+ import java.net.URISyntaxException;
import java.util.ArrayList;
***************
*** 92,98 ****
private static final int ID_ALL_OF_ALL = 5;
! //
private int functionId;
// should the second argument (the first arg passed to the sub-function)
// be a bag
--- 93,102 ----
private static final int ID_ALL_OF_ALL = 5;
! // the internal identifier for each function
private int functionId;
+ // the real identifier for each function
+ private URI identifier;
+
// should the second argument (the first arg passed to the sub-function)
// be a bag
***************
*** 119,133 ****
public static void addConditionFunctions(Map functionMap) {
functionMap.put(NAME_ANY_OF,
! new HigherOrderFunction(ID_ANY_OF));
functionMap.put(NAME_ALL_OF,
! new HigherOrderFunction(ID_ALL_OF));
functionMap.put(NAME_ANY_OF_ANY,
! new HigherOrderFunction(ID_ANY_OF_ANY));
functionMap.put(NAME_ALL_OF_ANY,
! new HigherOrderFunction(ID_ALL_OF_ANY));
functionMap.put(NAME_ANY_OF_ALL,
! new HigherOrderFunction(ID_ANY_OF_ALL));
functionMap.put(NAME_ALL_OF_ALL,
! new HigherOrderFunction(ID_ALL_OF_ALL));
}
--- 123,141 ----
public static void addConditionFunctions(Map functionMap) {
functionMap.put(NAME_ANY_OF,
! new HigherOrderFunction(ID_ANY_OF, NAME_ANY_OF));
functionMap.put(NAME_ALL_OF,
! new HigherOrderFunction(ID_ALL_OF, NAME_ALL_OF));
functionMap.put(NAME_ANY_OF_ANY,
! new HigherOrderFunction(ID_ANY_OF_ANY,
! NAME_ANY_OF_ANY));
functionMap.put(NAME_ALL_OF_ANY,
! new HigherOrderFunction(ID_ALL_OF_ANY,
! NAME_ALL_OF_ANY));
functionMap.put(NAME_ANY_OF_ALL,
! new HigherOrderFunction(ID_ANY_OF_ALL,
! NAME_ANY_OF_ALL));
functionMap.put(NAME_ALL_OF_ALL,
! new HigherOrderFunction(ID_ALL_OF_ALL,
! NAME_ALL_OF_ALL));
}
***************
*** 135,141 ****
* Creates a new instance of the given kind of function.
*/
! private HigherOrderFunction(int functionId) {
this.functionId = functionId;
// see if the second arg is a bag
if ((functionId != ID_ANY_OF) && (functionId != ID_ALL_OF))
--- 143,155 ----
* Creates a new instance of the given kind of function.
*/
! private HigherOrderFunction(int functionId, String functionName) {
this.functionId = functionId;
+ try {
+ identifier = new URI(functionName);
+ } catch (URISyntaxException use) {
+ throw new IllegalArgumentException("invalid URI");
+ }
+
// see if the second arg is a bag
if ((functionId != ID_ANY_OF) && (functionId != ID_ALL_OF))
***************
*** 143,146 ****
--- 157,169 ----
else
secondIsBag = false;
+ }
+
+ /**
+ * Returns the full identifier of this function, as known by the factories.
+ *
+ * @return the function's identifier
+ */
+ public URI getIdentifier() {
+ return identifier;
}
Index: MapFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/MapFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** MapFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- MapFunction.java 29 Jul 2003 22:01:47 -0000 1.2
***************
*** 72,75 ****
--- 72,90 ----
private URI returnType;
+ // the stuff used to make sure that we have a valid identifier or a
+ // known error, just like in the attribute classes
+ private static URI identifier;
+ private static RuntimeException earlyException;
+
+ // try to initialize the identifier
+ static {
+ try {
+ identifier = new URI(NAME);
+ } catch (Exception e) {
+ earlyException = new IllegalArgumentException();
+ earlyException.initCause(e);
+ }
+ };
+
/**
* Creates a new instance of a <code>MapFunction</code>.
***************
*** 130,133 ****
--- 145,161 ----
return new MapFunction(returnType);
+ }
+
+ /**
+ * Returns the full identifier of this function, as known by the factories.
+ *
+ * @return the function's identifier
+ */
+ public URI getIdentifier() {
+ // strictly speaking, this should never happen
+ if (earlyException != null)
+ throw earlyException;
+
+ return identifier;
}
|