|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.rave.web.ui.util.PermissionChecker
public class PermissionChecker
This class takes a "Permission String" and is cabable of determining if a user passes the permission check. Supported "checks" are:
VariableResolver
). (null is
interpretted as false, non boolean values (besides the string
"false") are interpretted to mean true)
VariableResolver
Nested Class Summary | |
---|---|
protected static class |
PermissionChecker.BooleanFunction
BooleanFunction is either true or false. |
static interface |
PermissionChecker.Function
This class must be implemented by all user defined Functions. |
protected class |
PermissionChecker.StringFunction
StringFunction implements Function and serves as the default function. |
Field Summary | |
---|---|
static char |
AND_OPERATOR
|
static char |
ARGUMENT_SEPARATOR
|
static char |
EQUALS_OPERATOR
|
static java.lang.String |
FALSE
|
static PermissionChecker.BooleanFunction |
FALSE_BOOLEAN_FUNCTION
This variable represents a "false" BooleanFunction. |
static char |
FUNCTION_MARKER
|
static char |
LEFT_PAREN
|
static char |
LESS_THAN_OPERATOR
|
static char |
MODULUS_OPERATOR
|
static char |
MORE_THAN_OPERATOR
|
static char |
NOT_OPERATOR
|
static char |
OR_OPERATOR
|
protected static char |
POST_FALSE
|
protected static char |
POST_FALSE_CAP
|
protected static char |
POST_TRUE
|
protected static char |
POST_TRUE_CAP
|
static char |
RIGHT_PAREN
|
static java.lang.String |
TRUE
|
static PermissionChecker.BooleanFunction |
TRUE_BOOLEAN_FUNCTION
This variable represents a "true" BooleanFunction. |
Constructor Summary | |
---|---|
PermissionChecker(LayoutElement desc,
javax.faces.component.UIComponent component,
java.lang.String infixStr)
This is the constructor method that is required to create this object. |
Method Summary | |
---|---|
protected char[] |
generatePostfix(java.lang.String infixStr)
This method calculates the postfix representation of the infix equation passed in. |
protected static PermissionChecker.Function |
getFunction(java.lang.String functionName)
This method is a factory method for constructing a new function based on the function name passed in. |
java.lang.String |
getInfix()
This method returns the infix representation of the equation, in other words: the original String passed in. |
LayoutElement |
getLayoutElement()
Retreives the LayoutElement associated with this PermissionChecker (only needed in cases where a expression requires a LayoutElement for evaluation). |
java.lang.String |
getPostfix()
|
protected char[] |
getPostfixArr()
|
javax.faces.component.UIComponent |
getUIComponent()
Retreives the LayoutElement associated with this PermissionChecker (only needed in cases where a expression requires a LayoutElement for evaluation). |
boolean |
hasPermission()
This method is invoked to determine if the equation evaluates to true or false. |
static boolean |
isOperator(char ch)
This method returns true if the given character is a valid operator. |
static void |
main(java.lang.String[] args)
This is here to provide some test cases. |
protected char[] |
preProcessString(java.lang.String source)
This method replaces all "true" / "false" strings w/ 't'/'f'. |
static void |
registerFunction(java.lang.String functionName,
java.lang.Class function)
This method allows arbitrary functions to be registered. |
void |
setInfix(java.lang.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(javax.faces.component.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. |
static java.lang.String |
stripWhiteSpace(java.lang.String input)
This method removes all whitespace from the given String |
java.lang.String |
toString()
Displays the infix and postfix version of the equation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final PermissionChecker.BooleanFunction FALSE_BOOLEAN_FUNCTION
public static final PermissionChecker.BooleanFunction TRUE_BOOLEAN_FUNCTION
protected static final char POST_TRUE
protected static final char POST_FALSE
protected static final char POST_TRUE_CAP
protected static final char POST_FALSE_CAP
public static final java.lang.String TRUE
public static final java.lang.String FALSE
public static final char FUNCTION_MARKER
public static final char LEFT_PAREN
public static final char RIGHT_PAREN
public static final char EQUALS_OPERATOR
public static final char OR_OPERATOR
public static final char AND_OPERATOR
public static final char NOT_OPERATOR
public static final char LESS_THAN_OPERATOR
public static final char MORE_THAN_OPERATOR
public static final char MODULUS_OPERATOR
public static final char ARGUMENT_SEPARATOR
Constructor Detail |
---|
public PermissionChecker(LayoutElement desc, javax.faces.component.UIComponent component, java.lang.String infixStr)
Method Detail |
---|
protected void setUIComponent(javax.faces.component.UIComponent component)
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.
public javax.faces.component.UIComponent getUIComponent()
Retreives the LayoutElement associated with this PermissionChecker (only needed in cases where a expression requires a LayoutElement for evaluation).
protected void setLayoutElement(LayoutElement desc)
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.
public LayoutElement getLayoutElement()
Retreives the LayoutElement associated with this PermissionChecker (only needed in cases where a expression requires a LayoutElement for evaluation).
protected char[] preProcessString(java.lang.String source)
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. 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).
protected static PermissionChecker.Function getFunction(java.lang.String functionName)
public static void registerFunction(java.lang.String functionName, java.lang.Class function)
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 parameters also should only contain alpha-numeric characters.
Functions must implement PermissionChecker.Function interface
public static boolean isOperator(char ch)
protected char[] generatePostfix(java.lang.String infixStr)
infixStr
- The infix representation of the equation.
public boolean hasPermission()
public java.lang.String getInfix()
public void setInfix(java.lang.String equation)
equation
- The infix equation to useprotected char[] getPostfixArr()
protected void setPostfixArr(char[] postfix)
public java.lang.String getPostfix()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String stripWhiteSpace(java.lang.String input)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |