static Operator operatorFromSymbol( String jcrConstantValue ) { Operator op = OPERATORS_BY_JCR_NAME.get(jcrConstantValue); if (op == null) op = Operator.forSymbol(jcrConstantValue); assert op != null; return op; }
@Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof Comparison) { Comparison that = (Comparison)obj; if (this.hc != that.hc) return false; if (!this.operator.equals(that.operator)) return false; if (!this.operand1.equals(that.operand1)) return false; if (!this.operand2.equals(that.operand2)) return false; return true; } return false; }
@Override protected OperationBuilder<T> apply( Between between, boolean negated ) { T lower = converter.toLowerValue(between.getLowerBound(), variables); T upper = converter.toUpperValue(between.getUpperBound(), variables); boolean isLowerIncluded = between.isLowerBoundIncluded(); boolean isUpperIncluded = between.isUpperBoundIncluded(); if (negated) { OperationBuilder<T> lowerOp = create(keysByValue.headMap(lower, !isLowerIncluded)); OperationBuilder<T> upperOp = create(keysByValue.tailMap(upper, !isUpperIncluded)); return new DualOperationBuilder<>(lowerOp, upperOp); } return create(keysByValue.subMap(lower, isLowerIncluded, upper, isUpperIncluded)); }
/** * Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of * nodes returned. * * @param sequence the original sequence that is to be limited; may be null * @param limitAndOffset the specification of the offset and limit; if null this method simply returns <code>sequence</code> * @return the limitd sequence of nodes; never null */ public static NodeSequence limit( NodeSequence sequence, Limit limitAndOffset ) { if (sequence == null) return emptySequence(0); if (limitAndOffset != null && !limitAndOffset.isUnlimited()) { final int limit = limitAndOffset.getRowLimit(); // Perform the skip first ... if (limitAndOffset.isOffset()) { sequence = skip(sequence, limitAndOffset.getOffset()); } // And then the offset ... if (limit != Integer.MAX_VALUE) { sequence = limit(sequence, limit); } } return sequence; }
protected boolean applies( ReferenceValue operand ) { if (matchesSelectorName(operand.getSelectorName())) { // The selected node type matches or is a subtype of the indexed node type ... String refPropName = operand.getPropertyName(); if (refPropName != null) { // The constraint applies to a specific reference property ... return isReferenceIndex(refPropName); } // Otherwise, the constraint applies to any reference property ... return isReferenceIndex(); } return false; }
protected boolean indexAppliesTo( SetCriteria constraint ) { return applies(constraint.getOperand()); }
protected boolean indexAppliesTo( Between constraint ) { return applies(constraint.getOperand()); }
@Override public void visit( Comparison comparison ) { comparison.getOperand1().accept(this); append(' ').append(comparison.operator().symbol()).append(' '); comparison.getOperand2().accept(this); }
protected boolean indexAppliesTo( Relike constraint ) { // Relike can only work if the column types are all strings ... for (IndexColumnDefinition columnDefn : defn) { if (columnDefn.getColumnType() != PropertyType.STRING) return false; } return applies(constraint.getOperand2()); }
@Override protected OperationBuilder<T> apply( Between between, boolean negated ) { T lower = converter.toLowerValue(between.getLowerBound(), variables); T upper = converter.toUpperValue(between.getUpperBound(), variables); boolean isLowerIncluded = between.isLowerBoundIncluded(); boolean isUpperIncluded = between.isUpperBoundIncluded(); if (negated) { OperationBuilder<T> lowerOp = create(keysByValue.headMap(lower, !isLowerIncluded)); OperationBuilder<T> upperOp = create(keysByValue.tailMap(upper, !isUpperIncluded)); return new DualOperationBuilder<>(lowerOp, upperOp); } return create(keysByValue.subMap(lower, isLowerIncluded, upper, isUpperIncluded)); }
/** * Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of * nodes returned. * * @param sequence the original sequence that is to be limited; may be null * @param limitAndOffset the specification of the offset and limit; if null this method simply returns <code>sequence</code> * @return the limitd sequence of nodes; never null */ public static NodeSequence limit( NodeSequence sequence, Limit limitAndOffset ) { if (sequence == null) return emptySequence(0); if (limitAndOffset != null && !limitAndOffset.isUnlimited()) { final int limit = limitAndOffset.getRowLimit(); // Perform the skip first ... if (limitAndOffset.isOffset()) { sequence = skip(sequence, limitAndOffset.getOffset()); } // And then the offset ... if (limit != Integer.MAX_VALUE) { sequence = limit(sequence, limit); } } return sequence; }
protected boolean applies( ReferenceValue operand ) { if (matchesSelectorName(operand.getSelectorName())) { // The selected node type matches or is a subtype of the indexed node type ... String refPropName = operand.getPropertyName(); if (refPropName != null) { // The constraint applies to a specific reference property ... return isReferenceIndex(refPropName); } // Otherwise, the constraint applies to any reference property ... return isReferenceIndex(); } return false; }
protected boolean indexAppliesTo( SetCriteria constraint ) { return applies(constraint.getOperand()); }
protected boolean indexAppliesTo( Between constraint ) { return applies(constraint.getOperand()); }
@Override public void visit( Comparison comparison ) { comparison.getOperand1().accept(this); append(' ').append(comparison.operator().symbol()).append(' '); comparison.getOperand2().accept(this); }
static Operator operatorFromSymbol( String jcrConstantValue ) { Operator op = OPERATORS_BY_JCR_NAME.get(jcrConstantValue); if (op == null) op = Operator.forSymbol(jcrConstantValue); assert op != null; return op; }
@Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof Comparison) { Comparison that = (Comparison)obj; if (this.hc != that.hc) return false; if (!this.operator.equals(that.operator)) return false; if (!this.operand1.equals(that.operand1)) return false; if (!this.operand2.equals(that.operand2)) return false; return true; } return false; }
protected boolean indexAppliesTo( Relike constraint ) { // Relike can only work if the column types are all strings ... for (IndexColumnDefinition columnDefn : defn) { if (columnDefn.getColumnType() != PropertyType.STRING) return false; } return applies(constraint.getOperand2()); }