| |
|
| java.lang.Object com.sun.rave.web.ui.util.PermissionChecker
PermissionChecker | public class PermissionChecker (Code) | | This class takes a "Permission String" and is cabable of determining if
a user passes the permission check. Supported "checks" are:
- Boolean -- "true" or "false"
The format of the "Permission String" must be an equation that results in a
boolean answer. The supported functions/operators are:
--
- $<type>{<key>} -- To read a value according to
<type> using <key> (See:
com.sun.rave.web.ui.util.VariableResolver ). (null is
interpretted as false, non boolean values (besides the string
"false") are interpretted to mean true)
- '(' and ')' can be used to define order of operation
- '!' may be used to negate a value
- '|' may be used as a logical OR
- '&' may be used as a logical AND
- '=' may be used as a String equals
Operator Precedence (for infix notation) is:
See Also: VariableResolver author: Ken Paulsen (ken.paulsen@sun.com) |
Inner Class :public static interface Function | |
Method Summary | |
protected char[] | generatePostfix(String infixStr) This method calculates the postfix representation of the infix equation
passed in. | protected static Function | getFunction(String functionName) This method is a factory method for constructing a new function based
on the function name passed in. | public String | getInfix() This method returns the infix representation of the equation, in other
words: the original String passed in. | public LayoutElement | getLayoutElement() | public String | getPostfix() | protected char[] | getPostfixArr() | public UIComponent | getUIComponent() | public boolean | hasPermission() This method is invoked to determine if the equation evaluates to true
or false. | public static boolean | isOperator(char ch) This method returns true if the given character is a valid operator. | public static void | main(String args) This is here to provide some test cases. | protected char[] | preProcessString(String source) This method replaces all "true" / "false" strings w/ 't'/'f'. | public static void | registerFunction(String functionName, Class function) This method allows arbitrary functions to be registered. | public void | setInfix(String equation) This method sets the equation and forces a re-evaluation of the
equation. | protected void | setLayoutElement(LayoutElement desc) This method sets the LayoutElement that is associated with the 'if'
check being evaluated. | protected void | setPostfixArr(char postfix) | protected void | setUIComponent(UIComponent component) This method sets the LayoutElement that is associated with the 'if'
check being evaluated. | protected int | storeFunction(char arr, int idx) This method looks at the given char array starting at index and
continues until an operator (or end of String) is encountered. | public static String | stripWhiteSpace(String input) | public String | toString() Displays the infix and postfix version of the equation. |
AND_OPERATOR | final public static char AND_OPERATOR(Code) | | |
ARGUMENT_SEPARATOR | final public static char ARGUMENT_SEPARATOR(Code) | | |
EQUALS_OPERATOR | final public static char EQUALS_OPERATOR(Code) | | |
FALSE_BOOLEAN_FUNCTION | final public static BooleanFunction FALSE_BOOLEAN_FUNCTION(Code) | | This variable represents a "false" BooleanFunction.
|
FUNCTION_MARKER | final public static char FUNCTION_MARKER(Code) | | |
LEFT_PAREN | final public static char LEFT_PAREN(Code) | | |
LESS_THAN_OPERATOR | final public static char LESS_THAN_OPERATOR(Code) | | |
MODULUS_OPERATOR | final public static char MODULUS_OPERATOR(Code) | | |
MORE_THAN_OPERATOR | final public static char MORE_THAN_OPERATOR(Code) | | |
NOT_OPERATOR | final public static char NOT_OPERATOR(Code) | | |
OR_OPERATOR | final public static char OR_OPERATOR(Code) | | |
POST_FALSE | final protected static char POST_FALSE(Code) | | |
POST_FALSE_CAP | final protected static char POST_FALSE_CAP(Code) | | |
POST_TRUE | final protected static char POST_TRUE(Code) | | |
POST_TRUE_CAP | final protected static char POST_TRUE_CAP(Code) | | |
RIGHT_PAREN | final public static char RIGHT_PAREN(Code) | | |
TRUE_BOOLEAN_FUNCTION | final public static BooleanFunction TRUE_BOOLEAN_FUNCTION(Code) | | This variable represents a "true" BooleanFunction.
|
PermissionChecker | public PermissionChecker(LayoutElement desc, UIComponent component, String infixStr)(Code) | | This is the constructor method that is required to create this object.
|
generatePostfix | protected char[] generatePostfix(String infixStr)(Code) | | This method calculates the postfix representation of the infix equation
passed in. It returns the postfix equation as a char[].
Parameters: infixStr - The infix representation of the equation. postfix representation of the equation as a char[] (the f()'sare removed and stored in _functionList). |
getFunction | protected static Function getFunction(String functionName)(Code) | | This method is a factory method for constructing a new function based
on the function name passed in. The function must be registered prior
to invoking this method.
|
getInfix | public String getInfix()(Code) | | This method returns the infix representation of the equation, in other
words: the original String passed in.
|
getLayoutElement | public LayoutElement getLayoutElement()(Code) | | Retreives the LayoutElement associated with this PermissionChecker
(only needed in cases where a expression requires a LayoutElement for
evaluation).
|
getPostfixArr | protected char[] getPostfixArr()(Code) | | |
getUIComponent | public UIComponent getUIComponent()(Code) | | Retreives the LayoutElement associated with this PermissionChecker
(only needed in cases where a expression requires a LayoutElement for
evaluation).
|
hasPermission | public boolean hasPermission()(Code) | | This method is invoked to determine if the equation evaluates to true
or false.
|
isOperator | public static boolean isOperator(char ch)(Code) | | This method returns true if the given character is a valid operator.
|
main | public static void main(String args)(Code) | | This is here to provide some test cases. It only tests the conversion
to postfix notation.
|
preProcessString | protected char[] preProcessString(String source)(Code) | | This method replaces all "true" / "false" strings w/ 't'/'f'. It
converts the String into a char[]. It replaces all user defined
functions w/ 'F' and places a Function in a list per the registered
user-defined function. All other strings are converted to an 'F' and
a StringFunction is added to the function list.
|
registerFunction | public static void registerFunction(String functionName, Class function)(Code) | | This method allows arbitrary functions to be registered. Function
names should only contain letters or numbers, other characters or
whitespace may cause problems. No checking is done to ensure this,
however.
Functions will be expressed in an equation as follows:
- function_name(param1,param2)
Function parameters also should only contain alpha-numeric
characters.
Functions must implement PermissionChecker.Function interface
|
setInfix | public void setInfix(String equation)(Code) | | This method sets the equation and forces a re-evaluation of the
equation. It returns the postfix representation of the equation.
Parameters: equation - The infix equation to use |
setLayoutElement | protected void setLayoutElement(LayoutElement desc)(Code) | | This method sets the LayoutElement that is associated with the 'if'
check being evaluated. This is not normally needed, it is only needed
if the 'if' check contains an expression which requires a
LayoutElement to be properly evaluated.
|
setPostfixArr | protected void setPostfixArr(char postfix)(Code) | | |
setUIComponent | protected void setUIComponent(UIComponent component)(Code) | | This method sets the LayoutElement that is associated with the 'if'
check being evaluated. This is not normally needed, it is only needed
if the 'if' check contains an expression which requires a
LayoutElement to be properly evaluated.
|
storeFunction | protected int storeFunction(char arr, int idx)(Code) | | This method looks at the given char array starting at index and
continues until an operator (or end of String) is encountered. It then
uses this string to lookup a registered function (if any), it stores
that function (with parameters)... or if the function is not found, it
registers a "String function" (which always returns true).
|
stripWhiteSpace | public static String stripWhiteSpace(String input)(Code) | | This method removes all whitespace from the given String
|
toString | public String toString()(Code) | | Displays the infix and postfix version of the equation.
|
|
|
|