Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.sun.xacml.cond
Class ComparisonFunction  view ComparisonFunction download ComparisonFunction.java

java.lang.Object
  extended bycom.sun.xacml.cond.FunctionBase
      extended bycom.sun.xacml.cond.ComparisonFunction
All Implemented Interfaces:
Function

public class ComparisonFunction
extends FunctionBase

A class that implements all of the standard comparison functions.

Since:
1.0

Field Summary
private static int ID_DATE_GREATER_THAN
           
private static int ID_DATE_GREATER_THAN_OR_EQUAL
           
private static int ID_DATE_LESS_THAN
           
private static int ID_DATE_LESS_THAN_OR_EQUAL
           
private static int ID_DATETIME_GREATER_THAN
           
private static int ID_DATETIME_GREATER_THAN_OR_EQUAL
           
private static int ID_DATETIME_LESS_THAN
           
private static int ID_DATETIME_LESS_THAN_OR_EQUAL
           
private static int ID_DOUBLE_GREATER_THAN
           
private static int ID_DOUBLE_GREATER_THAN_OR_EQUAL
           
private static int ID_DOUBLE_LESS_THAN
           
private static int ID_DOUBLE_LESS_THAN_OR_EQUAL
           
private static int ID_INTEGER_GREATER_THAN
           
private static int ID_INTEGER_GREATER_THAN_OR_EQUAL
           
private static int ID_INTEGER_LESS_THAN
           
private static int ID_INTEGER_LESS_THAN_OR_EQUAL
           
private static int ID_STRING_GREATER_THAN
           
private static int ID_STRING_GREATER_THAN_OR_EQUAL
           
private static int ID_STRING_LESS_THAN
           
private static int ID_STRING_LESS_THAN_OR_EQUAL
           
private static int ID_TIME_GREATER_THAN
           
private static int ID_TIME_GREATER_THAN_OR_EQUAL
           
private static int ID_TIME_LESS_THAN
           
private static int ID_TIME_LESS_THAN_OR_EQUAL
           
private static java.util.HashMap idMap
           
static java.lang.String NAME_DATE_GREATER_THAN
          Standard identifier for the date-greater-than function.
static java.lang.String NAME_DATE_GREATER_THAN_OR_EQUAL
          Standard identifier for the date-greater-than-or-equal function.
static java.lang.String NAME_DATE_LESS_THAN
          Standard identifier for the date-less-than function.
static java.lang.String NAME_DATE_LESS_THAN_OR_EQUAL
          Standard identifier for the date-less-than-or-equal function.
static java.lang.String NAME_DATETIME_GREATER_THAN
          Standard identifier for the dateTime-greater-than function.
static java.lang.String NAME_DATETIME_GREATER_THAN_OR_EQUAL
          Standard identifier for the dateTime-greater-than-or-equal function.
static java.lang.String NAME_DATETIME_LESS_THAN
          Standard identifier for the dateTime-less-than function.
static java.lang.String NAME_DATETIME_LESS_THAN_OR_EQUAL
          Standard identifier for the dateTime-less-than-or-equal function.
static java.lang.String NAME_DOUBLE_GREATER_THAN
          Standard identifier for the double-greater-than function.
static java.lang.String NAME_DOUBLE_GREATER_THAN_OR_EQUAL
          Standard identifier for the double-greater-than-or-equal function.
static java.lang.String NAME_DOUBLE_LESS_THAN
          Standard identifier for the double-less-than function.
static java.lang.String NAME_DOUBLE_LESS_THAN_OR_EQUAL
          Standard identifier for the double-less-than-or-equal function.
static java.lang.String NAME_INTEGER_GREATER_THAN
          Standard identifier for the integer-greater-than function.
static java.lang.String NAME_INTEGER_GREATER_THAN_OR_EQUAL
          Standard identifier for the integer-greater-than-or-equal function.
static java.lang.String NAME_INTEGER_LESS_THAN
          Standard identifier for the integer-less-than function.
