SunTM's XACML Implementation for JavaTM

com.sun.xacml.cond
Class Apply

java.lang.Object
  extended bycom.sun.xacml.cond.Apply
All Implemented Interfaces:
Evaluatable

public class Apply
extends Object
implements Evaluatable

Represents the XACML ApplyType and ConditionType XML types.

Since:
1.0

Constructor Summary
Apply(Function function, List evals, boolean isCondition)
          Constructs an Apply object.
Apply(Function function, List evals, Function bagFunction, boolean isCondition)
          Constructs an Apply object that contains a higher-order bag function.
 
Method Summary
 void encode(OutputStream output)
          Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with no indentation.
 void encode(OutputStream output, Indenter indenter)
          Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with indentation.
 EvaluationResult evaluate(EvaluationCtx context)
          Evaluates the apply object using the given function.
 boolean evaluatesToBag()
          Returns whether or not the Function will return a bag of values on evaluation.
 List getChildren()
          Returns the List of children for this Apply.
static Apply getConditionInstance(Node root, String xpathVersion)
          Returns an instance of an Apply based on the given DOM root node.
 Function getFunction()
          Returns the Function used by this Apply.
 Function getHigherOrderFunction()
          Returns the higher order bag function used by this Apply if it exists, or null if no higher order function is used.
static Apply getInstance(Node root, String xpathVersion)
          Returns an instance of Apply based on the given DOM root.
 URI getType()
          Returns the type of attribute that this object will return on a call to evaluate.
 boolean isCondition()
          Returns whether or not this ApplyType is actually a ConditionType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Apply

public Apply(Function function,
             List evals,
             boolean isCondition)
      throws IllegalArgumentException
Constructs an Apply object. Throws an IllegalArgumentException if the given parameter list isn't valid for the given function.

Parameters:
function - the Function to use in evaluating the elements in the apply
evals - the contents of the apply which will be the parameters to the function, each of which is an Evaluatable
isCondition - true if this Apply is a Condition, false otherwise

Apply

public Apply(Function function,
             List evals,
             Function bagFunction,
             boolean isCondition)
      throws IllegalArgumentException
Constructs an Apply object that contains a higher-order bag function. Throws an IllegalArgumentException if the given parameter list isn't valid for the given function.

Parameters:
function - the Function to use in evaluating the elements in the apply
evals - the contents of the apply which will be the parameters to the function, each of which is an Evaluatable
bagFunction - the higher-order function to use
isCondition - true if this Apply is a Condition, false otherwise
Method Detail

getConditionInstance

public static Apply getConditionInstance(Node root,
                                         String xpathVersion)
                                  throws ParsingException
Returns an instance of an Apply based on the given DOM root node. This will actually return a special kind of Apply, namely an XML ConditionType, which is the root of the condition logic in a RuleType. A ConditionType is the same as an ApplyType except that it must use a FunctionId that returns a boolean value.

Parameters:
root - the DOM root of a ConditionType XML type
xpathVersion - the XPath version to use in any selectors or XPath functions, or null if this is unspecified (ie, not supplied in the defaults section of the policy)
Throws:
ParsingException - if this is not a valid ConditionType

getInstance

public static Apply getInstance(Node root,
                                String xpathVersion)
                         throws ParsingException
Returns an instance of Apply based on the given DOM root.

Parameters:
root - the DOM root of an ApplyType XML type
xpathVersion - the XPath version to use in any selectors or XPath functions, or null if this is unspecified (ie, not supplied in the defaults section of the policy)
Throws:
ParsingException - if this is not a valid ApplyType

getFunction

public Function getFunction()
Returns the Function used by this Apply.

Returns:
the Function

getChildren

public List getChildren()
Returns the List of children for this Apply. The List contains Evaluatables. The list is unmodifiable, and may be empty.

Specified by:
getChildren in interface Evaluatable
Returns:
a List of Evaluatables

getHigherOrderFunction

public Function getHigherOrderFunction()
Returns the higher order bag function used by this Apply if it exists, or null if no higher order function is used.

Returns:
the higher order Function or null

isCondition

public boolean isCondition()
Returns whether or not this ApplyType is actually a ConditionType.

Returns:
whether or not this represents a ConditionType

evaluate

public EvaluationResult evaluate(EvaluationCtx context)
Evaluates the apply object using the given function. This will in turn call evaluate on all the given parameters, some of which may be other Apply objects.

Specified by:
evaluate in interface Evaluatable
Parameters:
context - the representation of the request
Returns:
the result of trying to evaluate this apply object

getType

public URI getType()
Returns the type of attribute that this object will return on a call to evaluate. In practice, this will always be the same as the result of calling getReturnType on the function used by this object.

Specified by:
getType in interface Evaluatable
Returns:
the type returned by evaluate

evaluatesToBag

public boolean evaluatesToBag()
Returns whether or not the Function will return a bag of values on evaluation.

Specified by:
evaluatesToBag in interface Evaluatable
Returns:
true if evaluation will return a bag of values, false otherwise

encode

public void encode(OutputStream output)
Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with no indentation.

Specified by:
encode in interface Evaluatable
Parameters:
output - a stream into which the XML-encoded data is written

encode

public void encode(OutputStream output,
                   Indenter indenter)
Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with indentation.

Specified by:
encode in interface Evaluatable
Parameters:
output - a stream into which the XML-encoded data is written
indenter - an object that creates indentation strings

Sun's XACML Implementation Version 1.2

Copyright 2003-2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

Sun, Sun Microsystems, the Sun Logo, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.