From 917eb33ca3ffb73a34c0f733227d8f2215f9d978 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 25 Feb 2015 15:00:30 +0000
Subject: [PATCH] AutoRefactor: use String.contains()

---
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserDN.java                    |    4 ++--
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BasicMonitoringAttributes.java |    4 ++--
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java         |    2 +-
 opendj-server-legacy/src/test/java/org/opends/server/replication/SchemaReplicationTest.java                  |    2 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java                      |    2 +-
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java           |   30 +++++++-----------------------
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Target.java                    |    4 ++--
 7 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BasicMonitoringAttributes.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BasicMonitoringAttributes.java
index a871af6..9d7047f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BasicMonitoringAttributes.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BasicMonitoringAttributes.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
+ *      Portions Copyright 2014-2015 ForgeRock AS
  */
 package org.opends.guitools.controlpanel.datamodel;
 
@@ -382,7 +382,7 @@
     this == MAX_MEMORY ||
     this == USED_MEMORY;
 
-    isTime = attributeName.indexOf("time") != -1;
+    isTime = attributeName.contains("time");
 
     isNumeric =
     !isGMTDate() &&
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index d0e0fa4..0e93661 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -486,7 +486,7 @@
           {
             Object v = values.get(0);
             if (v instanceof String
-                && ((String) v).indexOf("\n") != -1)
+                && ((String) v).contains("\n"))
             {
               gbc.anchor = GridBagConstraints.NORTHWEST;
             }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index ac340eb..bd9fd06 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -2056,7 +2056,7 @@
     final String fileName = getSchemaFile(fileElement);
     if (fileName != null)
     {
-      return contains(standardSchemaFileNames, fileName) || fileName.toLowerCase().indexOf("-rfc") != -1;
+      return contains(standardSchemaFileNames, fileName) || fileName.toLowerCase().contains("-rfc");
     }
     else if (fileElement instanceof CommonSchemaElements)
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java
index 07c065f..ab5070e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java
@@ -182,40 +182,27 @@
          * Check that there are not too many filter lists. There can only
          * be either one or two.
          */
-        String[] filterLists=
-                subExpression.split(secondOp, -1);
+        String[] filterLists = subExpression.split(secondOp, -1);
         if(filterLists.length > 2) {
-          LocalizableMessage message =
-              WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_MAX_FILTER_LISTS.
-                get(expression);
-          throw new AciException(message);
+          throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_MAX_FILTER_LISTS.get(expression));
         } else if (filterLists.length == 1) {
           //Check if the there is something like ") , deel=". A bad token
           //that the regular expression didn't pick up.
           String [] filterList2=subExpression.split(secondOpSeparator);
           if(filterList2.length == 2) {
-              LocalizableMessage message =
-                  WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.
-                    get(expression);
-              throw new AciException(message);
+              throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.get(expression));
           }
           String rg = getReverseOp(firstOp) + "=";
           //This check catches the case where there might not be a
           //',' character between the first filter list and the second.
-          if(subExpression.indexOf(rg) != -1) {
-            LocalizableMessage message =
-                WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.
-                  get(expression);
-            throw new AciException(message);
+          if (subExpression.contains(rg)) {
+            throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.get(expression));
           }
         }
         filterLists[0]=filterLists[0].trim();
         //First filter list must end in an ')' character.
         if(!filterLists[0].endsWith(")")) {
-            LocalizableMessage message =
-                WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.
-                  get(expression);
-            throw new AciException(message);
+            throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.get(expression));
         }
         TargAttrFilterList firstFilterList =
                 TargAttrFilterList.decode(getMask(firstOp), filterLists[0]);
@@ -225,10 +212,7 @@
             String filterList=filterLists[1].trim();
             //Second filter list must start with a '='.
             if(!filterList.startsWith("=")) {
-              LocalizableMessage message =
-                  WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.
-                    get(expression);
-              throw new AciException(message);
+              throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGATTRFILTERS_EXPRESSION.get(expression));
             }
             String temp2= filterList.substring(1,filterList.length());
             //Assume the first op is an "add" so this has to be a "del".
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Target.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Target.java
index 9b6dbe4..f1bd19c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Target.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Target.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
+ *      Portions Copyright 2014-2015 ForgeRock AS
  */
 package org.opends.server.authorization.dseecompat;
 
@@ -86,7 +86,7 @@
               throw new AciException(WARN_ACI_SYNTAX_INVALID_TARGETKEYWORD_EXPRESSION.get(target));
           }
           LDAPURL targetURL =  LDAPURL.decode(target, false);
-          if(targetURL.getRawBaseDN().indexOf("*") != -1) {
+          if (targetURL.getRawBaseDN().contains("*")) {
               this.isPattern=true;
               patternDN = PatternDN.decodeSuffix(targetURL.getRawBaseDN());
           } else {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserDN.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserDN.java
index 7bc68fa..213d5df 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserDN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserDN.java
@@ -147,7 +147,7 @@
         EnumUserDNType type;
         String str=bldr.toString();
 
-        if(str.indexOf("?") != -1) {
+        if (str.contains("?")) {
             type = EnumUserDNType.URL;
         } else  if(str.equalsIgnoreCase("ldap:///self")) {
             type = EnumUserDNType.SELF;
@@ -161,7 +161,7 @@
         } else if(str.equalsIgnoreCase("ldap:///all")) {
             type = EnumUserDNType.ALL;
             bldr.replace(0, bldr.length(), urlStr);
-        } else if(str.indexOf("*") != -1) {
+        } else if (str.contains("*")) {
             type = EnumUserDNType.DNPATTERN;
         } else {
             type = EnumUserDNType.DN;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/SchemaReplicationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/SchemaReplicationTest.java
index ad439c3..88e87ad 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/SchemaReplicationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/SchemaReplicationTest.java
@@ -286,7 +286,7 @@
         byte[] bytes = new byte[input.available()];
         input.read(bytes);
         String fileStr = new String(bytes);
-        if (fileStr.indexOf(stateStr) != -1)
+        if (fileStr.contains(stateStr))
         {
           break;
         }

--
Gitblit v1.10.0