static java.lang.String NAME_INTEGER_LESS_THAN_OR_EQUAL
          Standard identifier for the integer-less-than-or-equal function.
static java.lang.String NAME_STRING_GREATER_THAN
          Standard identifier for the string-greater-than function.
static java.lang.String NAME_STRING_GREATER_THAN_OR_EQUAL
          Standard identifier for the string-greater-than-or-equal function.
static java.lang.String NAME_STRING_LESS_THAN
          Standard identifier for the string-less-than function.
static java.lang.String NAME_STRING_LESS_THAN_OR_EQUAL
          Standard identifier for the string-less-than-or-equal function.
static java.lang.String NAME_TIME_GREATER_THAN
          Standard identifier for the time-greater-than function.
static java.lang.String NAME_TIME_GREATER_THAN_OR_EQUAL
          Standard identifier for the time-greater-than-or-equal function.
static java.lang.String NAME_TIME_LESS_THAN
          Standard identifier for the time-less-than function.
static java.lang.String NAME_TIME_LESS_THAN_OR_EQUAL
          Standard identifier for the time-less-than-or-equal function.
private static java.util.HashMap typeMap
           
 
Fields inherited from class com.sun.xacml.cond.FunctionBase
FUNCTION_NS
 
Constructor Summary
ComparisonFunction(java.lang.String functionName)
          Creates a new ComparisonFunction object.
 
Method Summary
private  int dateCompare(java.util.Date d1, int n1, java.util.Date d2, int n2)
          Helper function to compare two Date objects and their associated nanosecond values.
private  int doubleCompare(double d1, double d2)
          Helper function that does a comparison of the two doubles using the rules of XMLSchema.
 EvaluationResult evaluate(java.util.List inputs, com.sun.xacml.EvaluationCtx context)
          Evaluate the function, using the specified parameters.
private static java.lang.String getArgumentType(java.lang.String functionName)
          Private helper that returns the type used for the given standard function.
private static int getId(java.lang.String functionName)
          Private helper that returns the internal identifier used for the given standard function.
static java.util.Set getSupportedIdentifiers()
          Returns a Set containing all the function identifiers supported by this class.
 
Methods inherited from class com.sun.xacml.cond.FunctionBase
checkInputs, checkInputsNoBag, evalArgs, getFunctionId, getFunctionName, getIdentifier, getReturnType, getReturnTypeAsString, makeProcessingError, returnsBag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_INTEGER_GREATER_THAN

public static final java.lang.String NAME_INTEGER_GREATER_THAN
Standard identifier for the integer-greater-than function.

See Also:
Constant Field Values

NAME_INTEGER_GREATER_THAN_OR_EQUAL

public static final java.lang.String NAME_INTEGER_GREATER_THAN_OR_EQUAL
Standard identifier for the integer-greater-than-or-equal function.

See Also:
Constant Field Values

NAME_INTEGER_LESS_THAN

public static final java.lang.String NAME_INTEGER_LESS_THAN
Standard identifier for the integer-less-than function.

See Also:
Constant Field Values

NAME_INTEGER_LESS_THAN_OR_EQUAL

public static final java.lang.String NAME_INTEGER_LESS_THAN_OR_EQUAL
Standard identifier for the integer-less-than-or-equal function.

See Also:
Constant Field Values

NAME_DOUBLE_GREATER_THAN

public static final java.lang.String NAME_DOUBLE_GREATER_THAN
Standard identifier for the double-greater-than function.

See Also:
Constant Field Values

NAME_DOUBLE_GREATER_THAN_OR_EQUAL

public static final java.lang.String NAME_DOUBLE_GREATER_THAN_OR_EQUAL
Standard identifier for the double-greater-than-or-equal function.

See Also:
Constant Field Values

NAME_DOUBLE_LESS_THAN

public static final java.lang.String NAME_DOUBLE_LESS_THAN
Standard identifier for the double-less-than function.

See Also:
Constant Field Values

NAME_DOUBLE_LESS_THAN_OR_EQUAL

