Search in sources :

Example 1 with Operator

use of org.apache.hadoop.hbase.security.visibility.expression.Operator in project hbase by apache.

the class ExpressionExpander method negate.

private ExpressionNode negate(NonLeafExpressionNode nlExp) {
    ExpressionNode notChild = nlExp.getChildExps().get(0);
    if (notChild instanceof LeafExpressionNode) {
        return nlExp;
    }
    NonLeafExpressionNode nlNotChild = (NonLeafExpressionNode) notChild;
    if (nlNotChild.getOperator() == Operator.NOT) {
        // negate the negate
        return nlNotChild.getChildExps().get(0);
    }
    Operator negateOp = nlNotChild.getOperator() == Operator.AND ? Operator.OR : Operator.AND;
    NonLeafExpressionNode newNode = new NonLeafExpressionNode(negateOp);
    for (ExpressionNode expNode : nlNotChild.getChildExps()) {
        NonLeafExpressionNode negateNode = new NonLeafExpressionNode(Operator.NOT);
        negateNode.addChildExp(expNode.deepClone());
        newNode.addChildExp(expand(negateNode));
    }
    return newNode;
}
Also used : Operator(org.apache.hadoop.hbase.security.visibility.expression.Operator) NonLeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode) ExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.ExpressionNode) LeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.LeafExpressionNode) NonLeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode) LeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.LeafExpressionNode) NonLeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode)

Example 2 with Operator

use of org.apache.hadoop.hbase.security.visibility.expression.Operator in project hbase by apache.

the class ExpressionExpander method expand.

public ExpressionNode expand(ExpressionNode src) {
    if (!src.isSingleNode()) {
        NonLeafExpressionNode nlExp = (NonLeafExpressionNode) src;
        List<ExpressionNode> childExps = nlExp.getChildExps();
        Operator outerOp = nlExp.getOperator();
        if (isToBeExpanded(childExps)) {
            // Any of the child exp is a non leaf exp with & or | operator
            NonLeafExpressionNode newNode = new NonLeafExpressionNode(nlExp.getOperator());
            for (ExpressionNode exp : childExps) {
                if (exp.isSingleNode()) {
                    newNode.addChildExp(exp);
                } else {
                    newNode.addChildExp(expand(exp));
                }
            }
            nlExp = expandNonLeaf(newNode, outerOp);
        }
        return nlExp;
    }
    if (src instanceof NonLeafExpressionNode && ((NonLeafExpressionNode) src).getOperator() == Operator.NOT) {
        // Negate the exp
        return negate((NonLeafExpressionNode) src);
    }
    return src;
}
Also used : Operator(org.apache.hadoop.hbase.security.visibility.expression.Operator) NonLeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode) ExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.ExpressionNode) LeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.LeafExpressionNode) NonLeafExpressionNode(org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode)

Aggregations

ExpressionNode (org.apache.hadoop.hbase.security.visibility.expression.ExpressionNode)2 LeafExpressionNode (org.apache.hadoop.hbase.security.visibility.expression.LeafExpressionNode)2 NonLeafExpressionNode (org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode)2 Operator (org.apache.hadoop.hbase.security.visibility.expression.Operator)2