From 3c8bcc9cc000997c780761a0c5067076ab2b0b3e Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 03 Nov 2014 11:41:46 +0000
Subject: [PATCH] Last batch of fixes from AutoRefactor (or me) for a while. AutoRefactor successfully goes through the whole SDK now.
---
opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java | 8 ++--
opendj-config/src/test/java/org/forgerock/opendj/config/SizeUnitTest.java | 18 +++++----
opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java | 4 +-
opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java | 4 +-
opendj-core/src/main/java/org/forgerock/opendj/ldap/Base64.java | 2
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java | 28 ++++++++-----
opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java | 6 --
7 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
index d854328..e8efc58 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
@@ -66,7 +66,7 @@
/** {@inheritDoc} */
@Override
- final public void addValue(final String valueString) {
+ public final void addValue(final String valueString) {
if (valueString != null) {
clearValues();
super.addValue(valueString);
@@ -76,7 +76,7 @@
/** {@inheritDoc} */
@Override
- final public void setPresent(final boolean isPresent) {
+ public final void setPresent(final boolean isPresent) {
addValue(String.valueOf(isPresent));
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
index 7f8b574..cd54054 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
@@ -144,11 +144,7 @@
* limit is greater than the upper limit.
*/
public final void setUpperLimit(String upperLimit) {
- if (upperLimit == null) {
- setUpperLimit((Long) null);
- } else {
- setUpperLimit(SizeUnit.parseValue(upperLimit, SizeUnit.BYTES));
- }
+ setUpperLimit(upperLimit != null ? SizeUnit.parseValue(upperLimit, SizeUnit.BYTES) : null);
}
/**
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java b/opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java
index 32ae6b7..b8c3afc 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java
@@ -39,10 +39,10 @@
BYTES(1L, "b", "bytes"),
/** A gibi-byte unit. */
- GIBI_BYTES(1024 * 1024 * 1024, "gib", "gibibytes"),
+ GIBI_BYTES(1024L * 1024 * 1024, "gib", "gibibytes"),
/** A giga-byte unit. */
- GIGA_BYTES(1000 * 1000 * 1000, "gb", "gigabytes"),
+ GIGA_BYTES(1000L * 1000 * 1000, "gb", "gigabytes"),
/** A kibi-byte unit. */
KIBI_BYTES(1024L, "kib", "kibibytes"),
@@ -51,10 +51,10 @@
KILO_BYTES(1000L, "kb", "kilobytes"),
/** A mebi-byte unit. */
- MEBI_BYTES(1024 * 1024, "mib", "mebibytes"),
+ MEBI_BYTES(1024L * 1024, "mib", "mebibytes"),
/** A mega-byte unit. */
- MEGA_BYTES(1000 * 1000, "mb", "megabytes"),
+ MEGA_BYTES(1000L * 1000, "mb", "megabytes"),
/** A tebi-byte unit. */
TEBI_BYTES(1024L * 1024 * 1024 * 1024, "tib", "tebibytes"),
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/SizeUnitTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/SizeUnitTest.java
index 718a7cf..6cf5c19 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/SizeUnitTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/SizeUnitTest.java
@@ -45,7 +45,8 @@
{ "gb", SizeUnit.GIGA_BYTES },
{ "gib", SizeUnit.GIBI_BYTES },
{ "tb", SizeUnit.TERA_BYTES },
- { "tib", SizeUnit.TEBI_BYTES } };
+ { "tib", SizeUnit.TEBI_BYTES },
+ };
}
@Test(dataProvider = "stringToSizeLimitData")
@@ -80,7 +81,8 @@
{ "1000kb", 1000000L },
{ "1000 kilobytes", 1000000L },
{ "1000 KILOBYTES", 1000000L },
- { "1000 KB", 1000000L } };
+ { "1000 KB", 1000000L },
+ };
}
@Test(dataProvider = "parseValueData")
@@ -243,12 +245,12 @@
{ SizeUnit.BYTES, 1L },
{ SizeUnit.KILO_BYTES, 1000L },
{ SizeUnit.KIBI_BYTES, 1024L },
- { SizeUnit.MEGA_BYTES, (long) 1000 * 1000 },
- { SizeUnit.MEBI_BYTES, (long) 1024 * 1024 },
- { SizeUnit.GIGA_BYTES, (long) 1000 * 1000 * 1000 },
- { SizeUnit.GIBI_BYTES, (long) 1024 * 1024 * 1024 },
- { SizeUnit.TERA_BYTES, (long) 1000 * 1000 * 1000 * 1000 },
- { SizeUnit.TEBI_BYTES, (long) 1024 * 1024 * 1024 * 1024 }
+ { SizeUnit.MEGA_BYTES, 1000L * 1000 },
+ { SizeUnit.MEBI_BYTES, 1024L * 1024 },
+ { SizeUnit.GIGA_BYTES, 1000L * 1000 * 1000 },
+ { SizeUnit.GIBI_BYTES, 1024L * 1024 * 1024 },
+ { SizeUnit.TERA_BYTES, 1000L * 1000 * 1000 * 1000 },
+ { SizeUnit.TEBI_BYTES, 1024L * 1024 * 1024 * 1024 },
};
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java
index 48a8b8b..cce5b99 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java
@@ -184,7 +184,7 @@
return;
}
- if ((length % 2) != 0) {
+ if (length % 2 != 0) {
final LocalizableMessage message = ERR_HEX_DECODE_INVALID_LENGTH.get(hexBuffer);
throw DecodeException.error(message);
}
@@ -341,7 +341,7 @@
// This character is escaped.
if (isHexDigit(c)) {
// Unicode characters.
- if (!(reader.remaining() > 0)) {
+ if (reader.remaining() <= 0) {
final LocalizableMessage msg =
ERR_ATTR_SYNTAX_DN_ESCAPED_HEX_VALUE_INVALID
.get(reader.getString());
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/Base64.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/Base64.java
index 85ef1d1..9872d23 100755
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/Base64.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/Base64.java
@@ -69,7 +69,7 @@
// The encoded value must have length that is a multiple of four
// bytes.
final int length = base64.length();
- if ((length % 4) != 0) {
+ if (length % 4 != 0) {
final LocalizableMessage message = ERR_BASE64_DECODE_INVALID_LENGTH.get(base64);
throw new LocalizedIllegalArgumentException(message);
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
index a4d9a40..0fb3c6b 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
@@ -206,8 +206,10 @@
// only digits and periods, but not consecutive periods.
boolean lastWasPeriod = false;
- while (reader.remaining() > 0 && (c = reader.read()) != ' ' && c != ')'
- && !(c == '\'' && enclosingQuote)) {
+ while (reader.remaining() > 0
+ && (c = reader.read()) != ' '
+ && c != ')'
+ && (c != '\'' || !enclosingQuote)) {
if (c == '.') {
if (lastWasPeriod) {
throw DecodeException.error(
@@ -230,10 +232,11 @@
}
} else if (isAlpha(c)) {
// This must be an attribute description. In this case, we will
- // only accept alphabetic characters, numeric digits, and the
- // hyphen.
- while (reader.remaining() > 0 && (c = reader.read()) != ' ' && c != ')'
- && !(c == '\'' && enclosingQuote)) {
+ // only accept alphabetic characters, numeric digits, and the hyphen.
+ while (reader.remaining() > 0
+ && (c = reader.read()) != ' '
+ && c != ')'
+ && (c != '\'' || !enclosingQuote)) {
if (length == 0 && !isAlpha(c)) {
throw DecodeException.error(
ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID1.get(c, reader.pos() - 1));
@@ -303,7 +306,9 @@
}
if (isDigit(c)) {
boolean lastWasPeriod = false;
- while ((c = reader.read()) != ' ' && c != '{' && !(c == '\'' && enclosingQuote)) {
+ while ((c = reader.read()) != ' '
+ && c != '{'
+ && (c != '\'' || !enclosingQuote)) {
if (c == '.') {
if (lastWasPeriod) {
throw DecodeException.error(
@@ -336,10 +341,11 @@
}
} else if (isAlpha(c)) {
// This must be an attribute description. In this case, we will
- // only accept alphabetic characters, numeric digits, and the
- // hyphen.
- while ((c = reader.read()) != ' ' && c != ')' && c != '{'
- && !(c == '\'' && enclosingQuote)) {
+ // only accept alphabetic characters, numeric digits, and the hyphen.
+ while ((c = reader.read()) != ' '
+ && c != ')'
+ && c != '{'
+ && (c != '\'' || !enclosingQuote)) {
if (length == 0 && !isAlpha(c)) {
throw DecodeException.error(
ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID1.get(c, reader.pos() - 1));
--
Gitblit v1.10.0