From 0e8959961d70e402fccea12d371756d10df5f34b Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 03 Nov 2015 16:49:00 +0000
Subject: [PATCH] IntegerFirstComponentEqualityMatchingRuleImpl.java: In normalizeAttributeValue(), used ByteString.valueOfObject() instead of ByteString.valueOfInt()
---
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java | 31 +++++++++++++------------------
opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java | 10 +++++++++-
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java b/opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java
index f9ac447..de600a7 100644
--- a/opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java
+++ b/opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2012 ForgeRock AS.
+ * Portions copyright 2012-2015 ForgeRock AS.
*/
package com.forgerock.opendj.util;
@@ -150,4 +150,12 @@
}
return skipped;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "("
+ + "source=" + source
+ + ", remaining=" + source.substring(pos, length)
+ + ")";
+ }
}
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java
index e7f7edb..863c05c 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java
@@ -54,36 +54,27 @@
}
@Override
- public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
- throws DecodeException {
+ public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue) throws DecodeException {
try {
final String definition = assertionValue.toString();
- final SubstringReader reader = new SubstringReader(definition);
- final int intValue = SchemaUtils.readRuleID(reader);
- return defaultAssertion(ByteString.valueOfInt(intValue));
+ return defaultAssertion(normalizeRuleID(new SubstringReader(definition)));
} catch (final Exception e) {
logger.debug(LocalizableMessage.raw("%s", e));
-
- final LocalizableMessage message =
- ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(assertionValue.toString());
- throw DecodeException.error(message);
+ throw DecodeException.error(ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(assertionValue));
}
}
- 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) {
- // This means that the value was empty or contained only
- // whitespace. That is illegal.
- final LocalizableMessage message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get();
- throw DecodeException.error(message);
+ // This means that the value was empty or contained only whitespace.
+ // That is illegal.
+ throw DecodeException.error(ERR_ATTR_SYNTAX_EMPTY_VALUE.get());
}
// The next character must be an open parenthesis.
@@ -98,6 +89,10 @@
reader.skipWhitespaces();
// The next set of characters must be the OID.
- return ByteString.valueOfObject(SchemaUtils.readRuleID(reader));
+ return normalizeRuleID(reader);
+ }
+
+ private ByteString normalizeRuleID(final SubstringReader reader) throws DecodeException {
+ return ByteString.valueOfInt(SchemaUtils.readRuleID(reader));
}
}
--
Gitblit v1.10.0