mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
28.15.2014 f2d3de2ba42488de34c0298a78f06f9b51911424
OPENDJ-1308 Migrate schema support

Preparation work for removing org.opends.server.api.MatchingRule.normalizeAssertionValue().


Assertion.java:
In matches(), renamed attributeValue parameter to normalizedAttributeValue.

MatchingRuleImpl.java:
In getAssertion(), renamed value parameter to assertionValue.
Fixed javadocs.

AbstractApproximateMatchingRuleImpl.java, AbstractEqualityMatchingRuleImpl.java: ADDED
Made the relevant approximate and equality matching rule classes subclass these new ones.

AbstractMatchingRuleImpl.java:
In getAssertion(), returned UNDEFINED_ASSERTION.
Extracted method trimConsecutiveSpaces() here from several places in the code.

WordEqualityMatchingRuleImpl.java: REMOVED
Implementation was the same as KeywordEqualityMatchingRuleImpl so reused that class instead + updated CoreSchemaImpl.

KeywordEqualityMatchingRuleImpl.java:
Extracted method isAcceptable().
Removed useless calls to String.intern() on String literals.

IntegerFirstComponentEqualityMatchingRuleImpl.java:
In getAssertion(), used DefaultEqualityAssertion instead of custom built Assertion.

EnumSyntaxTestCase.java:
Made the code more readable.

*.java:
Simplified code by using ConditionResult.valueOf().
1 files deleted
2 files added
41 files modified
654 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java 5 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java 48 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java 48 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java 22 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java 10 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java 10 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AuthPasswordExactEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/BitStringEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/BooleanEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactEqualityMatchingRuleImpl.java 11 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactIA5EqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactOrderingMatchingRuleImpl.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleImpl.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreEqualityMatchingRuleImpl.java 11 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5EqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListSubstringMatchingRuleImpl.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreOrderingMatchingRuleImpl.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleImpl.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CoreSchemaImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleImpl.java 23 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DistinguishedNameEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DoubleMetaphoneApproximateMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnumSyntaxImpl.java 12 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EqualLengthApproximateMatchingRuleImpl.java 9 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerEqualityMatchingRuleImpl.java 8 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java 18 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerOrderingMatchingRuleImpl.java 6 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java 63 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java 31 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/PresentationAddressEqualityMatchingRuleImpl.java 11 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ProtocolInformationEqualityMatchingRuleImpl.java 11 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UUIDEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UserPasswordExactEqualityMatchingRuleImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/WordEqualityMatchingRuleImpl.java 155 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EnumSyntaxTestCase.java 44 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java 9 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java
@@ -24,7 +24,6 @@
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS
 */
package org.forgerock.opendj.ldap;
/**
@@ -35,11 +34,11 @@
     * Indicates whether the provided attribute value should be considered a
     * match for this assertion value according to the matching rule.
     *
     * @param attributeValue
     * @param normalizedAttributeValue
     *            The normalized attribute value.
     * @return {@code TRUE} if the attribute value should be considered a match
     *         for the provided assertion value, {@code FALSE} if it does not
     *         match, or {@code UNDEFINED} if the result is undefined.
     */
    public abstract ConditionResult matches(ByteSequence attributeValue);
    ConditionResult matches(ByteSequence normalizedAttributeValue);
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java
New file
@@ -0,0 +1,48 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2014 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.DecodeException;
/**
 * This class implements an approximate matching rule that matches normalized
 * values in byte order.
 */
