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;
}
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;
}
Aggregations