Checking in some Java 5 changes

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5003 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Allan Caplan
2007-01-29 02:25:31 +00:00
parent 7ee230efcf
commit 10a60053c2
9 changed files with 37 additions and 39 deletions

View File

@ -134,12 +134,11 @@ public class Report {
if (rv.getPackageName() != null && rv.getPackageName().length() != 0) {
key = rv.getPackageName() + '.' + rv.getClassName();
}
Object o = summary.get(key);
Integer o = summary.get(key);
if (o == null) {
summary.put(key, NumericConstants.ONE);
} else {
Integer value = (Integer) o;
summary.put(key, new Integer(value.intValue() + 1));
summary.put(key, o+1);
}
}
return summary;
@ -161,7 +160,7 @@ public class Report {
summary.put(name, NumericConstants.ZERO);
}
Integer count = summary.get(name);
summary.put(name, new Integer(count.intValue() + 1));
summary.put(name, count + 1);
}
return summary;
}
@ -177,8 +176,8 @@ public class Report {
public void addRuleViolation(IRuleViolation violation) {
// NOPMD excluder
Integer line = new Integer(violation.getBeginLine());
if (linesToExclude.keySet().contains(line)) {
int line = violation.getBeginLine();
if (linesToExclude.containsKey(line)) {
suppressedRuleViolations.add(new SuppressedViolation(violation, true, linesToExclude.get(line)));
return;
}

View File

@ -17,7 +17,7 @@ public class IntegerProperty extends AbstractScalarProperty {
* @param theUIOrder float
*/
public IntegerProperty(String theName, String theDescription, int theDefault, float theUIOrder) {
super(theName, theDescription, new Integer(theDefault), theUIOrder);
super(theName, theDescription, theDefault, theUIOrder);
}
/**
@ -53,7 +53,7 @@ public class IntegerProperty extends AbstractScalarProperty {
*/
private static final Integer[] asIntegers(int[] ints) {
Integer[] integers = new Integer[ints.length];
for (int i=0; i<ints.length; i++) integers[i] = new Integer(ints[i]);
for (int i=0; i<ints.length; i++) integers[i] = Integer.valueOf(ints[i]);
return integers;
}
@ -72,7 +72,7 @@ public class IntegerProperty extends AbstractScalarProperty {
* @return Object
*/
protected Object createFrom(String value) {
return new Integer(value);
return Integer.valueOf(value);
}
/**

View File

@ -11,6 +11,7 @@ import net.sourceforge.pmd.ast.ASTType;
import net.sourceforge.pmd.ast.ASTVariableDeclarator;
import net.sourceforge.pmd.ast.SimpleJavaNode;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.util.NumericConstants;
public class MoreThanOneLogger extends AbstractRule {
@ -28,11 +29,11 @@ public class MoreThanOneLogger extends AbstractRule {
private Object init(SimpleJavaNode node, Object data) {
stack.push(count);
count = new Integer(0);
count = NumericConstants.ZERO;
node.childrenAccept(this, data);
if (count.intValue() > 1) {
if (count > 1) {
addViolation(data, node);
}
count = stack.pop();
@ -41,7 +42,7 @@ public class MoreThanOneLogger extends AbstractRule {
}
public Object visit(ASTVariableDeclarator node, Object data) {
if (count.intValue() > 1) {
if (count > 1) {
return super.visit(node, data);
}
SimpleNode type = (SimpleNode) ((SimpleNode) node.jjtGetParent()).getFirstChildOfType(ASTType.class);
@ -50,7 +51,7 @@ public class MoreThanOneLogger extends AbstractRule {
if (reftypeNode instanceof ASTReferenceType) {
SimpleNode classOrIntType = (SimpleNode) reftypeNode.jjtGetChild(0);
if (classOrIntType instanceof ASTClassOrInterfaceType && "Logger".equals(classOrIntType.getImage())) {
count = new Integer(count.intValue()+1);
++count;
}
}
}

View File

@ -62,7 +62,7 @@ public abstract class AbstractNcssCount extends StatisticalRule {
addDataPoint( point );
}
return new Integer( numNodes );
return Integer.valueOf( numNodes );
}
/**
@ -83,7 +83,7 @@ public abstract class AbstractNcssCount extends StatisticalRule {
this, data );
lineCount += nodeCount.intValue();
}
return new Integer( ++lineCount );
return ++lineCount;
}
public Object visit(ASTForStatement node, Object data) {
@ -99,9 +99,7 @@ public abstract class AbstractNcssCount extends StatisticalRule {
Integer lineCount = countNodeChildren( node, data );
if ( node.hasElse() ) {
int lines = lineCount.intValue();
lines++;
lineCount = new Integer( lines );
lineCount++;
}
return lineCount;

View File

@ -55,7 +55,7 @@ public class NcssTypeCount extends AbstractNcssCount {
if ( node.jjtGetParent() instanceof ASTTypeDeclaration ) {
Integer nodeCount = countNodeChildren( node, data );
int count = nodeCount.intValue() - 1;
return new Integer( count );
return Integer.valueOf( count );
}
return countNodeChildren( node, data );
}

View File

@ -34,7 +34,7 @@ public class ExcessiveNodeCountRule extends StatisticalRule {
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
Integer treeSize = (Integer) ((SimpleJavaNode) node.jjtGetChild(i)).jjtAccept(this, data);
numNodes += treeSize.intValue();
numNodes += treeSize;
}
if (nodeClass.isInstance(node)) {
@ -45,6 +45,6 @@ public class ExcessiveNodeCountRule extends StatisticalRule {
addDataPoint(point);
}
return new Integer(numNodes);
return Integer.valueOf(numNodes);
}
}

View File

@ -41,10 +41,10 @@ public class NpathComplexity extends StatisticalRule {
for ( int i = 0; i < node.jjtGetNumChildren(); i++ ) {
simpleNode = (SimpleJavaNode) node.jjtGetChild( i );
npath *= ((Integer) simpleNode.jjtAccept( this, data )).intValue();
npath *= ((Integer) simpleNode.jjtAccept( this, data ));
}
return new Integer( npath );
return npath;
}
private int complexitySumOf(SimpleJavaNode node, int npathStart, Object data) {
@ -54,10 +54,10 @@ public class NpathComplexity extends StatisticalRule {
for ( int i = 0; i < node.jjtGetNumChildren(); i++ ) {
simpleNode = (SimpleJavaNode) node.jjtGetChild( i );
npath += ((Integer) simpleNode.jjtAccept( this, data )).intValue();
npath += (Integer) simpleNode.jjtAccept( this, data );
}
return new Integer( npath );
return npath;
}
public Object visit(ASTMethodDeclaration node, Object data) {
@ -79,7 +79,7 @@ public class NpathComplexity extends StatisticalRule {
point.setMessage( getMessage() );
addDataPoint( point );
return new Integer( npath );
return Integer.valueOf( npath );
}
public Object visit(SimpleJavaNode node, Object data) {
@ -93,7 +93,7 @@ public class NpathComplexity extends StatisticalRule {
int npath = complexityMultipleOf(node, 1, data);
return new Integer( npath );
return Integer.valueOf( npath );
}
public Object visit(ASTIfStatement node, Object data) {
@ -122,10 +122,10 @@ public class NpathComplexity extends StatisticalRule {
}
for (SimpleJavaNode element: statementChildren) {
complexity += ( (Integer) element.jjtAccept( this, data ) ).intValue();
complexity += (Integer) element.jjtAccept( this, data );
}
return new Integer( boolCompIf + complexity );
return Integer.valueOf( boolCompIf + complexity );
}
public Object visit(ASTWhileStatement node, Object data) {
@ -136,7 +136,7 @@ public class NpathComplexity extends StatisticalRule {
Integer nPathWhile = (Integer) ( (SimpleJavaNode) node.getFirstChildOfType( ASTStatement.class ) ).jjtAccept(
this, data );
return new Integer( boolCompWhile + nPathWhile.intValue() + 1 );
return Integer.valueOf( boolCompWhile + nPathWhile + 1 );
}
public Object visit(ASTDoStatement node, Object data) {
@ -147,7 +147,7 @@ public class NpathComplexity extends StatisticalRule {
Integer nPathDo = (Integer) ( (SimpleJavaNode) node.getFirstChildOfType( ASTStatement.class ) ).jjtAccept(
this, data );
return new Integer( boolCompDo + nPathDo.intValue() + 1 );
return Integer.valueOf( boolCompDo + nPathDo + 1 );
}
public Object visit(ASTForStatement node, Object data) {
@ -158,7 +158,7 @@ public class NpathComplexity extends StatisticalRule {
Integer nPathFor = (Integer) ( (SimpleJavaNode) node.getFirstChildOfType( ASTStatement.class ) ).jjtAccept(
this, data );
return new Integer( boolCompFor + nPathFor.intValue() + 1 );
return Integer.valueOf( boolCompFor + nPathFor + 1 );
}
public Object visit(ASTReturnStatement node, Object data) {
@ -175,7 +175,7 @@ public class NpathComplexity extends StatisticalRule {
int boolCompReturn = andNodes.size() + orNodes.size();
if ( boolCompReturn > 0 ) {
return new Integer( boolCompReturn );
return Integer.valueOf( boolCompReturn );
}
return NumericConstants.ONE;
}
@ -196,12 +196,12 @@ public class NpathComplexity extends StatisticalRule {
caseRange = 1;
} else {
Integer complexity = (Integer) simpleNode.jjtAccept( this, data );
caseRange *= complexity.intValue();
caseRange *= complexity;
}
}
// add in npath of last label
npath += caseRange;
return new Integer( boolCompSwitch + npath );
return Integer.valueOf( boolCompSwitch + npath );
}
public Object visit(ASTTryStatement node, Object data) {

View File

@ -132,9 +132,9 @@ public class InsufficientStringBufferDeclaration extends AbstractRule {
}
Integer x = thisBranch.get(block);
if (x != null) {
thisSize += x.intValue();
thisSize += x;
}
thisBranch.put(statement, new Integer(thisSize));
thisBranch.put(statement, thisSize);
}
private int processBlocks(Map<Node, Map<Node, Integer>> blocks) {

View File

@ -2,6 +2,6 @@ package net.sourceforge.pmd.util;
public interface NumericConstants {
Integer ZERO = new Integer(0);
Integer ONE = new Integer(1);
Integer ZERO = 0;
Integer ONE = 1;
}