From 824258860da133d056edd1e07a100bf81b66cd6a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 22 Oct 2014 07:47:32 +0000
Subject: [PATCH] Code cleanup.
---
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java | 48 ++++++++----------------------------------------
1 files changed, 8 insertions(+), 40 deletions(-)
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
index 6152df7..85a7b16 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
@@ -291,7 +291,7 @@
final char[] escapeChars = new char[] { '*' };
final SubstringReader reader = new SubstringReader(valueString);
- ByteString bytes = evaluateEscapes(reader, escapeChars, false);
+ ByteString bytes = evaluateEscapes(reader, escapeChars);
if (bytes.length() > 0) {
initialString = bytes;
}
@@ -300,7 +300,7 @@
}
while (true) {
reader.read();
- bytes = evaluateEscapes(reader, escapeChars, false);
+ bytes = evaluateEscapes(reader, escapeChars);
if (reader.remaining() > 0) {
if (bytes.length() == 0) {
throw DecodeException.error(WARN_ATTR_SYNTAX_SUBSTRING_CONSECUTIVE_WILDCARDS
@@ -487,23 +487,16 @@
return (char) b;
}
- private ByteString evaluateEscapes(final SubstringReader reader, final char[] escapeChars,
- final boolean trim) throws DecodeException {
- // FIXME JNR I believe the trim parameter is dead code
- return evaluateEscapes(reader, escapeChars, escapeChars, trim);
+ private ByteString evaluateEscapes(final SubstringReader reader, final char[] escapeChars) throws DecodeException {
+ return evaluateEscapes(reader, escapeChars, escapeChars);
}
private ByteString evaluateEscapes(final SubstringReader reader, final char[] escapeChars,
- final char[] delimiterChars, final boolean trim) throws DecodeException {
+ final char[] delimiterChars) throws DecodeException {
int length = 0;
- int lengthWithoutSpace = 0;
char c;
ByteStringBuilder valueBuffer = null;
- if (trim) {
- reader.skipWhitespaces();
- }
-
reader.mark();
while (reader.remaining() > 0) {
c = reader.read();
@@ -514,26 +507,16 @@
valueBuffer.append(reader.read(length));
valueBuffer.append(evaluateEscapedChar(reader, escapeChars));
reader.mark();
- length = lengthWithoutSpace = 0;
+ length = 0;
}
if (delimiterChars != null) {
for (final char delimiterChar : delimiterChars) {
if (c == delimiterChar) {
reader.reset();
if (valueBuffer != null) {
- if (trim) {
- valueBuffer.append(reader.read(lengthWithoutSpace));
- } else {
- valueBuffer.append(reader.read(length));
- }
+ valueBuffer.append(reader.read(length));
return valueBuffer.toByteString();
} else {
- if (trim) {
- if (lengthWithoutSpace > 0) {
- return ByteString.valueOf(reader.read(lengthWithoutSpace));
- }
- return ByteString.empty();
- }
if (length > 0) {
return ByteString.valueOf(reader.read(length));
}
@@ -543,28 +526,13 @@
}
}
length++;
- if (c != ' ') {
- lengthWithoutSpace = length;
- } else {
- lengthWithoutSpace++;
- }
}
reader.reset();
if (valueBuffer != null) {
- if (trim) {
- valueBuffer.append(reader.read(lengthWithoutSpace));
- } else {
- valueBuffer.append(reader.read(length));
- }
+ valueBuffer.append(reader.read(length));
return valueBuffer.toByteString();
} else {
- if (trim) {
- if (lengthWithoutSpace > 0) {
- return ByteString.valueOf(reader.read(lengthWithoutSpace));
- }
- return ByteString.empty();
- }
if (length > 0) {
return ByteString.valueOf(reader.read(length));
}
--
Gitblit v1.10.0