From 333c7b4a76e819dec8d2b46a381e323266a16059 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 03 Apr 2014 13:53:49 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1308 Migrate schema support

---
 opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java |   68 +++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
index c377a94..1a871cc 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
@@ -52,6 +52,65 @@
 public abstract class AbstractMatchingRule implements MatchingRule
 {
 
+  /**
+   * Default implementation of assertion.
+   */
+  public static final class DefaultAssertion implements Assertion
+  {
+    /** The ID of the DB index to use with this assertion. */
+    private final String indexID;
+    private final ByteSequence normalizedAssertionValue;
+
+    /**
+     * Returns the equality assertion.
+     *
+     * @param normalizedAssertionValue
+     *          The value on which the assertion is built.
+     * @return the equality assertion
+     */
+    public static DefaultAssertion equality(final ByteSequence normalizedAssertionValue)
+    {
+      return new DefaultAssertion("equality", normalizedAssertionValue);
+    }
+
+    /**
+     * Returns the approximate assertion.
+     *
+     * @param normalizedAssertionValue
+     *          The value on which the assertion is built.
+     * @return the approximate assertion
+     */
+    static DefaultAssertion approximate(final ByteSequence normalizedAssertionValue)
+    {
+      return new DefaultAssertion("approximate", normalizedAssertionValue);
+    }
+
+    private DefaultAssertion(final String indexID, final ByteSequence normalizedAssertionValue)
+    {
+      this.indexID = indexID;
+      this.normalizedAssertionValue = normalizedAssertionValue;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ConditionResult matches(final ByteSequence normalizedAttributeValue)
+    {
+      return ConditionResult.valueOf(normalizedAssertionValue.equals(normalizedAttributeValue));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public <T> T createIndexQuery(IndexQueryFactory<T> factory)
+        throws DecodeException
+    {
+      return factory.createExactMatchQuery(indexID, normalizedAssertionValue);
+    }
+  }
+
   private static final Assertion UNDEFINED_ASSERTION = new Assertion()
   {
     @Override
@@ -71,9 +130,14 @@
   };
 
   /**
-   * {@inheritDoc}
+   * Returns the normalized form of the assertion value.
+   *
+   * @param value
+   *            The assertion value to normalize.
+   * @return the normalized value
+   * @throws DecodeException
+   *            If a problem occurs.
    */
-  @Override
   public ByteString normalizeAssertionValue(ByteSequence value)
       throws DecodeException
   {

--
Gitblit v1.10.0