/** * Compute the cardinality of the sequence returned by evaluating this instruction * @return the static cardinality */ public int computeCardinality() { int card = 0; boolean includesTrue = false; for (int i=0; i<actions.length; i++) { card = Cardinality.union(card, actions[i].getCardinality()); if (Literal.isConstantBoolean(conditions[i], true)) { includesTrue = true; } } if (!includesTrue) { // we may drop off the end and return an empty sequence (typical for xsl:if) card = Cardinality.union(card, StaticProperty.ALLOWS_ZERO); } return card; }
/** * Compute the cardinality of the sequence returned by evaluating this instruction * @return the static cardinality */ public int computeCardinality() { int card = 0; boolean includesTrue = false; for (int i=0; i<actions.length; i++) { card = Cardinality.union(card, actions[i].getCardinality()); if (Literal.isConstantBoolean(conditions[i], true)) { includesTrue = true; } } if (!includesTrue) { // we may drop off the end and return an empty sequence (typical for xsl:if) card = Cardinality.union(card, StaticProperty.ALLOWS_ZERO); } return card; }
if (Literal.isConstantBoolean(conditions[i], false)) { if (conditions.length == 1) { return new Literal(EmptySequence.getInstance()); if (Literal.isConstantBoolean(conditions[i], true)) { if (i == 0) { return actions[0]; if (conditions.length == 1 && Literal.isConstantBoolean(conditions[0], true)) { return actions[0]; if (Literal.isConstantBoolean(conditions[conditions.length-1], true) && actions[actions.length-1] instanceof Choose) { Choose choose2 = (Choose)actions[actions.length-1]; Literal.isConstantBoolean(actions[0], true) && Literal.isConstantBoolean(actions[1], false) && Literal.isConstantBoolean(conditions[1], true)) { TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (th.isSubType(conditions[0].getItemType(th), BuiltInAtomicType.BOOLEAN) &&
if (Literal.isConstantBoolean(conditions[i], false)) { if (conditions.length == 1) { return new Literal(EmptySequence.getInstance()); if (Literal.isConstantBoolean(conditions[i], true)) { if (i == 0) { return actions[0]; if (conditions.length == 1 && Literal.isConstantBoolean(conditions[0], true)) { return actions[0]; if (Literal.isConstantBoolean(conditions[conditions.length-1], true) && actions[actions.length-1] instanceof Choose) { Choose choose2 = (Choose)actions[actions.length-1]; Literal.isConstantBoolean(actions[0], true) && Literal.isConstantBoolean(actions[1], false) && Literal.isConstantBoolean(conditions[1], true)) { TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (th.isSubType(conditions[0].getItemType(th), BuiltInAtomicType.BOOLEAN) &&
Literal.isConstantBoolean(operand0, false) || Literal.isConstantBoolean(operand1, false))) { return new Literal(BooleanValue.FALSE); Literal.isConstantBoolean(operand0, true) || Literal.isConstantBoolean(operand1, true))) { return new Literal(BooleanValue.TRUE);
Literal.isConstantBoolean(operand0, false) || Literal.isConstantBoolean(operand1, false))) { return new Literal(BooleanValue.FALSE); Literal.isConstantBoolean(operand0, true) || Literal.isConstantBoolean(operand1, true))) { return new Literal(BooleanValue.TRUE);
@Override protected Expression preEvaluate() { // If the value can be determined from knowledge of one operand, precompute the result if (Literal.isConstantBoolean(getLhsExpression(), false) || Literal.isConstantBoolean(getRhsExpression(), false)) { // A and false() => false() // false() and B => false() return Literal.makeLiteral(BooleanValue.FALSE, this); } else if (Literal.hasEffectiveBooleanValue(getLhsExpression(), true)) { // true() and B => B return forceToBoolean(getRhsExpression()); } else if (Literal.hasEffectiveBooleanValue(getRhsExpression(), true)) { // A and true() => A return forceToBoolean(getLhsExpression()); } else { return this; } }
@Override protected Expression preEvaluate() { // If the value can be determined from knowledge of one operand, precompute the result if (Literal.isConstantBoolean(getLhsExpression(), false) || Literal.isConstantBoolean(getRhsExpression(), false)) { // A and false() => false() // false() and B => false() return Literal.makeLiteral(BooleanValue.FALSE, this); } else if (Literal.hasEffectiveBooleanValue(getLhsExpression(), true)) { // true() and B => B return forceToBoolean(getRhsExpression()); } else if (Literal.hasEffectiveBooleanValue(getRhsExpression(), true)) { // A and true() => A return forceToBoolean(getLhsExpression()); } else { return this; } }
Literal.isConstantBoolean(operand0, false) || Literal.isConstantBoolean(operand1, false))) { return new Literal(BooleanValue.FALSE); Literal.isConstantBoolean(operand0, true) || Literal.isConstantBoolean(operand1, true))) { return new Literal(BooleanValue.TRUE);
if (!Literal.isConstantBoolean(conditions[conditions.length-1], true) && !Cardinality.allowsZero(req.getCardinality())) { String cond = (conditions.length == 1 ? "the condition is not" : "none of the conditions is");
if (!Literal.isConstantBoolean(conditions[conditions.length-1], true) && !Cardinality.allowsZero(req.getCardinality())) { String cond = (conditions.length == 1 ? "the condition is not" : "none of the conditions is");
positionExpr = positionExpr.optimize(visitor, cit); if (Literal.isConstantBoolean(positionExpr, true)) { return new NodeTestPattern(nodeTest); } else if (Literal.isConstantBoolean(positionExpr, false)) {
Literal.isConstantBoolean(getAction(0), true) && Literal.isConstantBoolean(getAction(1), false) && Literal.hasEffectiveBooleanValue(getCondition(1), true)) { TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy();
positionExpr = positionExpr.optimize(visitor, cit); if (Literal.isConstantBoolean(positionExpr, true)) { return new NodeTestPattern(nodeTest); } else if (Literal.isConstantBoolean(positionExpr, false)) {
Literal.isConstantBoolean(getAction(0), true) && Literal.isConstantBoolean(getAction(1), false) && Literal.hasEffectiveBooleanValue(getCondition(1), true)) { TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy();
if (Literal.isConstantBoolean(filter, true)) { } else if (Literal.isConstantBoolean(filter, false)) {
if (Literal.isConstantBoolean(filter, true)) { } else if (Literal.isConstantBoolean(filter, false)) {
!Literal.isConstantBoolean(getCondition(i), false) && !Literal.isConstantBoolean(getCondition(i), true)) {
!Literal.isConstantBoolean(getCondition(i), false) && !Literal.isConstantBoolean(getCondition(i), true)) {