Package com.solacesystems.common.util.expression

A Generic Postfix Expression Stack Implementation.

See: Description

Package com.solacesystems.common.util.expression Description

A Generic Postfix Expression Stack Implementation.

This package represents a generic postfix (also known as reverse polish) expression stack. What postfix allows you to do is represent arbitrary mathematical or logical expressions without the need for parentheses. Currently this expression stack only represents logical and not mathematical expressions. In the "classical" stack everytime you evaluate the stack it evaluates to the same output value. This stack is a little different from the "classical" stack in that the operands in the stack take input from outside the stack. So, depending upon the input, the result may be different.

Everything that is added to the stack must implement ExpressionArgument. This includes all the operands and operators. The logical operators "and", "or" and "not" are provided in this package. The operands for the logical operators must evaluate to BooleanExpressionArguments. When an expression stack is evaluated, usually an operator will be popped off the stack with 1 or 2 operands depending on whether it is a unary or binary operator. The result of the operation is then pushed back on the stack to be possibly used as an argument to another operation. When the evaluation is done there should be one value still on the stack.

A good example of using this stack is for passwords. You may have a password requirements like:

You can write an expression stack that ANDs these requirements to validate whether the input password passes.

Copyright 2004-2017 Solace Corporation. All rights reserved.