From ba1a7045c092ad0f6ba7ac345c0014765e2be8df Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 30 Oct 2014 11:44:55 +0000
Subject: [PATCH] AutoRefactored code.
---
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java | 4
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java | 11 -
opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java | 15
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java | 44 ++--
opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java | 12
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java | 4
opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java | 29 +-
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java | 4
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java | 14
opendj-core/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java | 4
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java | 59 ++---
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java | 5
opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIF.java | 4
opendj-core/src/test/java/org/forgerock/opendj/io/ASN1WriterTestCase.java | 30 --
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java | 9
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java | 14
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java | 13
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java | 2
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java | 16 -
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java | 24 +-
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java | 8
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java | 28 +-
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java | 2
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java | 7
opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java | 8
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java | 20 +-
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java | 16 -
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java | 12 -
opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java | 59 +++---
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java | 4
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java | 18 -
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImpl.java | 21 +-
opendj-core/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java | 9
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java | 7
34 files changed, 224 insertions(+), 312 deletions(-)
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
index 785c1ec..8f6990e 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
@@ -591,11 +591,9 @@
if (!canWrite(file)) {
println(ERR_DSCFG_CANNOT_WRITE_EQUIVALENT_COMMAND_LINE_FILE.get(file));
return ReturnCode.ERROR_UNEXPECTED.get();
- } else {
- if (new File(file).isDirectory()) {
- println(ERR_DSCFG_EQUIVALENT_COMMAND_LINE_FILE_DIRECTORY.get(file));
- return ReturnCode.ERROR_UNEXPECTED.get();
- }
+ } else if (new File(file).isDirectory()) {
+ println(ERR_DSCFG_EQUIVALENT_COMMAND_LINE_FILE_DIRECTORY.get(file));
+ return ReturnCode.ERROR_UNEXPECTED.get();
}
}
// Creates the management context factory which is based on the connection
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java
index 0b7d3dd..8de069c 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java
@@ -214,7 +214,6 @@
// Reset the command builder
getCommandBuilder().clearArguments();
-
setCommandBuilderUseful(false);
// Update the command builder.
@@ -322,9 +321,8 @@
public LocalizableMessage visitAlias(AliasDefaultBehaviorProvider<T> d, Void p) {
if (app.isVerbose()) {
return d.getSynopsis();
- } else {
- return null;
}
+ return null;
}
public LocalizableMessage visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) {
@@ -358,34 +356,32 @@
} else {
builder.appendCell(content);
}
+ } else if (isRecordMode()) {
+ for (T value : values) {
+ builder.startRow();
+ builder.appendCell(pd.getName());
+ builder.appendCell(valuePrinter.print(pd, value));
+ }
} else {
- if (isRecordMode()) {
+ builder.startRow();
+ builder.appendCell(pd.getName());
+
+ if (app.isScriptFriendly()) {
for (T value : values) {
- builder.startRow();
- builder.appendCell(pd.getName());
builder.appendCell(valuePrinter.print(pd, value));
}
} else {
- builder.startRow();
- builder.appendCell(pd.getName());
-
- if (app.isScriptFriendly()) {
- for (T value : values) {
- builder.appendCell(valuePrinter.print(pd, value));
+ StringBuilder sb = new StringBuilder();
+ boolean isFirst = true;
+ for (T value : values) {
+ if (!isFirst) {
+ sb.append(", ");
}
- } else {
- StringBuilder sb = new StringBuilder();
- boolean isFirst = true;
- for (T value : values) {
- if (!isFirst) {
- sb.append(", ");
- }
- sb.append(valuePrinter.print(pd, value));
- isFirst = false;
- }
-
- builder.appendCell(sb.toString());
+ sb.append(valuePrinter.print(pd, value));
+ isFirst = false;
}
+
+ builder.appendCell(sb.toString());
}
}
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
index cb3d1f1..fccbc94 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
@@ -1124,7 +1124,7 @@
if (!oldValues.equals(currentValues)) {
result = MenuResult.success(true);
} else {
- result = MenuResult.<Boolean> cancel();
+ result = MenuResult.cancel();
}
LocalizableMessage option = getKeepDefaultValuesMenuOption(d, defaultValues, oldValues, currentValues);
@@ -1474,10 +1474,10 @@
// The second (and possibly third) option is to always change
// the property's value.
- if (currentValue == null || !currentValue) {
+ if (!Boolean.TRUE.equals(currentValue)) {
LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(true));
- if (defaultValue != null && defaultValue) {
+ if (Boolean.TRUE.equals(defaultValue)) {
option = INFO_EDITOR_OPTION_CHANGE_TO_DEFAULT_VALUE.get(svalue);
} else {
option = INFO_EDITOR_OPTION_CHANGE_TO_VALUE.get(svalue);
@@ -1486,10 +1486,10 @@
builder.addNumberedOption(option, MenuResult.success(true));
}
- if (currentValue == null || currentValue) {
+ if (!Boolean.FALSE.equals(currentValue)) {
LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(false));
- if (defaultValue != null && !defaultValue) {
+ if (Boolean.FALSE.equals(defaultValue)) {
option = INFO_EDITOR_OPTION_CHANGE_TO_DEFAULT_VALUE.get(svalue);
} else {
option = INFO_EDITOR_OPTION_CHANGE_TO_VALUE.get(svalue);
@@ -1977,18 +1977,12 @@
// Create the appropriate property action.
MenuCallback<Boolean> callback;
- if (pd.hasOption(PropertyOption.MULTI_VALUED)) {
- if (isReadOnly) {
- callback = new ReadOnlyPropertyViewer(mo, pd);
- } else {
- callback = new MultiValuedPropertyEditor(mo, pd);
- }
+ if (isReadOnly) {
+ callback = new ReadOnlyPropertyViewer(mo, pd);
+ } else if (pd.hasOption(PropertyOption.MULTI_VALUED)) {
+ callback = new MultiValuedPropertyEditor(mo, pd);
} else {
- if (isReadOnly) {
- callback = new ReadOnlyPropertyViewer(mo, pd);
- } else {
- callback = new SingleValuedPropertyEditor(mo, pd);
- }
+ callback = new SingleValuedPropertyEditor(mo, pd);
}
// Create the numeric option.
@@ -2027,7 +2021,7 @@
if (result.isSuccess()) {
if (result.getValue()) {
- return MenuResult.<Void> success();
+ return MenuResult.success();
}
} else if (result.isCancel()) {
return MenuResult.cancel();
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java
index 8774283..152d1a4 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java
@@ -988,14 +988,12 @@
int firstPos = asteriskPositions.removeFirst();
if (firstPos == 0) {
subInitial = null;
+ } else if (hasEscape) {
+ final ByteStringBuilder buffer = new ByteStringBuilder(firstPos);
+ escapeHexChars(buffer, attrType, valueBytes, 0, firstPos, equalPos);
+ subInitial = buffer.toByteString();
} else {
- if (hasEscape) {
- final ByteStringBuilder buffer = new ByteStringBuilder(firstPos);
- escapeHexChars(buffer, attrType, valueBytes, 0, firstPos, equalPos);
- subInitial = buffer.toByteString();
- } else {
- subInitial = ByteString.wrap(valueBytes, 0, firstPos);
- }
+ subInitial = ByteString.wrap(valueBytes, 0, firstPos);
}
// Next, process through the rest of the asterisks to get the subAny
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java
index a3422eb..cacd487 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java
@@ -151,7 +151,7 @@
this.isCollective = collective;
this.isNoUserModification = noUserModification;
this.attributeUsage = attributeUsage;
- this.isObjectClassType = oid.equals("2.5.4.0");
+ this.isObjectClassType = "2.5.4.0".equals(oid);
this.isPlaceHolder = false;
this.normalizedName = StaticUtils.toLowerCase(getNameOrOID());
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java
index 01db0e3..bc94767 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java
@@ -111,36 +111,35 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the attribute type. It
// is an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the attribute type should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("sup")) {
+ // parsing for this token.
+ } else if ("sup".equalsIgnoreCase(tokenName)) {
// This specifies the name or OID of the superior attribute
// type from which this attribute type should inherit its
// properties.
SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("equality")) {
+ } else if ("equality".equalsIgnoreCase(tokenName)) {
// This specifies the name or OID of the equality matching
// rule to use for this attribute type.
SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("ordering")) {
+ } else if ("ordering".equalsIgnoreCase(tokenName)) {
// This specifies the name or OID of the ordering matching
// rule to use for this attribute type.
SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("substr")) {
+ } else if ("substr".equalsIgnoreCase(tokenName)) {
// This specifies the name or OID of the substring matching
// rule to use for this attribute type.
SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("syntax")) {
+ } else if ("syntax".equalsIgnoreCase(tokenName)) {
// This specifies the numeric OID of the syntax for this
// matching rule. It may optionally be immediately followed
// by
@@ -152,30 +151,25 @@
// not impose any practical limit on the length of attribute
// values.
SchemaUtils.readOIDLen(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("single-definition")) {
- // This indicates that attributes of this type are allowed
- // to
+ } else if ("single-definition".equalsIgnoreCase(tokenName)) {
+ // This indicates that attributes of this type are allowed to
// have at most one definition. We do not need any more
// parsing for this token.
- } else if (tokenName.equalsIgnoreCase("single-value")) {
+ } else if ("single-value".equalsIgnoreCase(tokenName)) {
// This indicates that attributes of this type are allowed
- // to
- // have at most one value. We do not need any more parsing
- // for
- // this token.
- } else if (tokenName.equalsIgnoreCase("collective")) {
- // This indicates that attributes of this type are
- // collective
- // (i.e., have their values generated dynamically in some
- // way). We do not need any more parsing for this token.
- } else if (tokenName.equalsIgnoreCase("no-user-modification")) {
+ // to have at most one value.
+ // We do not need any more parsing for this token.
+ } else if ("collective".equalsIgnoreCase(tokenName)) {
+ // This indicates that attributes of this type are collective
+ // (i.e., have their values generated dynamically in some way).
+ // We do not need any more parsing for this token.
+ } else if ("no-user-modification".equalsIgnoreCase(tokenName)) {
// This indicates that the values of attributes of this type
// are not to be modified by end users. We do not need any
// more parsing for this token.
- } else if (tokenName.equalsIgnoreCase("usage")) {
+ } else if ("usage".equalsIgnoreCase(tokenName)) {
// This specifies the usage string for this attribute type.
- // It
- // should be followed by one of the strings
+ // It should be followed by one of the strings
// "userApplications", "directoryOperation",
// "distributedOperation", or "dSAOperation".
int length = 0;
@@ -189,10 +183,10 @@
reader.reset();
final String usageStr = reader.read(length);
- if (!usageStr.equalsIgnoreCase("userapplications")
- && !usageStr.equalsIgnoreCase("directoryoperation")
- && !usageStr.equalsIgnoreCase("distributedoperation")
- && !usageStr.equalsIgnoreCase("dsaoperation")) {
+ if (!"userapplications".equalsIgnoreCase(usageStr)
+ && !"directoryoperation".equalsIgnoreCase(usageStr)
+ && !"distributedoperation".equalsIgnoreCase(usageStr)
+ && !"dsaoperation".equalsIgnoreCase(usageStr)) {
final LocalizableMessage message =
WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_ATTRIBUTE_USAGE1.get(definition,
usageStr);
@@ -203,8 +197,7 @@
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImpl.java
index a1f8724..480e42c 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImpl.java
@@ -138,10 +138,9 @@
try {
// the first namedValue is serialNumber
identifier = parser.nextNamedValueIdentifier();
- if (!identifier.equals(GSER_ID_SERIALNUMBER)) {
- LocalizableMessage message =
- ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_SERIALNUMBER);
- throw DecodeException.error(message);
+ if (!GSER_ID_SERIALNUMBER.equals(identifier)) {
+ throw DecodeException.error(
+ ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_SERIALNUMBER));
}
// The value for the serialNumber
@@ -152,18 +151,16 @@
// the next namedValue is issuer
identifier = parser.nextNamedValueIdentifier();
- if (!identifier.equals(GSER_ID_ISSUER)) {
- LocalizableMessage message =
- ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_ISSUER);
- throw DecodeException.error(message);
+ if (!GSER_ID_ISSUER.equals(identifier)) {
+ throw DecodeException.error(
+ ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_ISSUER));
}
// expecting "rdnSequence:"
identifier = parser.nextChoiceValueIdentifier();
- if (!identifier.equals(GSER_ID_RDNSEQUENCE)) {
- LocalizableMessage message =
- ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_RDNSEQUENCE);
- throw DecodeException.error(message);
+ if (!GSER_ID_RDNSEQUENCE.equals(identifier)) {
+ throw DecodeException.error(
+ ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_RDNSEQUENCE));
}
// now the issuer dn
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java
index e0da14d..e57d3ff 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java
@@ -112,31 +112,29 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the attribute type. It
// is an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the attribute type should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("aux")) {
+ // parsing for this token.
+ } else if ("aux".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("must")) {
+ } else if ("must".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("may")) {
+ } else if ("may".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("not")) {
+ } else if ("not".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java
index 3522df3..a01170c 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java
@@ -113,27 +113,25 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the attribute type. It
// is an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the attribute type should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("form")) {
+ // parsing for this token.
+ } else if ("form".equalsIgnoreCase(tokenName)) {
nameForm = SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("sup")) {
+ } else if ("sup".equalsIgnoreCase(tokenName)) {
SchemaUtils.readRuleIDs(reader);
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java
index 286326c..83d3e5d 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java
@@ -115,15 +115,14 @@
}
final String scopeStr = valueStr.substring(lastSharpPos + 1).trim();
- if (!(scopeStr.equals("baseobject") || scopeStr.equals("onelevel")
- || scopeStr.equals("wholesubtree") || scopeStr.equals("subordinatesubtree"))) {
+ if (!"baseobject".equals(scopeStr) && !"onelevel".equals(scopeStr)
+ && !"wholesubtree".equals(scopeStr) && !"subordinatesubtree".equals(scopeStr)) {
if (scopeStr.length() == 0) {
invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SCOPE.get(valueStr));
} else {
invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_INVALID_SCOPE.get(valueStr,
scopeStr));
}
-
return false;
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java
index 1ad4ab3..bf40840 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java
@@ -140,11 +140,8 @@
if (c == '$') {
pos++;
break;
- } else {
- if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString,
- String.valueOf(c), pos));
- }
+ } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
+ invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, c, pos));
}
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java
index 7467dd4..0155d03 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java
@@ -160,7 +160,7 @@
// See if the criteria is either "true" or "false". If so, then it
// is valid.
- if (criteria.equals("true") || criteria.equals("false")) {
+ if ("true".equals(criteria) || "false".equals(criteria)) {
return true;
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java
index dcb52c6..7d9a1d4 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java
@@ -120,15 +120,14 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the syntax. It is an
// arbitrary string of characters enclosed in single quotes.
SchemaUtils.readQuotedString(reader);
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
if (extraProperties.isEmpty()) {
@@ -145,7 +144,7 @@
}
for (final Map.Entry<String, List<String>> property : extraProperties.entrySet()) {
- if (property.getKey().equalsIgnoreCase("x-pattern")) {
+ if ("x-pattern".equalsIgnoreCase(property.getKey())) {
final Iterator<String> values = property.getValue().iterator();
if (values.hasNext()) {
final String pattern = values.next();
@@ -161,7 +160,7 @@
}
break;
}
- } else if (property.getKey().equalsIgnoreCase("x-enum")) {
+ } else if ("x-enum".equalsIgnoreCase(property.getKey())) {
final List<String> values = property.getValue();
for (int i = 0; i < values.size() - 1; i++) {
final String entry = values.get(i);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java
index 0a76d91..d3088bc 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java
@@ -127,26 +127,24 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the matching rule. It
// is
// an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the matching rule should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("syntax")) {
+ // parsing for this token.
+ } else if ("syntax".equalsIgnoreCase(tokenName)) {
syntax = SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java
index 58d3173..a7a004d 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java
@@ -131,26 +131,24 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the attribute type. It
// is an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the attribute type should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("applies")) {
+ // parsing for this token.
+ } else if ("applies".equalsIgnoreCase(tokenName)) {
attributes =
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java
index 668efe3..6d96cd2 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java
@@ -119,31 +119,29 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the attribute type. It
// is an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the attribute type should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("oc")) {
+ // parsing for this token.
+ } else if ("oc".equalsIgnoreCase(tokenName)) {
structuralClass =
SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("must")) {
+ } else if ("must".equalsIgnoreCase(tokenName)) {
requiredAttributes =
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("may")) {
+ } else if ("may".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java
index f151701..4be4182 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java
@@ -114,40 +114,38 @@
if (tokenName == null) {
// No more tokens.
break;
- } else if (tokenName.equalsIgnoreCase("name")) {
+ } else if ("name".equalsIgnoreCase(tokenName)) {
SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("desc")) {
+ } else if ("desc".equalsIgnoreCase(tokenName)) {
// This specifies the description for the attribute type. It
// is an arbitrary string of characters enclosed in single
// quotes.
SchemaUtils.readQuotedString(reader);
- } else if (tokenName.equalsIgnoreCase("obsolete")) {
+ } else if ("obsolete".equalsIgnoreCase(tokenName)) {
// This indicates whether the attribute type should be
// considered obsolete. We do not need to do any more
- // parsing
- // for this token.
- } else if (tokenName.equalsIgnoreCase("sup")) {
+ // parsing for this token.
+ } else if ("sup".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("abstract")) {
+ } else if ("abstract".equalsIgnoreCase(tokenName)) {
// This indicates that entries must not include this
// objectclass unless they also include a non-abstract
// objectclass that inherits from this class. We do not need
// any more parsing for this token.
- } else if (tokenName.equalsIgnoreCase("structural")) {
+ } else if ("structural".equalsIgnoreCase(tokenName)) {
// This indicates that this is a structural objectclass.
// We do not need any more parsing for this token.
- } else if (tokenName.equalsIgnoreCase("auxiliary")) {
+ } else if ("auxiliary".equalsIgnoreCase(tokenName)) {
// This indicates that this is an auxiliary objectclass.
// We do not need any more parsing for this token.
- } else if (tokenName.equalsIgnoreCase("must")) {
+ } else if ("must".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
- } else if (tokenName.equalsIgnoreCase("may")) {
+ } else if ("may".equalsIgnoreCase(tokenName)) {
SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions());
} else if (tokenName.matches("^X-[A-Za-z_-]+$")) {
// This must be a non-standard property and it must be
// followed by either a single definition in single quotes
- // or
- // an open parenthesis followed by one or more values in
+ // or an open parenthesis followed by one or more values in
// single quotes separated by spaces followed by a close
// parenthesis.
SchemaUtils.readExtensions(reader);
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java
index fe1520e..6e1912c 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java
@@ -364,7 +364,7 @@
// See if we need to override the implementation of the syntax
for (final Map.Entry<String, List<String>> property : getExtraProperties().entrySet()) {
// Enums are handled in the schema builder.
- if (property.getKey().equalsIgnoreCase("x-subst")) {
+ if ("x-subst".equalsIgnoreCase(property.getKey())) {
/**
* One unimplemented syntax can be substituted by another
* defined syntax. A substitution syntax is an
@@ -386,7 +386,7 @@
}
impl = subSyntax.impl;
}
- } else if (property.getKey().equalsIgnoreCase("x-pattern")) {
+ } else if ("x-pattern".equalsIgnoreCase(property.getKey())) {
final Iterator<String> values = property.getValue().iterator();
if (values.hasNext()) {
final String value = values.next();
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java
index a8e43dc..2fb9765 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java
@@ -135,11 +135,8 @@
if (c == '$') {
pos++;
break;
- } else {
- if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString,
- String.valueOf(c), pos));
- }
+ } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
+ invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, c, pos));
}
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java
index ee8a32e..b3e435e 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java
@@ -109,11 +109,8 @@
if (c == '$') {
pos++;
break;
- } else {
- if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, String
- .valueOf(c), pos));
- }
+ } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
+ invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos));
}
}
@@ -136,12 +133,9 @@
if (c == '$') {
pos++;
break;
- } else {
- if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, String
- .valueOf(c), pos));
- return false;
- }
+ } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) {
+ invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos));
+ return false;
}
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java b/opendj-core/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java
index 399d557..df261c4 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java
@@ -572,7 +572,7 @@
}
String attrName = toLowerCase(ldifLine.substring(0, colonPos));
- if (attrName.equals("version")) {
+ if ("version".equals(attrName)) {
// This is the version line, try the next line if there is one.
if (!record.iterator.hasNext()) {
return null;
@@ -587,7 +587,7 @@
attrName = toLowerCase(ldifLine.substring(0, colonPos));
}
- if (!attrName.equals("dn")) {
+ if (!"dn".equals(attrName)) {
throw DecodeException.error(ERR_LDIF_NO_DN.get(record.lineNumber, ldifLine));
}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIF.java b/opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIF.java
index 989eb25..274ea6b 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIF.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIF.java
@@ -749,7 +749,7 @@
} else {
final Entry filteredEntry = new LinkedHashMapEntry(entry.getName());
for (final String atd : search.getAttributes()) {
- if (atd.equals("*")) {
+ if ("*".equals(atd)) {
for (final Attribute attribute : entry.getAllAttributes()) {
if (attribute.getAttributeDescription().getAttributeType()
.getUsage() == AttributeUsage.USER_APPLICATIONS) {
@@ -762,7 +762,7 @@
}
}
}
- } else if (atd.equals("+")) {
+ } else if ("+".equals(atd)) {
for (final Attribute attribute : entry.getAllAttributes()) {
if (attribute.getAttributeDescription().getAttributeType()
.getUsage() != AttributeUsage.USER_APPLICATIONS) {
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java b/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
index 932a858..6c68983 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
@@ -421,15 +421,14 @@
// "sequential" or "random". If there isn't one, then we should
// assume "random".
if (arguments.length == 2) {
- if (arguments[1].equalsIgnoreCase("sequential")) {
+ if ("sequential".equalsIgnoreCase(arguments[1])) {
isSequential = true;
nextIndex = 0;
- } else if (arguments[1].equalsIgnoreCase("random")) {
+ } else if ("random".equalsIgnoreCase(arguments[1])) {
isSequential = false;
} else {
- LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1],
- getName(), lineNumber);
- throw DecodeException.fatalError(message);
+ throw DecodeException.fatalError(
+ ERR_ENTRY_GENERATOR_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1], getName(), lineNumber));
}
} else {
isSequential = false;
@@ -1013,10 +1012,10 @@
int numArgs = arguments.length;
String randomTypeString = arguments[0].toLowerCase();
- if (randomTypeString.equals("alpha")) {
+ if ("alpha".equals(randomTypeString)) {
characterSet = ALPHA_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
- } else if (randomTypeString.equals("numeric")) {
+ } else if ("numeric".equals(randomTypeString)) {
if (numArgs == 2) {
randomType = RandomType.CHARS_FIXED;
characterSet = NUMERIC_CHARS;
@@ -1079,10 +1078,10 @@
lineNumber, 2, 4, numArgs);
throw DecodeException.fatalError(message);
}
- } else if (randomTypeString.equals("alphanumeric")) {
+ } else if ("alphanumeric".equals(randomTypeString)) {
characterSet = ALPHANUMERIC_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
- } else if (randomTypeString.equals("chars")) {
+ } else if ("chars".equals(randomTypeString)) {
if (numArgs < 3 || numArgs > 4) {
LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(),
lineNumber, 3, 4, numArgs);
@@ -1091,13 +1090,13 @@
characterSet = arguments[1].toCharArray();
decodeLength(arguments, 2, lineNumber, warnings);
- } else if (randomTypeString.equals("hex")) {
+ } else if ("hex".equals(randomTypeString)) {
characterSet = HEX_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
- } else if (randomTypeString.equals("base64")) {
+ } else if ("base64".equals(randomTypeString)) {
characterSet = BASE64_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
- } else if (randomTypeString.equals("month")) {
+ } else if ("month".equals(randomTypeString)) {
randomType = RandomType.MONTH;
if (numArgs == 1) {
@@ -1120,7 +1119,7 @@
lineNumber, 1, 2, numArgs);
throw DecodeException.fatalError(message);
}
- } else if (randomTypeString.equals("telephone")) {
+ } else if ("telephone".equals(randomTypeString)) {
randomType = RandomType.TELEPHONE;
} else {
LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNKNOWN_RANDOM_TYPE.get(lineNumber,
@@ -1363,9 +1362,9 @@
}
private void initializeReset(String resetValue, int lineNumber) throws DecodeException {
- if (resetValue.equalsIgnoreCase("true")) {
+ if ("true".equalsIgnoreCase(resetValue)) {
resetOnNewParents = true;
- } else if (resetValue.equalsIgnoreCase("false")) {
+ } else if ("false".equalsIgnoreCase(resetValue)) {
resetOnNewParents = false;
} else {
throw DecodeException.fatalError(ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_BOOLEAN.get(
diff --git a/opendj-core/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java b/opendj-core/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java
index 9716a48..6668a7d 100644
--- a/opendj-core/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java
+++ b/opendj-core/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java
@@ -23,11 +23,8 @@
*
* Copyright 2010 Sun Microsystems, Inc.
*/
-
package com.forgerock.opendj.ldap.controls;
-import static org.testng.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
@@ -43,6 +40,8 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
/**
* Tests the account usability request control.
*/
@@ -64,8 +63,6 @@
assertTrue(entries.size() > 0);
final SearchResultEntry entry = entries.get(0);
final Control ctrl = entry.getControls().get(0);
- if (!ctrl.getOID().equals("1.3.6.1.4.1.42.2.27.9.5.8")) {
- throw new Exception("expected control response 1.3.6.1.4.1.42.2.27.9.5.8");
- }
+ assertEquals(ctrl.getOID(), "1.3.6.1.4.1.42.2.27.9.5.8", "expected control response 1.3.6.1.4.1.42.2.27.9.5.8");
}
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/io/ASN1WriterTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/io/ASN1WriterTestCase.java
index 6993339..00d9687 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/io/ASN1WriterTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/io/ASN1WriterTestCase.java
@@ -26,8 +26,6 @@
*/
package org.forgerock.opendj.io;
-import static org.testng.Assert.*;
-
import java.io.IOException;
import org.forgerock.opendj.ldap.ByteString;
@@ -39,6 +37,8 @@
import com.forgerock.opendj.util.StaticUtils;
+import static org.testng.Assert.*;
+
/**
* An abstract base class for all ASN1Writer test cases.
*/
@@ -339,18 +339,11 @@
public void testEncodeDecodeOctetString(final String s) throws Exception {
getWriter().writeOctetString(s);
+ final String expected = s != null ? s : "";
final ASN1Reader r = getReader(getEncodedBytes());
- if (s == null) {
- assertEquals(r.peekLength(), 0);
- } else {
- assertEquals(r.peekLength(), StaticUtils.getBytes(s).length);
- }
+ assertEquals(r.peekLength(), StaticUtils.getBytes(expected).length);
assertEquals(r.peekType(), ASN1.UNIVERSAL_OCTET_STRING_TYPE);
- if (s == null) {
- assertTrue(r.readOctetStringAsString().equals(""));
- } else {
- assertTrue(s.equals(r.readOctetStringAsString()));
- }
+ assertEquals(r.readOctetStringAsString(), expected);
}
/**
@@ -410,18 +403,11 @@
for (final byte type : testTypes) {
getWriter().writeOctetString(type, s);
+ final String expected = s != null ? s : "";
final ASN1Reader r = getReader(getEncodedBytes());
- if (s == null) {
- assertEquals(r.peekLength(), 0);
- } else {
- assertEquals(r.peekLength(), StaticUtils.getBytes(s).length);
- }
+ assertEquals(r.peekLength(), StaticUtils.getBytes(expected).length);
assertEquals(r.peekType(), type);
- if (s == null) {
- assertTrue(r.readOctetStringAsString().equals(""));
- } else {
- assertTrue(s.equals(r.readOctetStringAsString()));
- }
+ assertEquals(r.readOctetStringAsString(), expected);
}
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java
index 46053c4..a52dfdb 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java
@@ -267,9 +267,7 @@
.setServerSASLCredentials(ByteString.wrap(challenge)));
String qop = (String) saslServer.getNegotiatedProperty(Sasl.QOP);
- if (qop != null
- && (qop.equalsIgnoreCase("auth-int") || qop
- .equalsIgnoreCase("auth-conf"))) {
+ if ("auth-int".equalsIgnoreCase(qop) || "auth-conf".equalsIgnoreCase(qop)) {
ConnectionSecurityLayer csl = new ConnectionSecurityLayer() {
@Override
public void dispose() {
@@ -427,9 +425,7 @@
final IntermediateResponseHandler intermediateResponseHandler,
final ResultHandler<R> resultHandler) throws UnsupportedOperationException {
if (request.getOID().equals(StartTLSExtendedRequest.OID)) {
- final R result =
- request.getResultDecoder().newExtendedErrorResult(ResultCode.SUCCESS, "",
- "");
+ final R result = request.getResultDecoder().newExtendedErrorResult(ResultCode.SUCCESS, "", "");
resultHandler.handleResult(result);
clientContext.enableTLS(sslContext, null, sslContext.getSocketFactory()
.getSupportedCipherSuites(), false, false);
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java
index a833b41..17cf434 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java
@@ -954,15 +954,14 @@
assertThat(((ModifyRequest) cr).getModifications().size()).isEqualTo(3);
for (Modification mod : ((ModifyRequest) cr).getModifications()) {
+ final String attrDescription = mod.getAttribute().getAttributeDescription().toString();
+ final String firstValueAsString = mod.getAttribute().firstValueAsString();
if (mod.getModificationType() == ModificationType.ADD) {
- assertThat(mod.getAttribute().getAttributeDescription().toString().equals("description")
- || mod.getAttribute().getAttributeDescription().toString().equals("userPassword"));
- assertThat(mod.getAttribute().firstValueAsString().equals("A new description.")
- || mod.getAttribute().firstValueAsString().equals("secret12"));
- }
- if (mod.getModificationType() == ModificationType.DELETE) {
- assertThat(mod.getAttribute().getAttributeDescription().toString()).isEqualTo("userPassword");
- assertThat(mod.getAttribute().firstValueAsString()).isEqualTo("changeme");
+ assertThat(attrDescription).isIn("description", "userPassword");
+ assertThat(firstValueAsString).isIn("A new description.", "secret12");
+ } else if (mod.getModificationType() == ModificationType.DELETE) {
+ assertThat(attrDescription).isEqualTo("userPassword");
+ assertThat(firstValueAsString).isEqualTo("changeme");
}
}
reader.close();
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java
index 267bd1d..bf98a32 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java
@@ -238,7 +238,7 @@
if (ldapConnection != null) {
if (messageID == 0) {
// Unsolicited notification received.
- if (result.getOID() != null && result.getOID().equals(LDAP.OID_NOTICE_OF_DISCONNECTION)) {
+ if (LDAP.OID_NOTICE_OF_DISCONNECTION.equals(result.getOID())) {
// Treat this as a connection error.
final Result errorResult = newResult(result.getResultCode()).setDiagnosticMessage(
result.getDiagnosticMessage());
@@ -369,36 +369,35 @@
final ExtendedResult result) throws DecodeException {
final R decodedResponse = promise.decodeResult(result, conn.getLDAPOptions().getDecodeOptions());
- if (promise.getRequest() instanceof StartTLSExtendedRequest) {
- if (result.getResultCode() == ResultCode.SUCCESS) {
- try {
- final StartTLSExtendedRequest request = (StartTLSExtendedRequest) promise.getRequest();
- conn.startTLS(request.getSSLContext(), request.getEnabledProtocols(),
- request.getEnabledCipherSuites(),
- new EmptyCompletionHandler<SSLEngine>() {
- @Override
- public void completed(final SSLEngine result) {
- conn.setBindOrStartTLSInProgress(false);
- promise.setResultOrError(decodedResponse);
- }
+ if (result.getResultCode() == ResultCode.SUCCESS
+ && promise.getRequest() instanceof StartTLSExtendedRequest) {
+ try {
+ final StartTLSExtendedRequest request = (StartTLSExtendedRequest) promise.getRequest();
+ conn.startTLS(request.getSSLContext(), request.getEnabledProtocols(),
+ request.getEnabledCipherSuites(),
+ new EmptyCompletionHandler<SSLEngine>() {
+ @Override
+ public void completed(final SSLEngine result) {
+ conn.setBindOrStartTLSInProgress(false);
+ promise.setResultOrError(decodedResponse);
+ }
- @Override
- public void failed(final Throwable throwable) {
- final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR)
- .setCause(throwable).setDiagnosticMessage("SSL handshake failed");
- conn.setBindOrStartTLSInProgress(false);
- conn.close(null, false, errorResult);
- promise.adaptErrorResult(errorResult);
- }
- });
- return;
- } catch (final IOException e) {
- final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR).setCause(e)
- .setDiagnosticMessage(e.getMessage());
- promise.adaptErrorResult(errorResult);
- conn.close(null, false, errorResult);
- return;
- }
+ @Override
+ public void failed(final Throwable throwable) {
+ final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR)
+ .setCause(throwable).setDiagnosticMessage("SSL handshake failed");
+ conn.setBindOrStartTLSInProgress(false);
+ conn.close(null, false, errorResult);
+ promise.adaptErrorResult(errorResult);
+ }
+ });
+ return;
+ } catch (final IOException e) {
+ final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR).setCause(e)
+ .setDiagnosticMessage(e.getMessage());
+ promise.adaptErrorResult(errorResult);
+ conn.close(null, false, errorResult);
+ return;
}
}
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
index de3a81d..a77ae81 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
@@ -70,9 +70,9 @@
connection.bind("", "".toCharArray()); // Anonymous bind
final String attributeList;
- if (infoType.toLowerCase().equals("controls")) {
+ if ("controls".equals(infoType.toLowerCase())) {
attributeList = "supportedControl";
- } else if (infoType.toLowerCase().equals("extops")) {
+ } else if ("extops".equals(infoType.toLowerCase())) {
attributeList = "supportedExtension";
} else {
attributeList = "+"; // All operational attributes
@@ -124,10 +124,11 @@
host = args[0];
port = Integer.parseInt(args[1]);
- infoType = args[2]; // all, controls, or extops
- if (!(infoType.toLowerCase().equals("all")
- || infoType.toLowerCase().equals("controls")
- || infoType.toLowerCase().equals("extops"))) {
+ infoType = args[2];
+ final String infoTypeLc = infoType.toLowerCase();
+ if (!("all".equals(infoTypeLc)
+ || "controls".equals(infoTypeLc)
+ || "extops".equals(infoTypeLc))) {
giveUp();
}
}
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
index 8430b70..6e7a79d 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
@@ -93,7 +93,7 @@
Requests.newModifyRequest(DN.valueOf(targetDN));
String passwordAttribute = "unicodePwd";
- if (mode.equalsIgnoreCase("admin")) {
+ if ("admin".equalsIgnoreCase(mode)) {
// Request modify, replacing the password with the new.
request.addModification(
@@ -101,7 +101,7 @@
passwordAttribute,
encodePassword(newPassword)
);
- } else if (mode.equalsIgnoreCase("self")) {
+ } else if ("self".equalsIgnoreCase(mode)) {
// Request modify, deleting the old password, adding the new.
// The default password policy for Active Directory domain
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
index dd964d1..9a70944 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
@@ -80,16 +80,8 @@
attributes = new String[0];
}
- SearchScope scope;
- if (scopeString.equalsIgnoreCase("base")) {
- scope = SearchScope.BASE_OBJECT;
- } else if (scopeString.equalsIgnoreCase("one")) {
- scope = SearchScope.SINGLE_LEVEL;
- } else if (scopeString.equalsIgnoreCase("sub")) {
- scope = SearchScope.WHOLE_SUBTREE;
- } else if (scopeString.equalsIgnoreCase("subordinates")) {
- scope = SearchScope.SUBORDINATES;
- } else {
+ final SearchScope scope = SearchScope.valueOf(scopeString);
+ if (scope == null) {
System.err.println("Unknown scope: " + scopeString);
System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
return;
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java
index f40d8d8..7ca99e4 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java
@@ -166,15 +166,8 @@
attributes = new String[0];
}
- if (scopeString.equalsIgnoreCase("base")) {
- scope = SearchScope.BASE_OBJECT;
- } else if (scopeString.equalsIgnoreCase("one")) {
- scope = SearchScope.SINGLE_LEVEL;
- } else if (scopeString.equalsIgnoreCase("sub")) {
- scope = SearchScope.WHOLE_SUBTREE;
- } else if (scopeString.equalsIgnoreCase("subordinates")) {
- scope = SearchScope.SUBORDINATES;
- } else {
+ final SearchScope scope = SearchScope.valueOf(scopeString);
+ if (scope == null) {
System.err.println("Unknown scope: " + scopeString);
System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
return;
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
index 6458f61..60d9456 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
@@ -282,10 +282,10 @@
bindPassword = args[3];
if (args.length == 5) {
- if (args[4].toLowerCase().equals("use-starttls")) {
+ if ("use-starttls".equals(args[4].toLowerCase())) {
useStartTLS = true;
useSSL = false;
- } else if (args[4].toLowerCase().equals("use-ssl")) {
+ } else if ("use-ssl".equals(args[4].toLowerCase())) {
useStartTLS = false;
useSSL = true;
} else {
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java
index 04ab6fb..fb3fb7a 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java
@@ -163,8 +163,8 @@
* @param operation Operation specified as an argument (add or del).
*/
private static ModificationType getModificationType(String operation) {
- final boolean isAdd = operation.equalsIgnoreCase("add");
- if (!(isAdd || operation.equalsIgnoreCase("del"))) {
+ final boolean isAdd = "add".equalsIgnoreCase(operation);
+ if (!(isAdd || "del".equalsIgnoreCase(operation))) {
printUsage();
}
return isAdd ? ModificationType.ADD : ModificationType.DELETE;
--
Gitblit v1.10.0