Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.pmd.rules
Class AbstractPoorMethodCall

    java.lang.Object
      net.sourceforge.pmd.ast.JavaParserVisitorAdapter
          net.sourceforge.pmd.AbstractRule
              net.sourceforge.pmd.rules.AbstractPoorMethodCall

All Implemented Interfaces:
  JavaParserVisitor, Rule

Direct Known Subclasses:
  UseIndexOfChar

public abstract class AbstractPoorMethodCall
extends AbstractRule

Detects and flags the occurrences of specific method calls against an instance of a designated class. I.e. String.indexOf. The goal is to be able to suggest more efficient/modern ways of implementing the same function. Concrete subclasses are expected to provide the name of the target class and an array of method names that we are looking for. We then pass judgement on any literal arguments we find in the subclass as well.

Version:
  $Revision: 1.1 $
Author:
  Brian Remedios

Field Summary

Fields inherited from class net.sourceforge.pmd.AbstractRule
`description, example, externalInfoUrl, include, message, name, priority, properties, ruleSetName, usesDFA, usesTypeResolution`

Fields inherited from interface net.sourceforge.pmd.Rule
`LOWEST_PRIORITY, PRIORITIES`

Constructor Summary
`AbstractPoorMethodCall()`

Method Summary
`static boolean` | `isSingleCharAsString(java.lang.String value)` Returns whether the value argument is a single character string.
`protected abstract boolean` | `isViolationArgument(int argIndex, java.lang.String arg)` Returns whether the string argument at the stated position being sent to the method is ok or not.
`protected abstract java.lang.String[]` | `methodNames()` Return the names of all the methods we are scanning for, no brackets or argument types.
`protected abstract java.lang.String` | `targetTypename()` The name of the type the method will be invoked against.
`java.lang.Object` | `visit(ASTVariableDeclaratorId node, java.lang.Object data)` Method visit.

Methods inherited from class net.sourceforge.pmd.AbstractRule
`addProperties, addProperty, addViolation, addViolation, addViolation, addViolationWithMessage, apply, asFixedMap, asFixedMap, equals, getBooleanProperties, getBooleanProperty, getBooleanProperty, getDeclaringType, getDescription, getDoubleProperties, getDoubleProperty, getDoubleProperty, getExample, getExternalInfoUrl, getIntProperties, getIntProperty, getIntProperty, getMessage, getName, getPriority, getPriorityName, getProperties, getRuleSetName, getStringProperties, getStringProperty, getStringProperty, getTypeProperties, getTypeProperty, hashCode, hasProperty, importsPackage, include, isQualifiedName, propertiesByName, propertyDescriptorFor, setBooleanProperty, setDescription, setExample, setExternalInfoUrl, setInclude, setMessage, setName, setPriority, setProperties, setProperty, setRuleSetName, setUsesDFA, setUsesTypeResolution, usesDFA, usesTypeResolution, visitAll`

Methods inherited from class net.sourceforge.pmd.ast.JavaParserVisitorAdapter
`visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractPoorMethodCall

    public AbstractPoorMethodCall()

Method Detail

### targetTypename

    protected abstract java.lang.String targetTypename()

  The name of the type the method will be invoked against.

  Returns:
    String

### methodNames

    protected abstract java.lang.String[] methodNames()

  Return the names of all the methods we are scanning for, no brackets or argument types.

  Returns:
    String[]

### isViolationArgument

    protected abstract boolean isViolationArgument(int argIndex,
                                                   java.lang.String arg)

  Returns whether the string argument at the stated position being sent to the method is ok or not. Return true if you want to record the method call as a violation, false otherwise.

  Parameters:
    `argIndex` - int
    `arg` - String
  Returns:
    boolean

### isSingleCharAsString

    public static boolean isSingleCharAsString(java.lang.String value)

  Returns whether the value argument is a single character string.

  Parameters:
    `value` - String
  Returns:
    boolean

### visit

    public java.lang.Object visit(ASTVariableDeclaratorId node,
                                  java.lang.Object data)

  Method visit.

  Specified by:
    `visit` in interface `JavaParserVisitor`
  Overrides:
    `visit` in class `JavaParserVisitorAdapter`
  Parameters:
    `node` - ASTVariableDeclaratorId
    `data` - Object
  Returns:
    Object
  See Also:
    `JavaParserVisitor.visit(ASTVariableDeclaratorId, Object)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 InfoEther. All Rights Reserved.