| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this virtual attribute provider will generate |
| | | * any value for the provided entry that is greater than or equal to |
| | | * the given value. |
| | | * Indicates whether this virtual attribute provider will generate any value |
| | | * for the provided entry that is greater than or equal to the given value. |
| | | * |
| | | * @param entry The entry for which to make the determination. |
| | | * @param rule The virtual attribute rule which defines the |
| | | * constraints for the virtual attribute. |
| | | * @param value The value for which to make the determination. |
| | | * |
| | | * @return {@code UNDEFINED} if the associated attribute type does |
| | | * not have an ordering matching rule, {@code TRUE} if at |
| | | * least one of the generated values will be greater than |
| | | * or equal to the specified value, or {@code FALSE} if |
| | | * none of the generated values will be greater than or |
| | | * equal to the specified value. |
| | | * @param entry |
| | | * The entry for which to make the determination. |
| | | * @param rule |
| | | * The virtual attribute rule which defines the constraints for the |
| | | * virtual attribute. |
| | | * @param assertionValue |
| | | * The value for which to make the determination. |
| | | * @return {@code UNDEFINED} if the associated attribute type does not have an |
| | | * ordering matching rule, {@code TRUE} if at least one of the |
| | | * generated values will be greater than or equal to the specified |
| | | * value, or {@code FALSE} if none of the generated values will be |
| | | * greater than or equal to the specified value. |
| | | */ |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | ByteString value) |
| | | ByteString assertionValue) |
| | | { |
| | | OrderingMatchingRule matchingRule = |
| | | rule.getAttributeType().getOrderingMatchingRule(); |
| | | MatchingRule matchingRule = rule.getAttributeType().getOrderingMatchingRule(); |
| | | if (matchingRule == null) |
| | | { |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | ByteString normalizedValue; |
| | | Assertion assertion = null; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | assertion = matchingRule.getGreaterOrEqualAssertion(assertionValue); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // We couldn't normalize the provided value => return "undefined". |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (matchingRule.compareValues(nv, normalizedValue) >= 0) |
| | | if (assertion.matches(matchingRule.normalizeAttributeValue(v)).toBoolean()) |
| | | { |
| | | return ConditionResult.TRUE; |
| | | } |
| | |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // We couldn't normalize one of the attribute values. |
| | | // We will return "undefined" if we can't find a definite match |
| | | result = ConditionResult.UNDEFINED; |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this virtual attribute provider will generate |
| | | * any value for the provided entry that is less than or equal to |
| | | * the given value. |
| | | * Indicates whether this virtual attribute provider will generate any value |
| | | * for the provided entry that is less than or equal to the given value. |
| | | * |
| | | * @param entry The entry for which to make the determination. |
| | | * @param rule The virtual attribute rule which defines the |
| | | * constraints for the virtual attribute. |
| | | * @param value The value for which to make the determination. |
| | | * |
| | | * @return {@code UNDEFINED} if the associated attribute type does |
| | | * not have an ordering matching rule, {@code TRUE} if at |
| | | * least one of the generated values will be less than or |
| | | * equal to the specified value, or {@code FALSE} if none |
| | | * of the generated values will be greater than or equal to |
| | | * the specified value. |
| | | * @param entry |
| | | * The entry for which to make the determination. |
| | | * @param rule |
| | | * The virtual attribute rule which defines the constraints for the |
| | | * virtual attribute. |
| | | * @param assertionValue |
| | | * The value for which to make the determination. |
| | | * @return {@code UNDEFINED} if the associated attribute type does not have an |
| | | * ordering matching rule, {@code TRUE} if at least one of the |
| | | * generated values will be less than or equal to the specified value, |
| | | * or {@code FALSE} if none of the generated values will be greater |
| | | * than or equal to the specified value. |
| | | */ |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | ByteString value) |
| | | ByteString assertionValue) |
| | | { |
| | | OrderingMatchingRule matchingRule = |
| | | rule.getAttributeType().getOrderingMatchingRule(); |
| | | MatchingRule matchingRule = rule.getAttributeType().getOrderingMatchingRule(); |
| | | if (matchingRule == null) |
| | | { |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | ByteString normalizedValue; |
| | | Assertion assertion = null; |
| | | try |
| | | { |
| | | normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | assertion = matchingRule.getLessOrEqualAssertion(assertionValue); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // We couldn't normalize the provided value => return "undefined". |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (matchingRule.compareValues(nv, normalizedValue) <= 0) |
| | | if (assertion.matches(matchingRule.normalizeAttributeValue(v)).toBoolean()) |
| | | { |
| | | return ConditionResult.TRUE; |
| | | } |
| | |
| | | * @param entry The entry for which to make the determination. |
| | | * @param rule The virtual attribute rule which defines the |
| | | * constraints for the virtual attribute. |
| | | * @param value The value for which to make the determination. |
| | | * @param assertionValue The value for which to make the determination. |
| | | * |
| | | * @return {@code UNDEFINED} if the associated attribute type does |
| | | * not have an approximate matching rule, {@code TRUE} if at |
| | |
| | | */ |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | ByteString value) |
| | | ByteString assertionValue) |
| | | { |
| | | MatchingRule matchingRule = rule.getAttributeType().getApproximateMatchingRule(); |
| | | if (matchingRule == null) |
| | |
| | | Assertion assertion = null; |
| | | try |
| | | { |
| | | assertion = matchingRule.getAssertion(value); |
| | | assertion = matchingRule.getAssertion(assertionValue); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | result = assertion.matches(matchingRule.normalizeAttributeValue(v)); |
| | | if (assertion.matches(matchingRule.normalizeAttributeValue(v)).toBoolean()) |
| | | { |
| | | return ConditionResult.TRUE; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |