Source Code Cross Referenced for InputMagicNumber.java in  » Code-Analyzer » checkstyle » com » puppycrawl » tools » checkstyle » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » checkstyle » com.puppycrawl.tools.checkstyle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.puppycrawl.tools.checkstyle;
002:
003:        /**
004:         * Describe class InputMagicNumber
005:         * @author Rick Giles
006:         * @version 6-May-2003
007:         */
008:        public class InputMagicNumber {
009:            public void magicMethod() {
010:                //constants, ignore
011:                final int INT_CONST = 101;
012:                final long LONG_CONST1 = 100L;
013:                final long LONG_CONST2 = 100l;
014:                final float FLOAT_CONST1 = 1.5F;
015:                final float FLOAT_CONST2 = 1.5f;
016:                final double DOUBLE_CONST1 = 1.5D;
017:                final double DOUBLE_CONST2 = 1.5d;
018:                final double DOUBLE_CONST3 = 1.5;
019:
020:                //ignore by default
021:                int int_var1 = 1;
022:                int int_var2 = (2);
023:                long long_var1 = 0L;
024:                long long_var2 = 0l;
025:                double double_var1 = 0D;
026:                double double_var2 = 0d;
027:
028:                int[] int_array = new int[2];
029:
030:                int_var1 = 1 + 2;
031:                int_var1 += 1;
032:                double_var1 = 1.0 + 2.0;
033:
034:                for (int i = 0; i < 2; i++)
035:                    ;
036:
037:                if (1 < 2)
038:                    ;
039:
040:                if (1.0 < 2.0)
041:                    ;
042:
043:                //magic numbers
044:                int int_magic1 = 3;
045:                double double_magic1 = 1.5;
046:                int int_magic2 = (3 + 4);
047:
048:                int_array = new int[3];
049:
050:                int_magic1 += 3;
051:                double_magic1 *= 1.5;
052:
053:                for (int j = 3; j < 5; j += 3) {
054:                    int_magic1++;
055:                }
056:
057:                if (int_magic1 < 3) {
058:                    int_magic1 = int_magic1 + 3;
059:                }
060:
061:                //octal
062:                int octalVar0 = 00;
063:                int octalVar8 = 010;
064:                int octalVar9 = 011;
065:
066:                long longOctalVar8 = 010L;
067:                long longOctalVar9 = 011l;
068:
069:                //hex
070:                int hexVar0 = 0x0;
071:                int hexVar16 = 0x10;
072:                int hexVar17 = 0X011;
073:                long longHexVar0 = 0x0L;
074:                long longHexVar16 = 0x10L;
075:                long longHexVar17 = 0X11l;
076:            }
077:        }
078:
079:        interface Blah {
080:            int LOW = 5;
081:            int HIGH = 78;
082:        }
083:
084:        class ArrayMagicTest {
085:            private static final int[] NONMAGIC = { 3 };
086:            private int[] magic = { 3 };
087:            private static final int[][] NONMAGIC2 = { { 1 }, { 2 }, { 3 } };
088:        }
089:
090:        /** test long hex */
091:        class LongHex {
092:            long l = 0xffffffffL;
093:        }
094:
095:        /** test signed values */
096:        class Signed {
097:            public static final int CONST_PLUS_THREE = +3;
098:            public static final int CONST_MINUS_TWO = -2;
099:            private int mPlusThree = +3;
100:            private int mMinusTwo = -2;
101:            private double mPlusDecimal = +3.5;
102:            private double mMinusDecimal = -2.5;
103:        }
104:
105:        /** test octal and hex negative values */
106:        class NegativeOctalHex {
107:            private int hexIntMinusOne = 0xffffffff;
108:            private long hexLongMinusOne = 0xffffffffffffffffL;
109:            private long hexIntMinValue = 0x80000000;
110:            private long hexLongMinValue = 0x8000000000000000L;
111:            private int octalIntMinusOne = 037777777777;
112:            private long octalLongMinusOne = 01777777777777777777777L;
113:            private long octalIntMinValue = 020000000000;
114:            private long octalLongMinValue = 01000000000000000000000L;
115:        }
116:
117:        class Cast {
118:            public static final int TESTINTVAL = (byte) 0x80;
119:        }
120:
121:        class ComplexAndFlagged {
122:            public static final java.util.List MYLIST = new java.util.ArrayList() {
123:                public int size() {
124:                    // should be flagged although technically inside const definition
125:                    return 378;
126:                }
127:            };
128:        }
129:
130:        class ComplexButNotFlagged {
131:            // according to user feedback this is typical code that should not be flagged
132:            // (at least in the default configuration of MagicNumberCheck)
133:            public static final Integer DEFAULT_INT = new Integer(27);
134:            public static final int SECS_PER_DAY = 24 * 60 * 60;
135:            public static final javax.swing.border.Border STD_BORDER = javax.swing.BorderFactory
136:                    .createEmptyBorder(3, 3, 3, 3);
137:        }
138:
139:        enum MyEnum {
140:            A(3), B(54);
141:
142:            private MyEnum(int value) {
143:
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.