abstract class AbstractApproximateMatchingRuleImpl extends AbstractMatchingRuleImpl {
    AbstractApproximateMatchingRuleImpl() {
        // Nothing to do.
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        return new DefaultEqualityAssertion(normalizeAttributeValue(schema, assertionValue));
    }
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java
New file
@@ -0,0 +1,48 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2014 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.DecodeException;
/**
 * This class implements an equality matching rule that matches normalized
 * values in byte order.
 */
abstract class AbstractEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
    AbstractEqualityMatchingRuleImpl() {
        // Nothing to do.
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        return new DefaultEqualityAssertion(normalizeAttributeValue(schema, assertionValue));
    }
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
@@ -38,16 +38,15 @@
 * matches normalized values in byte order.
 */
abstract class AbstractMatchingRuleImpl implements MatchingRuleImpl {
    static class DefaultEqualityAssertion implements Assertion {
        ByteSequence normalizedAssertionValue;
    static final class DefaultEqualityAssertion implements Assertion {
        private final ByteSequence normalizedAssertionValue;
        protected DefaultEqualityAssertion(final ByteSequence normalizedAssertionValue) {
        DefaultEqualityAssertion(final ByteSequence normalizedAssertionValue) {
            this.normalizedAssertionValue = normalizedAssertionValue;
        }
        public ConditionResult matches(final ByteSequence attributeValue) {
            return normalizedAssertionValue.equals(attributeValue) ? ConditionResult.TRUE
                    : ConditionResult.FALSE;
            return ConditionResult.valueOf(normalizedAssertionValue.equals(attributeValue));
        }
    }
@@ -72,9 +71,9 @@
        return DEFAULT_COMPARATOR;
    }
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        return new DefaultEqualityAssertion(normalizeAttributeValue(schema, value));
        return UNDEFINED_ASSERTION;
    }
    public Assertion getSubstringAssertion(final Schema schema, final ByteSequence subInitial,
@@ -92,4 +91,13 @@
            throws DecodeException {
        return UNDEFINED_ASSERTION;
    }
    static void trimConsecutiveSpaces(StringBuilder buffer) {
        for (int pos = buffer.length() - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' '
                    && buffer.charAt(pos - 1) == ' ') {
                buffer.delete(pos, pos + 1);
            }
        }
    }
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java
@@ -40,14 +40,12 @@
        // Nothing to do.
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
            throws DecodeException {
        final ByteString normAssertion = normalizeAttributeValue(schema, value);
        return new Assertion() {
            public ConditionResult matches(final ByteSequence attributeValue) {
                return attributeValue.compareTo(normAssertion) < 0 ? ConditionResult.TRUE
                        : ConditionResult.FALSE;
                return ConditionResult.valueOf(attributeValue.compareTo(normAssertion) < 0);
            }
        };
    }
@@ -58,8 +56,7 @@
        final ByteString normAssertion = normalizeAttributeValue(schema, value);
        return new Assertion() {
            public ConditionResult matches(final ByteSequence attributeValue) {
                return attributeValue.compareTo(normAssertion) >= 0 ? ConditionResult.TRUE
                        : ConditionResult.FALSE;
                return ConditionResult.valueOf(attributeValue.compareTo(normAssertion) >= 0);
            }
        };
    }
@@ -70,8 +67,7 @@
        final ByteString normAssertion = normalizeAttributeValue(schema, value);
        return new Assertion() {
            public ConditionResult matches(final ByteSequence attributeValue) {
                return attributeValue.compareTo(normAssertion) <= 0 ? ConditionResult.TRUE
                        : ConditionResult.FALSE;
                return ConditionResult.valueOf(attributeValue.compareTo(normAssertion) <= 0);
            }
        };
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
@@ -131,9 +131,9 @@
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        if (value.length() == 0) {
        if (assertionValue.length() == 0) {
            throw DecodeException.error(WARN_ATTR_SYNTAX_SUBSTRING_EMPTY.get());
        }
@@ -141,7 +141,7 @@
        ByteSequence finalString = null;
        List<ByteSequence> anyStrings = null;
        final String valueString = value.toString();
        final String valueString = assertionValue.toString();
        if (valueString.length() == 1 && valueString.charAt(0) == '*') {
            return getSubstringAssertion(schema, initialString, anyStrings, finalString);
@@ -155,7 +155,7 @@
            initialString = normalizeSubString(schema, bytes);
        }
        if (reader.remaining() == 0) {
            throw DecodeException.error(WARN_ATTR_SYNTAX_SUBSTRING_NO_WILDCARDS.get(value
            throw DecodeException.error(WARN_ATTR_SYNTAX_SUBSTRING_NO_WILDCARDS.get(assertionValue
                    .toString()));
        }
        while (true) {
@@ -164,7 +164,7 @@
            if (reader.remaining() > 0) {
                if (bytes.length() == 0) {
                    throw DecodeException.error(WARN_ATTR_SYNTAX_SUBSTRING_CONSECUTIVE_WILDCARDS
                            .get(value.toString(), reader.pos()));
                            .get(assertionValue.toString(), reader.pos()));
                }
                if (anyStrings == null) {
                    anyStrings = new LinkedList<ByteSequence>();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AuthPasswordExactEqualityMatchingRuleImpl.java
@@ -33,7 +33,7 @@
 * This class implements the authPasswordMatch matching rule defined in RFC
 * 3112.
 */
final class AuthPasswordExactEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class AuthPasswordExactEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        final StringBuilder[] authPWComponents =
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/BitStringEqualityMatchingRuleImpl.java
@@ -38,7 +38,7 @@
 * This class defines the bitStringMatch matching rule defined in X.520 and
 * referenced in RFC 2252.
 */
final class BitStringEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class BitStringEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        final String valueString = value.toString().toUpperCase();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/BooleanEqualityMatchingRuleImpl.java
@@ -35,7 +35,7 @@
 * This class defines the booleanMatch matching rule defined in X.520 and
 * referenced in RFC 4519.
 */
final class BooleanEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class BooleanEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        final String valueString = value.toString().toUpperCase();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * This class defines the caseExactMatch matching rule defined in X.520 and
 * referenced in RFC 4519.
 */
final class CaseExactEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class CaseExactEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
@@ -53,14 +53,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactIA5EqualityMatchingRuleImpl.java
@@ -39,7 +39,7 @@
 * This class implements the caseExactIA5Match matching rule defined in RFC
 * 2252.
 */
final class CaseExactIA5EqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class CaseExactIA5EqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        final StringBuilder buffer = new StringBuilder();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactOrderingMatchingRuleImpl.java
@@ -53,14 +53,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleImpl.java
@@ -64,14 +64,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * This class defines the caseIgnoreMatch matching rule defined in X.520 and
 * referenced in RFC 2252.
 */
final class CaseIgnoreEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class CaseIgnoreEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -53,14 +53,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5EqualityMatchingRuleImpl.java
@@ -39,7 +39,7 @@
 * This class implements the caseIgnoreIA5Match matching rule defined in RFC
 * 2252.
 */
final class CaseIgnoreIA5EqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class CaseIgnoreIA5EqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        final StringBuilder buffer = new StringBuilder();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * This class implements the caseIgnoreListMatch matching rule defined in X.520
 * and referenced in RFC 2252.
 */
final class CaseIgnoreListEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class CaseIgnoreListEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListSubstringMatchingRuleImpl.java
@@ -96,14 +96,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreOrderingMatchingRuleImpl.java
@@ -53,14 +53,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleImpl.java
@@ -66,14 +66,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CoreSchemaImpl.java
@@ -811,7 +811,7 @@
                .syntaxOID(SYNTAX_NAME_AND_OPTIONAL_UID_OID).extraProperties(RFC4512_ORIGIN)
                .implementation(new UniqueMemberEqualityMatchingRuleImpl()).addToSchema();
        builder.buildMatchingRule(EMR_WORD_OID).names(EMR_WORD_NAME).syntaxOID(SYNTAX_DIRECTORY_STRING_OID)
                .extraProperties(RFC4512_ORIGIN).implementation(new WordEqualityMatchingRuleImpl())
                .extraProperties(RFC4512_ORIGIN).implementation(new KeywordEqualityMatchingRuleImpl())
                .addToSchema();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleImpl.java
@@ -47,15 +47,15 @@
 * objectclass descriptions) in which the "first component" is the first item
 * after the opening parenthesis.
 */
final class DirectoryStringFirstComponentEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class DirectoryStringFirstComponentEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value) {
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
        prepareUnicode(buffer, assertionValue, TRIM, CASE_FOLD);
        final int bufferLength = buffer.length();
        if (bufferLength == 0) {
            if (value.length() > 0) {
            if (assertionValue.length() > 0) {
                // This should only happen if the value is composed entirely of
                // spaces. In that case, the normalized value is a single space.
                return new DefaultEqualityAssertion(SchemaConstants.SINGLE_SPACE_VALUE);
@@ -65,14 +65,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return new DefaultEqualityAssertion(ByteString.valueOf(buffer.toString()));
    }
@@ -95,8 +88,7 @@
        }
        // The next character must be an open parenthesis. If it is not,
        // then
        // that is an error.
        // then that is an error.
        final char c = reader.read();
        if (c != '(') {
            final LocalizableMessage message =
@@ -105,8 +97,7 @@
            throw DecodeException.error(message);
        }
        // Skip over any spaces immediately following the opening
        // parenthesis.
        // Skip over any spaces immediately following the opening parenthesis.
        reader.skipWhitespaces();
        // The next set of characters must be the OID.
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DistinguishedNameEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * This class defines the distinguishedNameMatch matching rule defined in X.520
 * and referenced in RFC 2252.
 */
final class DistinguishedNameEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class DistinguishedNameEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    /**
     * {@inheritDoc}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DoubleMetaphoneApproximateMatchingRuleImpl.java
@@ -49,7 +49,7 @@
 * redundant checks that aren't needed. It has also been updated to always only
 * generate a single value rather than one or possibly two values.
 */
final class DoubleMetaphoneApproximateMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class DoubleMetaphoneApproximateMatchingRuleImpl extends AbstractApproximateMatchingRuleImpl {
    private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnumSyntaxImpl.java
@@ -23,13 +23,14 @@
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 */
package org.forgerock.opendj.ldap.schema;
import static com.forgerock.opendj.util.StringPrepProfile.CASE_FOLD;
import static com.forgerock.opendj.util.StringPrepProfile.TRIM;
import static com.forgerock.opendj.util.StringPrepProfile.prepareUnicode;
import static com.forgerock.opendj.ldap.CoreMessages.WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_INVALID_VALUE;
import static org.forgerock.opendj.ldap.schema.AbstractMatchingRuleImpl.*;
import static org.forgerock.opendj.ldap.schema.SchemaConstants.AMR_DOUBLE_METAPHONE_OID;
import static org.forgerock.opendj.ldap.schema.SchemaConstants.EMR_CASE_IGNORE_OID;
import static org.forgerock.opendj.ldap.schema.SchemaConstants.OMR_OID_GENERIC_ENUM;
@@ -131,14 +132,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return buffer.toString();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EqualLengthApproximateMatchingRuleImpl.java
@@ -36,14 +36,14 @@
 * consider two values approximately equal only if they have the same length. It
 * is intended purely for testing purposes.
 */
final class EqualLengthApproximateMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class EqualLengthApproximateMatchingRuleImpl extends AbstractApproximateMatchingRuleImpl {
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        return new Assertion() {
            @Override
            public ConditionResult matches(final ByteSequence attributeValue) {
                return attributeValue.length() == value.length() ? ConditionResult.TRUE
                        : ConditionResult.FALSE;
                return ConditionResult.valueOf(attributeValue.length() == assertionValue.length());
            }
        };
    }
@@ -51,6 +51,7 @@
    /**
     * {@inheritDoc}
     */
    @Override
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        return value.toByteString();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * This class defines the generalizedTimeMatch matching rule defined in X.520
 * and referenced in RFC 2252.
 */
final class GeneralizedTimeEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class GeneralizedTimeEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        try {
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerEqualityMatchingRuleImpl.java
@@ -38,20 +38,18 @@
 * This class defines the integerMatch matching rule defined in X.520 and
 * referenced in RFC 2252.
 */
final class IntegerEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class IntegerEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
    @Override
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        try {
            return ByteString.valueOf(Integer.parseInt(value.toString()));
        } catch (final Exception e) {
            logger.debug(LocalizableMessage.raw("%s", e));
            final LocalizableMessage message =
                    WARN_ATTR_SYNTAX_ILLEGAL_INTEGER.get(value.toString());
            throw DecodeException.error(message);
            throw DecodeException.error(WARN_ATTR_SYNTAX_ILLEGAL_INTEGER.get(value));
        }
    }
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java
@@ -33,7 +33,6 @@
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
import com.forgerock.opendj.util.SubstringReader;
@@ -45,30 +44,23 @@
 * objectclass descriptions) in which the "first component" is the first item
 * after the opening parenthesis.
 */
final class IntegerFirstComponentEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class IntegerFirstComponentEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        try {
            final String definition = value.toString();
            final String definition = assertionValue.toString();
            final SubstringReader reader = new SubstringReader(definition);
            final int intValue = SchemaUtils.readRuleID(reader);
            return new Assertion() {
                public ConditionResult matches(final ByteSequence attributeValue) {
                    final int actualIntValue = attributeValue.toByteString().toInt();
                    return intValue == actualIntValue ? ConditionResult.TRUE
                            : ConditionResult.FALSE;
                }
            };
            return new DefaultEqualityAssertion(ByteString.valueOf(intValue));
        } catch (final Exception e) {
            logger.debug(LocalizableMessage.raw("%s", e));
            final LocalizableMessage message =
                    ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(value.toString());
                    ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(assertionValue.toString());
            throw DecodeException.error(message);
        }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerOrderingMatchingRuleImpl.java
@@ -42,16 +42,14 @@
    private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
    @Override
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        try {
            return ByteString.valueOf(Integer.parseInt(value.toString()));
        } catch (final Exception e) {
            logger.debug(LocalizableMessage.raw("%s", e));
            final LocalizableMessage message =
                    WARN_ATTR_SYNTAX_ILLEGAL_INTEGER.get(value.toString());
            throw DecodeException.error(message);
            throw DecodeException.error(WARN_ATTR_SYNTAX_ILLEGAL_INTEGER.get(value));
        }
    }
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java
@@ -39,8 +39,8 @@
 * This class implements the keywordMatch matching rule defined in X.520. That
 * document defines "keyword" as implementation-specific, but in this case we
 * will consider it a match if the assertion value is contained within the
 * attribute value and is bounded by the edge of the value or any of the
 * following characters: <BR>
 * attribute value and is bounded by the start or the end of the attribute value
 * or any of the following characters: <BR>
 * <UL>
 * <LI>A space</LI>
 * <LI>A period</LI>
@@ -54,11 +54,11 @@
 * <LI>An equal sign</LI>
 * </UL>
 */
final class KeywordEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class KeywordEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        final String normalStr = normalize(value);
        final String normalStr = normalize(assertionValue);
        return new Assertion() {
            public ConditionResult matches(final ByteSequence attributeValue) {
@@ -73,28 +73,23 @@
                if (pos > 0) {
                    final char c = valueStr1.charAt(pos - 1);
                    switch (c) {
                    case ' ':
                    case '.':
                    case ',':
                    case '/':
                    case '$':
                    case '+':
                    case '-':
                    case '_':
                    case '#':
                    case '=':
                        // These are all acceptable.
                        break;
                    default:
                        // Anything else is not.
                    if (!isAcceptable(c)) {
                        return ConditionResult.FALSE;
                    }
                }
                if (valueStr1.length() > pos + normalStr.length()) {
                    final char c = valueStr1.charAt(pos + normalStr.length());
                    if (!isAcceptable(c)) {
                        return ConditionResult.FALSE;
                    }
                }
                // If we've gotten here, then we can assume it is a match.
                return ConditionResult.TRUE;
            }
            private boolean isAcceptable(final char c) {
                    switch (c) {
                    case ' ':
                    case '.':
@@ -106,18 +101,12 @@
                    case '_':
                    case '#':
                    case '=':
                        // These are all acceptable.
                        break;
                    return true;
                    default:
                        // Anything else is not.
                        return ConditionResult.FALSE;
                    return false;
                    }
                }
                // If we've gotten here, then we can assume it is a match.
                return ConditionResult.TRUE;
            }
        };
    }
@@ -129,26 +118,18 @@
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
        final int bufferLength = buffer.length();
        if (bufferLength == 0) {
        if (buffer.length() == 0) {
            if (value.length() > 0) {
                // This should only happen if the value is composed entirely of
                // spaces. In that case, the normalized value is a single space.
                return " ".intern();
                return " ";
            } else {
                // The value is empty, so it is already normalized.
                return "".intern();
                return "";
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return buffer.toString();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java
@@ -47,23 +47,23 @@
     * @return A comparator that can be used to compare the attribute values
     *         normalized by this matching rule.
     */
    public Comparator<ByteSequence> comparator(Schema schema);
    Comparator<ByteSequence> comparator(Schema schema);
    /**
     * Retrieves the normalized form of the provided assertion value, which is
     * best suited for efficiently performing matching operations on that value.
     * The assertion value is guarenteed to be valid against this matching
     * The assertion value is guaranteed to be valid against this matching
     * rule's assertion syntax.
     *
     * @param schema
     *            The schema in which this matching rule is defined.
     * @param value
     * @param assertionValue
     *            The syntax checked assertion value to be normalized.
     * @return The normalized version of the provided assertion value.
     * @throws DecodeException
     *             if an syntax error occured while parsing the value.
     *             if an syntax error occurred while parsing the value.
     */
    public Assertion getAssertion(Schema schema, ByteSequence value) throws DecodeException;
    Assertion getAssertion(Schema schema, ByteSequence assertionValue) throws DecodeException;
    /**
     * Retrieves the normalized form of the provided assertion substring values,
@@ -83,16 +83,16 @@
     *            the end of the target value.
     * @return The normalized version of the provided assertion value.
     * @throws DecodeException
     *             if an syntax error occured while parsing the value.
     *             if an syntax error occurred while parsing the value.
     */
    public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
    Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
            List<? extends ByteSequence> subAnyElements, ByteSequence subFinal)
            throws DecodeException;
    /**
     * Retrieves the normalized form of the provided assertion value, which is
     * best suited for efficiently performing greater than or equal matching
     * operations on that value. The assertion value is guarenteed to be valid
     * operations on that value. The assertion value is guaranteed to be valid
     * against this matching rule's assertion syntax.
     *
     * @param schema
@@ -101,15 +101,15 @@
     *            The syntax checked assertion value to be normalized.
     * @return The normalized version of the provided assertion value.
     * @throws DecodeException
     *             if an syntax error occured while parsing the value.
     *             if an syntax error occurred while parsing the value.
     */
    public Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value)
    Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value)
            throws DecodeException;
    /**
     * Retrieves the normalized form of the provided assertion value, which is
     * best suited for efficiently performing greater than or equal matching
     * operations on that value. The assertion value is guarenteed to be valid
     * operations on that value. The assertion value is guaranteed to be valid
     * against this matching rule's assertion syntax.
     *
     * @param schema
@@ -118,9 +118,9 @@
     *            The syntax checked assertion value to be normalized.
     * @return The normalized version of the provided assertion value.
     * @throws DecodeException
     *             if an syntax error occured while parsing the value.
     *             if an syntax error occurred while parsing the value.
     */
    public Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value)
    Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value)
            throws DecodeException;
    /**
@@ -133,8 +133,9 @@
     *            The attribute value to be normalized.
     * @return The normalized version of the provided attribute value.
     * @throws DecodeException
     *             if an syntax error occured while parsing the value.
     *             if an syntax error occurred while parsing the value.
     */
    public ByteString normalizeAttributeValue(Schema schema, ByteSequence value)
    ByteString normalizeAttributeValue(Schema schema, ByteSequence value)
            throws DecodeException;
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleImpl.java
@@ -37,7 +37,7 @@
 * and referenced in RFC 2252. It allows for values with numeric digits and
 * spaces, but ignores spaces when performing matching.
 */
final class NumericStringEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class NumericStringEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java
@@ -40,7 +40,7 @@
 * either an attribute/objectclass name or a numeric OID. NOTE: This matching
 * rule requires a schema to lookup object identifiers in the descriptor form.
 */
final class ObjectIdentifierEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class ObjectIdentifierEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    static String resolveNames(final Schema schema, final String oid) {
        if (!StaticUtils.isDigit(oid.charAt(0))) {
            // Do an best effort attempt to normalize names to OIDs.
@@ -97,9 +97,9 @@
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        final String definition = value.toString();
        final String definition = assertionValue.toString();
        final SubstringReader reader = new SubstringReader(definition);
        final String normalized =
                resolveNames(schema, SchemaUtils.readOID(reader, schema
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java
@@ -45,11 +45,11 @@
 * objectclass descriptions) in which the "first component" is the first item
 * after the opening parenthesis.
 */
final class ObjectIdentifierFirstComponentEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class ObjectIdentifierFirstComponentEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence value)
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        final String definition = value.toString();
        final String definition = assertionValue.toString();
        final SubstringReader reader = new SubstringReader(definition);
        final String normalized =
                ObjectIdentifierEqualityMatchingRuleImpl.resolveNames(schema, SchemaUtils.readOID(
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringEqualityMatchingRuleImpl.java
@@ -33,7 +33,7 @@
 * will be used as the default equality matching rule for the binary and octet
 * string syntaxes.
 */
final class OctetStringEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class OctetStringEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        return value.toByteString();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/PresentationAddressEqualityMatchingRuleImpl.java
@@ -38,7 +38,7 @@
 * associated syntax have been deprecated, this matching rule behaves exactly
 * like the caseIgnoreMatch rule.
 */
final class PresentationAddressEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class PresentationAddressEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -55,14 +55,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ProtocolInformationEqualityMatchingRuleImpl.java
@@ -38,7 +38,7 @@
 * associated syntax have been deprecated, this matching rule behaves exactly
 * like the caseIgnoreMatch rule.
 */
final class ProtocolInformationEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class ProtocolInformationEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -55,14 +55,7 @@
            }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength - 1; pos > 0; pos--) {
            if (buffer.charAt(pos) == ' ') {
                if (buffer.charAt(pos - 1) == ' ') {
                    buffer.delete(pos, pos + 1);
                }
            }
        }
        trimConsecutiveSpaces(buffer);
        return ByteString.valueOf(buffer.toString());
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * very rigorous format, this is widely ignored so this matching will compare
 * only numeric digits and strip out everything else.
 */
final class TelephoneNumberEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class TelephoneNumberEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        final String valueString = value.toString();
        final int valueLength = valueString.length();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UUIDEqualityMatchingRuleImpl.java
@@ -38,7 +38,7 @@
 * This class defines the uuidMatch matching rule defined in RFC 4530. It will
 * be used as the default equality matching rule for the UUID syntax.
 */
final class UUIDEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class UUIDEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        if (value.length() != 36) {
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java
@@ -34,7 +34,7 @@
 * and will compare values with a distinguished name and optional bit string
 * suffix.
 */
final class UniqueMemberEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class UniqueMemberEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
        return value.toByteString();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UserPasswordExactEqualityMatchingRuleImpl.java
@@ -36,7 +36,7 @@
 * simply compare encoded hashed password values to see if they are exactly
 * equal to each other.
 */
final class UserPasswordExactEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
final class UserPasswordExactEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
        // The normalized form of this matching rule is exactly equal to the
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/WordEqualityMatchingRuleImpl.java
File was deleted
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EnumSyntaxTestCase.java
@@ -26,15 +26,15 @@
 */
package org.forgerock.opendj.ldap.schema;
import static org.forgerock.opendj.ldap.schema.SchemaConstants.OMR_OID_GENERIC_ENUM;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.forgerock.opendj.ldap.ConditionResult.*;
import static org.forgerock.opendj.ldap.schema.SchemaConstants.*;
import static org.testng.Assert.*;
/**
 * Enum syntax tests.
 */
@@ -58,27 +58,21 @@
        final Schema schema = builder.toSchema();
        final Syntax syntax = schema.getSyntax("3.3.3");
        final MatchingRule rule = syntax.getOrderingMatchingRule();
        Assert.assertEquals(rule.getGreaterOrEqualAssertion(ByteString.valueOf("monday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("thursday"))), ConditionResult.TRUE);
        Assert.assertEquals(rule.getLessOrEqualAssertion(ByteString.valueOf("monday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("thursday"))),
                ConditionResult.FALSE);
        Assert.assertEquals(rule.getGreaterOrEqualAssertion(ByteString.valueOf("tuesday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("monday"))), ConditionResult.FALSE);
        Assert.assertEquals(rule.getLessOrEqualAssertion(ByteString.valueOf("tuesday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("monday"))), ConditionResult.TRUE);
        Assert.assertEquals(rule.getGreaterOrEqualAssertion(ByteString.valueOf("tuesday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("tuesday"))), ConditionResult.TRUE);
        Assert.assertEquals(rule.getLessOrEqualAssertion(ByteString.valueOf("tuesday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("tuesday"))), ConditionResult.TRUE);
        Assert.assertEquals(rule.getAssertion(ByteString.valueOf("tuesday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("monday"))), ConditionResult.TRUE);
        Assert.assertEquals(rule.getAssertion(ByteString.valueOf("monday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("thursday"))),
                ConditionResult.FALSE);
        Assert.assertEquals(rule.getAssertion(ByteString.valueOf("tuesday")).matches(
                rule.normalizeAttributeValue(ByteString.valueOf("tuesday"))), ConditionResult.FALSE);
        Assert.assertNotNull(schema.getMatchingRule(OMR_OID_GENERIC_ENUM + ".3.3.3"));
        final ByteString monday = ByteString.valueOf("monday");
        final ByteString normMonday = rule.normalizeAttributeValue(monday);
        final ByteString tuesday = ByteString.valueOf("tuesday");
        final ByteString normTuesday = rule.normalizeAttributeValue(tuesday);
        final ByteString normThursday = rule.normalizeAttributeValue(ByteString.valueOf("thursday"));
        assertEquals(rule.getGreaterOrEqualAssertion(monday).matches(normThursday), TRUE);
        assertEquals(rule.getLessOrEqualAssertion(monday).matches(normThursday), FALSE);
        assertEquals(rule.getGreaterOrEqualAssertion(tuesday).matches(normMonday), FALSE);
        assertEquals(rule.getLessOrEqualAssertion(tuesday).matches(normMonday), TRUE);
        assertEquals(rule.getGreaterOrEqualAssertion(tuesday).matches(normTuesday), TRUE);
        assertEquals(rule.getLessOrEqualAssertion(tuesday).matches(normTuesday), TRUE);
        assertEquals(rule.getAssertion(tuesday).matches(normMonday), TRUE);
        assertEquals(rule.getAssertion(monday).matches(normThursday), FALSE);
        assertEquals(rule.getAssertion(tuesday).matches(normTuesday), FALSE);
        assertNotNull(schema.getMatchingRule(OMR_OID_GENERIC_ENUM + ".3.3.3"));
    }
    @Test
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java
@@ -79,16 +79,13 @@
        }
        Assertion a = ruleInstance.getGreaterOrEqualAssertion(ByteString.valueOf(value2));
        Assert.assertEquals(a.matches(normalizedValue1), result >= 0 ? ConditionResult.TRUE
                : ConditionResult.FALSE);
        Assert.assertEquals(a.matches(normalizedValue1), ConditionResult.valueOf(result >= 0));
        a = ruleInstance.getLessOrEqualAssertion(ByteString.valueOf(value2));
        Assert.assertEquals(a.matches(normalizedValue1), result <= 0 ? ConditionResult.TRUE
                : ConditionResult.FALSE);
        Assert.assertEquals(a.matches(normalizedValue1), ConditionResult.valueOf(result <= 0));
        a = ruleInstance.getAssertion(ByteString.valueOf(value2));
        Assert.assertEquals(a.matches(normalizedValue1), result < 0 ? ConditionResult.TRUE
                : ConditionResult.FALSE);
        Assert.assertEquals(a.matches(normalizedValue1), ConditionResult.valueOf(result < 0));
    }
    /**