SunTM's XACML Implementation for JavaTM

com.sun.xacml.cond
Class FunctionBase

java.lang.Object
  extended bycom.sun.xacml.cond.FunctionBase
All Implemented Interfaces:
Function
Direct Known Subclasses:
AbsFunction, AddFunction, BagFunction, ComparisonFunction, DateMathFunction, DivideFunction, EqualFunction, FloorFunction, LogicalFunction, MatchFunction, ModFunction, MultiplyFunction, NOfFunction, NotFunction, NumericConvertFunction, RoundFunction, SetFunction, StringNormalizeFunction, SubtractFunction

public abstract class FunctionBase
extends Object
implements Function

An abstract utility superclass for functions. Supplies several useful methods, making it easier to implement a Function. You can extend this class or implement Function directly, depending on your needs.

Since:
1.0

Field Summary
static String FUNCTION_NS
          The standard namespace where all the spec-defined functions live
 
Constructor Summary
FunctionBase(String functionName, int functionId, String[] paramTypes, boolean[] paramIsBag, String returnType, boolean returnsBag)
          Constructor that sets up the function as having different types for each given parameter.
FunctionBase(String functionName, int functionId, String returnType, boolean returnsBag)
          Constructor that sets up some basic values for functions that will take care of parameter checking on their own.
FunctionBase(String functionName, int functionId, String paramType, boolean paramIsBag, int numParams, int minParams, String returnType, boolean returnsBag)
          Constructor that sets up the function as having some number of parameters all of the same given type.
FunctionBase(String functionName, int functionId, String paramType, boolean paramIsBag, int numParams, String returnType, boolean returnsBag)
          Constructor that sets up the function as having some number of parameters all of the same given type.
 
Method Summary
 void checkInputs(List inputs)
          Default handling of input checking.
 void checkInputsNoBag(List inputs)
          Default handling of input checking.
protected  EvaluationResult evalArgs(List params, EvaluationCtx context, AttributeValue[] args)
          Evaluates each of the parameters, in order, filling in the argument array with the resulting values.
 int getFunctionId()
          Returns the Identifier of the function to be handled by this particular object.
 String getFunctionName()
          Returns the name of the function to be handled by this particular object.
 URI getIdentifier()
          Returns the full identifier of this function, as known by the factories.
 URI getReturnType()
          Get the attribute type returned by this function.
 String getReturnTypeAsString()
          Returns the return type for this particular object.
protected static EvaluationResult makeProcessingError(String message)
          Create an EvaluationResult that indicates a processing error with the specified message.
 boolean returnsBag()
          Returns true if this function returns a bag of values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.xacml.cond.Function
evaluate
 

Field Detail

FUNCTION_NS

public static final String FUNCTION_NS
The standard namespace where all the spec-defined functions live

See Also:
Constant Field Values
Constructor Detail

FunctionBase

public FunctionBase(String functionName,
                    int functionId,
                    String paramType,
                    boolean paramIsBag,
                    int numParams,
                    String returnType,
                    boolean returnsBag)
Constructor that sets up the function as having some number of parameters all of the same given type. If numParams is -1, then the length is variable

Parameters:
functionName - the name of this function as used by the factory and any XACML policies
functionId - an optional identifier that can be used by your code for convenience
paramType - the type of all parameters to this function, as used by the factory and any XACML documents
paramIsBag - whether or not every parameter is actually a bag of values
numParams - the number of parameters required by this function, or -1 if any number are allowed
returnType - the type returned by this function, as used by the factory and any XACML documents
returnsBag - whether or not this function returns a bag of values

FunctionBase

public FunctionBase(String functionName,
                    int functionId,
                    String paramType,
                    boolean paramIsBag,
                    int numParams,
                    int minParams,
                    String returnType,
                    boolean returnsBag)
Constructor that sets up the function as having some number of parameters all of the same given type. If numParams is -1, then the length is variable, and then minParams may be used to specify a minimum number of parameters. If numParams is not -1, then minParams is ignored.