public static final java.lang.String NAME_DOUBLE_LESS_THAN_OR_EQUAL
Standard identifier for the double-less-than-or-equal function.

See Also:
Constant Field Values

NAME_STRING_GREATER_THAN

public static final java.lang.String NAME_STRING_GREATER_THAN
Standard identifier for the string-greater-than function.

See Also:
Constant Field Values

NAME_STRING_GREATER_THAN_OR_EQUAL

public static final java.lang.String NAME_STRING_GREATER_THAN_OR_EQUAL
Standard identifier for the string-greater-than-or-equal function.

See Also:
Constant Field Values

NAME_STRING_LESS_THAN

public static final java.lang.String NAME_STRING_LESS_THAN
Standard identifier for the string-less-than function.

See Also:
Constant Field Values

NAME_STRING_LESS_THAN_OR_EQUAL

public static final java.lang.String NAME_STRING_LESS_THAN_OR_EQUAL
Standard identifier for the string-less-than-or-equal function.

See Also:
Constant Field Values

NAME_TIME_GREATER_THAN

public static final java.lang.String NAME_TIME_GREATER_THAN
Standard identifier for the time-greater-than function.

See Also:
Constant Field Values

NAME_TIME_GREATER_THAN_OR_EQUAL

public static final java.lang.String NAME_TIME_GREATER_THAN_OR_EQUAL
Standard identifier for the time-greater-than-or-equal function.

See Also:
Constant Field Values

NAME_TIME_LESS_THAN

public static final java.lang.String NAME_TIME_LESS_THAN
Standard identifier for the time-less-than function.

See Also:
Constant Field Values

NAME_TIME_LESS_THAN_OR_EQUAL

public static final java.lang.String NAME_TIME_LESS_THAN_OR_EQUAL
Standard identifier for the time-less-than-or-equal function.

See Also:
Constant Field Values

NAME_DATETIME_GREATER_THAN

public static final java.lang.String NAME_DATETIME_GREATER_THAN
Standard identifier for the dateTime-greater-than function.

See Also:
Constant Field Values

NAME_DATETIME_GREATER_THAN_OR_EQUAL

public static final java.lang.String NAME_DATETIME_GREATER_THAN_OR_EQUAL
Standard identifier for the dateTime-greater-than-or-equal function.

See Also:
Constant Field Values

NAME_DATETIME_LESS_THAN

public static final java.lang.String NAME_DATETIME_LESS_THAN
Standard identifier for the dateTime-less-than function.

See Also:
Constant Field Values

NAME_DATETIME_LESS_THAN_OR_EQUAL

public static final java.lang.String NAME_DATETIME_LESS_THAN_OR_EQUAL
Standard identifier for the dateTime-less-than-or-equal function.

See Also:
Constant Field Values

NAME_DATE_GREATER_THAN

public static final java.lang.String NAME_DATE_GREATER_THAN
Standard identifier for the date-greater-than function.

See Also:
Constant Field Values

NAME_DATE_GREATER_THAN_OR_EQUAL

public static final java.lang.String NAME_DATE_GREATER_THAN_OR_EQUAL
Standard identifier for the date-greater-than-or-equal function.

See Also:
Constant Field Values

NAME_DATE_LESS_THAN

public static final java.lang.String NAME_DATE_LESS_THAN
Standard identifier for the date-less-than function.

See Also:
Constant Field Values

NAME_DATE_LESS_THAN_OR_EQUAL

public static final java.lang.String NAME_DATE_LESS_THAN_OR_EQUAL
Standard identifier for the date-less-than-or-equal function.

See Also:
Constant Field Values

ID_INTEGER_GREATER_THAN

private static final int ID_INTEGER_GREATER_THAN
See Also:
Constant Field Values

ID_INTEGER_GREATER_THAN_OR_EQUAL

private static final int ID_INTEGER_GREATER_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_INTEGER_LESS_THAN

private static final int ID_INTEGER_LESS_THAN
See Also:
Constant Field Values

