com.jimischopp.checkstyle
Class WastefulParseNumCheck

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.Check
              extended by com.jimischopp.checkstyle.AbstractBaseChecker
                  extended by com.jimischopp.checkstyle.WastefulParseNumCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

public class WastefulParseNumCheck
extends AbstractBaseChecker

Checks for unnecessary wrapper object creation used to parse strings and primitives. This is a very novice programming mistake that nevertheless occurs. It finds code like:

        short s = new Short("5").shortValue();
 
It also subsequently finds truly creative novice code such as:
        int i = new Integer("-" + x).intValue();
 
and
        int i = new Long(-1).intValue();
 

Copyright 2003, James Schopp

Since:
Oct 27, 2003
Author:
James Schopp
See Also:
Check

Constructor Summary
WastefulParseNumCheck()
           
 
Method Summary
 int[] getAcceptableTokens()
           
 int[] getDefaultTokens()
           
 int[] getRequiredTokens()
           
 void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
           
 
Methods inherited from class com.jimischopp.checkstyle.AbstractBaseChecker
isInsideLoop
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLines, getTokenNames, init, leaveToken, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getId, getSeverity, getSeverityLevel, setId, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WastefulParseNumCheck

public WastefulParseNumCheck()
Method Detail

getDefaultTokens

public int[] getDefaultTokens()
Specified by:
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.Check

getAcceptableTokens

public int[] getAcceptableTokens()
Overrides:
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.Check

getRequiredTokens

public int[] getRequiredTokens()
Overrides:
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.Check

visitToken

public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
Overrides:
visitToken in class com.puppycrawl.tools.checkstyle.api.Check