Parameters:
functionName - the name of this function as used by the factory and any XACML policies
functionId - an optional identifier that can be used by your code for convenience
paramType - the type of all parameters to this function, as used by the factory and any XACML documents
paramIsBag - whether or not every parameter is actually a bag of values
numParams - the number of parameters required by this function, or -1 if any number are allowed
minParams - the minimum number of parameters required if numParams is -1
returnType - the type returned by this function, as used by the factory and any XACML documents
returnsBag - whether or not this function returns a bag of values

FunctionBase

public FunctionBase(String functionName,
                    int functionId,
                    String[] paramTypes,
                    boolean[] paramIsBag,
                    String returnType,
                    boolean returnsBag)
Constructor that sets up the function as having different types for each given parameter.

Parameters:
functionName - the name of this function as used by the factory and any XACML policies
functionId - an optional identifier that can be used by your code for convenience
paramTypes - the type of each parameter, in order, required by this function, as used by the factory and any XACML documents
paramIsBag - whether or not each parameter is actually a bag of values
returnType - the type returned by this function, as used by the factory and any XACML documents
returnsBag - whether or not this function returns a bag of values

FunctionBase

public FunctionBase(String functionName,
                    int functionId,
                    String returnType,
                    boolean returnsBag)
Constructor that sets up some basic values for functions that will take care of parameter checking on their own. If you use this constructor for your function class, then you must override the two check methods to make sure that parameters are correct.

Parameters:
functionName - the name of this function as used by the factory and any XACML policies
functionId - an optional identifier that can be used by your code for convenience
returnType - the type returned by this function, as used by the factory and any XACML documents
returnsBag - whether or not this function returns a bag of values
Method Detail

getIdentifier

public URI getIdentifier()
Returns the full identifier of this function, as known by the factories.

Specified by:
getIdentifier in interface Function
Returns:
the function's identifier
Throws:
IllegalArgumentException - if the identifier isn't a valid URI

getFunctionName

public String getFunctionName()
Returns the name of the function to be handled by this particular object.

Returns:
the function name

getFunctionId

public int getFunctionId()
Returns the Identifier of the function to be handled by this particular object.

Returns:
the function Id

getReturnType

public URI getReturnType()
Get the attribute type returned by this function.

Specified by:
getReturnType in interface Function
Returns:
a URI indicating the attribute type returned by this function

returnsBag

public boolean returnsBag()
Returns true if this function returns a bag of values.

Specified by:
returnsBag in interface Function
Returns:
true if the function returns a bag, false otherwise

getReturnTypeAsString

public String getReturnTypeAsString()
Returns the return type for this particular object.

Returns:
the return type

makeProcessingError

protected static EvaluationResult makeProcessingError(String message)
Create an EvaluationResult that indicates a processing error with the specified message. This method may be useful to subclasses.

Parameters:
message - a description of the error (null if none)
Returns:
the desired EvaluationResult

evalArgs

protected EvaluationResult evalArgs(List params,
                                    EvaluationCtx context,
                                    AttributeValue[] args)
Evaluates each of the parameters, in order, filling in the argument array with the resulting values. If any error occurs, this method returns the error, otherwise null is returned, signalling that evaluation was successful for all inputs, and the resulting argument list can be used.

Parameters:
params - a List of Evaluatable objects representing the parameters to evaluate
context - the representation of the request
args - an array as long as the params List that will, on return, contain the AttributeValues generated from evaluating all parameters
Returns:
null if no errors were encountered, otherwise an EvaluationResult representing the error

checkInputs

public void checkInputs(List inputs)
                 throws IllegalArgumentException
Default handling of input checking. This does some simple checking based on the type of constructor used. If you need anything more complex, or if you used the simple constructor, then you must override this method.

Specified by:
checkInputs in interface Function
Parameters:
inputs - a List> of Evaluatables
Throws:
IllegalArgumentException - if the inputs won't work

checkInputsNoBag

public void checkInputsNoBag(List inputs)
                      throws IllegalArgumentException
Default handling of input checking. This does some simple checking based on the type of constructor used. If you need anything more complex, or if you used the simple constructor, then you must override this method.

Specified by:
checkInputsNoBag in interface Function
Parameters:
inputs - a List> of Evaluatables
Throws:
IllegalArgumentException - if the inputs won't work

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.