ID_INTEGER_LESS_THAN_OR_EQUAL

private static final int ID_INTEGER_LESS_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_DOUBLE_GREATER_THAN

private static final int ID_DOUBLE_GREATER_THAN
See Also:
Constant Field Values

ID_DOUBLE_GREATER_THAN_OR_EQUAL

private static final int ID_DOUBLE_GREATER_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_DOUBLE_LESS_THAN

private static final int ID_DOUBLE_LESS_THAN
See Also:
Constant Field Values

ID_DOUBLE_LESS_THAN_OR_EQUAL

private static final int ID_DOUBLE_LESS_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_STRING_GREATER_THAN

private static final int ID_STRING_GREATER_THAN
See Also:
Constant Field Values

ID_STRING_GREATER_THAN_OR_EQUAL

private static final int ID_STRING_GREATER_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_STRING_LESS_THAN

private static final int ID_STRING_LESS_THAN
See Also:
Constant Field Values

ID_STRING_LESS_THAN_OR_EQUAL

private static final int ID_STRING_LESS_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_TIME_GREATER_THAN

private static final int ID_TIME_GREATER_THAN
See Also:
Constant Field Values

ID_TIME_GREATER_THAN_OR_EQUAL

private static final int ID_TIME_GREATER_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_TIME_LESS_THAN

private static final int ID_TIME_LESS_THAN
See Also:
Constant Field Values

ID_TIME_LESS_THAN_OR_EQUAL

private static final int ID_TIME_LESS_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_DATE_GREATER_THAN

private static final int ID_DATE_GREATER_THAN
See Also:
Constant Field Values

ID_DATE_GREATER_THAN_OR_EQUAL

private static final int ID_DATE_GREATER_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_DATE_LESS_THAN

private static final int ID_DATE_LESS_THAN
See Also:
Constant Field Values

ID_DATE_LESS_THAN_OR_EQUAL

private static final int ID_DATE_LESS_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_DATETIME_GREATER_THAN

private static final int ID_DATETIME_GREATER_THAN
See Also:
Constant Field Values

ID_DATETIME_GREATER_THAN_OR_EQUAL

private static final int ID_DATETIME_GREATER_THAN_OR_EQUAL
See Also:
Constant Field Values

ID_DATETIME_LESS_THAN

private static final int ID_DATETIME_LESS_THAN
See Also:
Constant Field Values

ID_DATETIME_LESS_THAN_OR_EQUAL

private static final int ID_DATETIME_LESS_THAN_OR_EQUAL
See Also:
Constant Field Values

idMap

private static java.util.HashMap idMap

typeMap

private static java.util.HashMap typeMap
Constructor Detail

ComparisonFunction

public ComparisonFunction(java.lang.String functionName)
Creates a new ComparisonFunction object.

Method Detail

getId

private static int getId(java.lang.String functionName)
Private helper that returns the internal identifier used for the given standard function.


getArgumentType

private static java.lang.String getArgumentType(java.lang.String functionName)
Private helper that returns the type used for the given standard function. Note that this doesn't check on the return value since the method always is called after getId, so we assume that the function is present.


getSupportedIdentifiers

public static java.util.Set getSupportedIdentifiers()
Returns a Set containing all the function identifiers supported by this class.


evaluate

public EvaluationResult evaluate(java.util.List inputs,
                                 com.sun.xacml.EvaluationCtx context)
Evaluate the function, using the specified parameters.


doubleCompare

private int doubleCompare(double d1,
                          double d2)
Helper function that does a comparison of the two doubles using the rules of XMLSchema. Like all compare methods, this returns 0 if they're equal, a positive value if d1 > d2, and a negative value if d1 < d2.


dateCompare

private int dateCompare(java.util.Date d1,
                        int n1,
                        java.util.Date d2,
                        int n2)
Helper function to compare two Date objects and their associated nanosecond values. Like all compare methods, this returns 0 if they're equal, a positive value if d1 > d2, and a negative value if d1 < d2.