View Javadoc

    1   package net.sourceforge.pmd.rules.strings;
    2
    3   import net.sourceforge.pmd.rules.AbstractPoorMethodCall;
    4
    5   /***
    6    */
    7   public class UseIndexOfChar extends AbstractPoorMethodCall {
    8
    9       private static final String targetTypeName = "String";
    10      private static final String[] methodNames = new String[] { "indexOf", "lastIndexOf" };
    11
    12      public UseIndexOfChar() {
    13          super();
    14      }
    15
    16      /***
    17       * Method targetTypeName.
    18       * @return String
    19       */
    20      protected String targetTypename() {
    21          return targetTypeName;
    22      }
    23
    24      /***
    25       * Method methodNames.
    26       * @return String[]
    27       */
    28      protected String[] methodNames() {
    29          return methodNames;
    30      }
    31
    32      /***
    33       * Method isViolationArgument.
    34       * @param argIndex int
    35       * @param arg String
    36       * @return boolean
    37       */
    38      protected boolean isViolationArgument(int argIndex, String arg) {
    39
    40          return isSingleCharAsString(arg);
    41      }
    42
    43  }