if (field.matches(pattern)) { return inclusion; } else {
if (field.matches(pattern)) { return inclusion; } else {
/** * Check if this path is a matching descendant of the pattern, that is: - * path matches pattern, or - a prefix of the path matches the pattern */ public boolean matchingDescendant(Path pattern) { int n = pattern.numSegments(); if (n < numSegments()) { return prefix(n).matches(pattern); } else if (n == numSegments()) { return matches(pattern); } return false; }
/** * Check if this path is a matching descendant of the pattern, that is: - * path matches pattern, or - a prefix of the path matches the pattern */ public boolean matchingDescendant(Path pattern) { int n = pattern.numSegments(); if (n < numSegments()) { return prefix(n).matches(pattern); } else if (n == numSegments()) { return matches(pattern); } return false; }
/** * Check if this path is a matching descendant of the pattern, that is: - * path matches pattern, or - a prefix of the path matches the pattern */ public boolean matchingDescendant(Path pattern) { int n = pattern.numSegments(); if (n < numSegments()) { return prefix(n).matches(pattern); } else if (n == numSegments()) { return matches(pattern); } return false; }
/** * Check if this path is a matching prefix of the pattern, that is: - path * matches pattern, or - path matches a prefix of the pattern */ public boolean matchingPrefix(Path pattern) { int n = pattern.numSegments(); if (n > numSegments()) { return matches(pattern.prefix(numSegments())); } else if (n == numSegments()) { return matches(pattern); } return false; }
/** * Check if this path is a matching prefix of the pattern, that is: - path * matches pattern, or - path matches a prefix of the pattern */ public boolean matchingPrefix(Path pattern) { int n = pattern.numSegments(); if (n > numSegments()) { return matches(pattern.prefix(numSegments())); } else if (n == numSegments()) { return matches(pattern); } return false; }
/** * Check if this path is a matching prefix of the pattern, that is: - path * matches pattern, or - path matches a prefix of the pattern */ public boolean matchingPrefix(Path pattern) { int n = pattern.numSegments(); if (n > numSegments()) { return matches(pattern.prefix(numSegments())); } else if (n == numSegments()) { return matches(pattern); } return false; }
private static ArrayProjector findArrayProjectorForField(Projector p, Path field) { if (p instanceof ListProjector) { List<Projector> items = ((ListProjector) p).getItems(); ListIterator<Projector> itemsItr = items.listIterator(items.size()); while (itemsItr.hasPrevious()) { Projector projector = itemsItr.previous(); ArrayProjector x = findArrayProjectorForField(projector, field); if (x != null) { return x; } } } else if (p instanceof ArrayProjector) { if (field.matches(((ArrayProjector) p).getArrayFieldPattern())) { return (ArrayProjector) p; } return findArrayProjectorForField(p.getNestedProjector(), field); } return null; } }
private static ArrayProjector findArrayProjectorForField(Projector p, Path field) { if (p instanceof ListProjector) { List<Projector> items = ((ListProjector) p).getItems(); ListIterator<Projector> itemsItr = items.listIterator(items.size()); while (itemsItr.hasPrevious()) { Projector projector = itemsItr.previous(); ArrayProjector x = findArrayProjectorForField(projector, field); if (x != null) { return x; } } } else if (p instanceof ArrayProjector) { if (field.matches(((ArrayProjector) p).getArrayFieldPattern())) { return (ArrayProjector) p; } return findArrayProjectorForField(p.getNestedProjector(), field); } return null; } }
@Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { // If this is true, we're checking an ancestor of the // projection field, or the projection field itself, but // not a field that is a descendant of the projection // field if (include) { return Projection.Inclusion.explicit_inclusion; // Inclusion implies, because if we're going to // include a descendant of this field, this field // should also be included } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; // If this field is exclusively excluded, exclude it } // Otherwise, this projection does not tell anything about this particular field. } else if (recursive && // If this is a recursive projection p.numSegments() > field.numSegments() && // If we're checking a field deeper than our field p.prefix(field.numSegments()).matches(field) // And if we're checking a field under the subtree of our field ) { // This is an implied inclusion or exclusion, because the // projection is for an ancestor of this field. return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } }
@Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { // If this is true, we're checking an ancestor of the // projection field, or the projection field itself, but // not a field that is a descendant of the projection // field if (include) { return Projection.Inclusion.explicit_inclusion; // Inclusion implies, because if we're going to // include a descendant of this field, this field // should also be included } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; // If this field is exclusively excluded, exclude it } // Otherwise, this projection does not tell anything about this particular field. } else if (recursive && // If this is a recursive projection p.numSegments() > field.numSegments() && // If we're checking a field deeper than our field p.prefix(field.numSegments()).matches(field) // And if we're checking a field under the subtree of our field ) { // This is an implied inclusion or exclusion, because the // projection is for an ancestor of this field. return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } }
/** * Returns if the field should be included based on the recursive pattern. * * @param field The field name * @param pattern The projection pattern * @param inclusion flag to return if the field matches the given pattern * @return Boolean value of <code>inclusion</code> if field is in subtree of * <code>pattern</code> else null */ public static Boolean impliedInclusion(Path field, Path pattern, boolean inclusion) { if (field.numSegments() > pattern.numSegments() && // If we're checking a field deeper than the pattern // And if we're checking a field under the subtree of the pattern field.prefix(pattern.numSegments()).matches(pattern)) { return inclusion ? Boolean.TRUE : Boolean.FALSE; } else { return null; } }
/** * Returns if the field should be included based on the recursive pattern. * * @param field The field name * @param pattern The projection pattern * @param inclusion flag to return if the field matches the given pattern * @return Boolean value of <code>inclusion</code> if field is in subtree of * <code>pattern</code> else null */ public static Boolean impliedInclusion(Path field, Path pattern, boolean inclusion) { if (field.numSegments() > pattern.numSegments() && // If we're checking a field deeper than the pattern // And if we're checking a field under the subtree of the pattern field.prefix(pattern.numSegments()).matches(pattern)) { return inclusion ? Boolean.TRUE : Boolean.FALSE; } else { return null; } }