Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond
In directory sc8-pr-cvs1:/tmp/cvs-serv22245/cond
Modified Files:
Apply.java Evaluatable.java Function.java
Log Message:
updated all existing encoding and added new encoding routines for all policy
related elements
Index: Apply.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Apply.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Apply.java 11 Aug 2003 20:48:45 -0000 1.3
--- Apply.java 25 Aug 2003 16:53:10 -0000 1.4
***************
*** 38,41 ****
--- 38,42 ----
import com.sun.xacml.EvaluationCtx;
+ import com.sun.xacml.Indenter;
import com.sun.xacml.ParsingException;
import com.sun.xacml.UnknownIdentifierException;
***************
*** 46,49 ****
--- 47,53 ----
import com.sun.xacml.attr.AttributeValue;
+ import java.io.OutputStream;
+ import java.io.PrintStream;
+
import java.net.URI;
***************
*** 74,77 ****
--- 78,84 ----
private Function bagFunction;
+ // whether or not this is a condition
+ private boolean isCondition;
+
/**
* Constructs an <code>Apply</code> object. Throws an
***************
*** 84,92 ****
* to the function, each of which is an
* <code>Evaluatable</code>
*/
! public Apply(Function function, List evals)
throws IllegalArgumentException
{
! this(function, evals, null);
}
--- 91,101 ----
* to the function, each of which is an
* <code>Evaluatable</code>
+ * @param isCondition true if this <code>Apply</code> is a Condition,
+ * false otherwise
*/
! public Apply(Function function, List evals, boolean isCondition)
throws IllegalArgumentException
{
! this(function, evals, null, isCondition);
}
***************
*** 102,107 ****
* <code>Evaluatable</code>
* @param bagFunction the higher-order function to use
*/
! public Apply(Function function, List evals, Function bagFunction)
throws IllegalArgumentException
{
--- 111,119 ----
* <code>Evaluatable</code>
* @param bagFunction the higher-order function to use
+ * @param isCondition true if this <code>Apply</code> is a Condition,
+ * false otherwise
*/
! public Apply(Function function, List evals, Function bagFunction,
! boolean isCondition)
throws IllegalArgumentException
{
***************
*** 119,122 ****
--- 131,135 ----
this.evals = Collections.unmodifiableList(evals);
this.bagFunction = bagFunction;
+ this.isCondition = isCondition;
}
***************
*** 136,140 ****
throws ParsingException
{
! return getInstance(root, FunctionFactory.getConditionInstance());
}
--- 149,153 ----
throws ParsingException
{
! return getInstance(root, FunctionFactory.getConditionInstance(), true);
}
***************
*** 149,153 ****
throws ParsingException
{
! return getInstance(root, FunctionFactory.getGeneralInstance());
}
--- 162,166 ----
throws ParsingException
{
! return getInstance(root, FunctionFactory.getGeneralInstance(), false);
}
***************
*** 157,161 ****
* kind of function.
*/
! private static Apply getInstance(Node root, FunctionFactory factory)
throws ParsingException
{
--- 170,175 ----
* kind of function.
*/
! private static Apply getInstance(Node root, FunctionFactory factory,
! boolean isCondition)
throws ParsingException
{
***************
*** 207,211 ****
}
! return new Apply(function, evals, bagFunction);
}
--- 221,225 ----
}
! return new Apply(function, evals, bagFunction, isCondition);
}
***************
*** 327,330 ****
--- 341,392 ----
public boolean evaluatesToBag() {
return function.returnsBag();
+ }
+
+ /**
+ * Encodes this <code>Apply</code> into its XML representation and
+ * writes this encoding to the given <code>OutputStream</code> with no
+ * indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ */
+ public void encode(OutputStream output) {
+ encode(output, new Indenter(0));
+ }
+
+ /**
+ * Encodes this <code>Apply</code> into its XML representation and
+ * writes this encoding to the given <code>OutputStream</code> with
+ * indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ * @param indenter an object that creates indentation strings
+ */
+ public void encode(OutputStream output, Indenter indenter) {
+ PrintStream out = new PrintStream(output);
+ String indent = indenter.makeString();
+
+ if (isCondition)
+ out.println(indent + "<Condition FunctionId=\"" +
+ function.getIdentifier() + "\">");
+ else
+ out.println(indent + "<Apply FunctionId=\"" +
+ function.getIdentifier() + "\">");
+ indenter.in();
+
+ if (bagFunction != null)
+ out.println("<Function FunctionId=\"" +
+ bagFunction.getIdentifier() + "\"/>");
+
+ Iterator it = evals.iterator();
+ while (it.hasNext()) {
+ Evaluatable eval = (Evaluatable)(it.next());
+ eval.encode(output, indenter);
+ }
+
+ indenter.out();
+ if (isCondition)
+ out.println(indent + "</Condition>");
+ else
+ out.println(indent + "</Apply>");
}
Index: Evaluatable.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Evaluatable.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Evaluatable.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- Evaluatable.java 25 Aug 2003 16:53:10 -0000 1.2
***************
*** 38,44 ****
--- 38,47 ----
import com.sun.xacml.EvaluationCtx;
+ import com.sun.xacml.Indenter;
import com.sun.xacml.attr.AttributeValue;
+ import java.io.OutputStream;
+
import java.net.URI;
***************
*** 80,83 ****
--- 83,105 ----
*/
public boolean evaluatesToBag();
+
+ /**
+ * Encodes this <code>Evaluatable</code> into its XML representation and
+ * writes this encoding to the given <code>OutputStream</code> with no
+ * indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ */
+ public void encode(OutputStream output);
+
+ /**
+ * Encodes this <code>Evaluatable</code> into its XML representation and
+ * writes this encoding to the given <code>OutputStream</code> with
+ * indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ * @param indenter an object that creates indentation strings
+ */
+ public void encode(OutputStream output, Indenter indenter);
}
Index: Function.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Function.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Function.java 29 Jul 2003 22:01:47 -0000 1.2
--- Function.java 25 Aug 2003 16:53:10 -0000 1.3
***************
*** 96,99 ****
--- 96,101 ----
* URIs defined in the standard namespace. This function must always
* return the complete namespace and identifier of this function.
+ *
+ * @return the function's identifier
*/
public URI getIdentifier();
|