From 4f3f49d8c31f9c5bcc46b7902a160e733c274573 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 18 Feb 2015 12:28:51 +0000
Subject: [PATCH] ObjectIdentifier*EqualityMatchingRuleImpl.java: Removed duplicated code

---
 opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java |   32 ++++++++++++--------------------
 opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java               |   23 ++++++++---------------
 2 files changed, 20 insertions(+), 35 deletions(-)

diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java
index a194590..fc074d6 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java
@@ -22,11 +22,13 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions copyright 2011-2014 ForgeRock AS
+ *      Portions copyright 2011-2015 ForgeRock AS
  */
 package org.forgerock.opendj.ldap.schema;
 
-import org.forgerock.opendj.ldap.Assertion;
+import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
+import static org.forgerock.opendj.ldap.schema.SchemaUtils.*;
+
 import org.forgerock.opendj.ldap.ByteSequence;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DecodeException;
@@ -34,9 +36,6 @@
 import com.forgerock.opendj.util.StaticUtils;
 import com.forgerock.opendj.util.SubstringReader;
 
-import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
-import static org.forgerock.opendj.ldap.schema.SchemaUtils.*;
-
 /**
  * This class defines the objectIdentifierMatch matching rule defined in X.520
  * and referenced in RFC 2252. This expects to work on OIDs and will match
@@ -80,21 +79,15 @@
     }
 
     @Override
-    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
-            throws DecodeException {
-        final String definition = assertionValue.toString();
-        final SubstringReader reader = new SubstringReader(definition);
-        final String oid = readOID(reader, schema.getOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS));
-        final String normalized = resolveNames(schema, oid);
-        return DefaultAssertion.equality(ByteString.valueOf(normalized));
+    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) throws DecodeException {
+        return normalizeAttributeValuePrivate(schema, value);
     }
 
-    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
+    static ByteString normalizeAttributeValuePrivate(final Schema schema, final ByteSequence value)
             throws DecodeException {
         final String definition = value.toString();
         final SubstringReader reader = new SubstringReader(definition);
         final String oid = readOID(reader, schema.getOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS));
-        final String normalized = resolveNames(schema, oid);
-        return ByteString.valueOf(normalized);
+        return ByteString.valueOf(resolveNames(schema, oid));
     }
 }
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java
index 372d9bc..50cf1a9 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java
@@ -22,12 +22,15 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions copyright 2011-2014 ForgeRock AS
+ *      Portions copyright 2011-2015 ForgeRock AS
  */
 package org.forgerock.opendj.ldap.schema;
 
-import static com.forgerock.opendj.ldap.CoreMessages.ERR_ATTR_SYNTAX_EMPTY_VALUE;
-import static com.forgerock.opendj.ldap.CoreMessages.ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS;
+import static com.forgerock.opendj.ldap.CoreMessages.*;
+
+import static org.forgerock.opendj.ldap.schema.ObjectIdentifierEqualityMatchingRuleImpl.*;
+import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
+import static org.forgerock.opendj.ldap.schema.SchemaUtils.*;
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.opendj.ldap.Assertion;
@@ -37,9 +40,6 @@
 
 import com.forgerock.opendj.util.SubstringReader;
 
-import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
-import static org.forgerock.opendj.ldap.schema.SchemaUtils.*;
-
 /**
  * This class implements the objectIdentifierFirstComponentMatch matching rule
  * defined in X.520 and referenced in RFC 2252. This rule is intended for use
@@ -51,23 +51,16 @@
 final class ObjectIdentifierFirstComponentEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
 
     @Override
-    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
-            throws DecodeException {
-        final String definition = assertionValue.toString();
-        final SubstringReader reader = new SubstringReader(definition);
-        final String oid = readOID(reader, schema.getOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS));
-        final String normalized = ObjectIdentifierEqualityMatchingRuleImpl.resolveNames(schema, oid);
-        return DefaultAssertion.equality(ByteString.valueOf(normalized));
+    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue) throws DecodeException {
+        return DefaultAssertion.equality(normalizeAttributeValuePrivate(schema, assertionValue));
     }
 
     @Override
-    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
-            throws DecodeException {
+    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) throws DecodeException {
         final String definition = value.toString();
         final SubstringReader reader = new SubstringReader(definition);
 
-        // We'll do this a character at a time. First, skip over any leading
-        // whitespace.
+        // We'll do this a character at a time. First, skip over any leading whitespace.
         reader.skipWhitespaces();
 
         if (reader.remaining() <= 0) {
@@ -88,8 +81,7 @@
         reader.skipWhitespaces();
 
         // The next set of characters must be the OID.
-        final String normalized = ObjectIdentifierEqualityMatchingRuleImpl.resolveNames(schema,
-            readOID(reader, schema.getOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS)));
-        return ByteString.valueOf(normalized);
+        final String oid = readOID(reader, schema.getOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS));
+        return ByteString.valueOf(resolveNames(schema, oid));
     }
 }

--
Gitblit v1.10.0