org.jboss.security.xacml.sunxacml.cond
Class Condition

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.cond.Condition
All Implemented Interfaces:
Evaluatable, Expression

public class Condition
extends Object
implements Evaluatable

Represents the XACML ConditionType type. It contains exactly one child expression that is boolean and returns a single value. This class was added in XACML 2.0

Since:
2.0
Author:
Seth Proctor

Constructor Summary
Condition(Expression expression)
          Constructs a Condition as used in XACML 2.0.
Condition(Function function, List expressions)
          Constructs a Condition as used in XACML 1.x.
 
Method Summary
 void encode(OutputStream output)
          Encodes this Condition into its XML representation and writes this encoding to the given OutputStream with no indentation.
 void encode(OutputStream output, Indenter indenter)
          Encodes this Condition into its XML representation and writes this encoding to the given OutputStream with indentation.
 EvaluationResult evaluate(EvaluationCtx context)
          Evaluates the Condition by evaluating its child Expression.
 boolean evaluatesToBag()
          Deprecated. As of 2.0, you should use the returnsBag method from the super-interface Expression.
 List getChildren()
          Returns the List of children for this Condition.
 Function getFunction()
          Returns the Function used by this Condition if this is a 1.x condition, or null if this is a 2.0 condition.
static Condition getInstance(Node root, PolicyMetaData metaData, VariableManager manager)
          Returns an instance of Condition based on the given DOM root.
 URI getType()
          Returns the type of attribute that this object will return on a call to evaluate.
 boolean returnsBag()
          Returns whether or not this Condition will return a bag of values on evaluation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition

public Condition(Function function,
                 List expressions)
          throws IllegalArgumentException
Constructs a Condition as used in XACML 1.x.

Parameters:
function - the Function to use in evaluating the elements in the Condition
xprs - the contents of the Condition which will be the parameters to the function, each of which is an Expression
Throws:
IllegalArgumentException - if the input expressions don't match the signature of the function or if the function is invalid for use in a Condition

Condition

public Condition(Expression expression)
          throws IllegalArgumentException
Constructs a Condition as used in XACML 2.0.

Parameters:
expression - the child Expression
Throws:
IllegalArgumentException - if the expression is not boolean or returns a bag
Method Detail

getInstance

public static Condition getInstance(Node root,
                                    PolicyMetaData metaData,
                                    VariableManager manager)
                             throws ParsingException
Returns an instance of Condition based on the given DOM root.

Parameters:
root - the DOM root of a ConditionType XML type
metaData - the meta-data associated with the containing policy
manager - VariableManager used to connect references and definitions while parsing
Throws:
ParsingException - if this is not a valid ConditionType

getFunction

public Function getFunction()
Returns the Function used by this Condition if this is a 1.x condition, or null if this is a 2.0 condition.

Returns:
a Function or null

getChildren

public List getChildren()
Returns the List of children for this Condition. The List contains Expressions. The list is unmodifiable.

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

getType

public URI getType()
Returns the type of attribute that this object will return on a call to evaluate. This is always a boolean, since that's all that a Condition is allowed to return.

Specified by:
getType in interface Expression
Returns:
the boolean type

returnsBag

public boolean returnsBag()
Returns whether or not this Condition will return a bag of values on evaluation. This always returns false, since a Condition isn't allowed to return a bag.

Specified by:
returnsBag in interface Expression
Returns:
false

evaluatesToBag

public boolean evaluatesToBag()
Deprecated. As of 2.0, you should use the returnsBag method from the super-interface Expression.

Returns whether or not this Condition will return a bag of values on evaluation. This always returns false, since a Condition isn't allowed to return a bag.

Specified by:
evaluatesToBag in interface Evaluatable
Returns:
false

evaluate

public EvaluationResult evaluate(EvaluationCtx context)
Evaluates the Condition by evaluating its child Expression.

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

encode

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

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

encode

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

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


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.