Source Code Cross Referenced for InputWhitespace.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:        ////////////////////////////////////////////////////////////////////////////////
002:        // Test case file for checkstyle.
003:        // Created: 2001
004:        ////////////////////////////////////////////////////////////////////////////////
005:        package com.puppycrawl.tools.checkstyle;
006:
007:        /**
008:         * Class for testing whitespace issues.
009:         * error missing author tag
010:         **/
011:        class InputWhitespace {
012:            /** ignore assignment **/
013:            private int mVar1 = 1;
014:            /** ignore assignment **/
015:            private int mVar2 = 1;
016:            /** Should be ok **/
017:            private int mVar3 = 1;
018:
019:            /** method **/
020:            void method1() {
021:                final int a = 1;
022:                int b = 1; // Ignore 1
023:                b = 1; // Ignore 1
024:                b += 1; // Ignore 1
025:                b -= -1 + (+b); // Ignore 2
026:                b = b++ + b--; // Ignore 1
027:                b = ++b - --b; // Ignore 1
028:            }
029:
030:            /** method **/
031:            void method2() {
032:                synchronized (this ) {
033:                }
034:                try {
035:                } catch (RuntimeException e) {
036:                }
037:            }
038:
039:            /**
040:               skip blank lines between comment and code,
041:               should be ok
042:             **/
043:
044:            private int mVar4 = 1;
045:
046:            /** test WS after void return */
047:            private void fastExit() {
048:                boolean complicatedStuffNeeded = true;
049:                if (!complicatedStuffNeeded) {
050:                    return; // should not complain about missing WS after return
051:                } else {
052:                    // do complicated stuff
053:                }
054:            }
055:
056:            /** test WS after non void return
057:             @return 2
058:             */
059:            private int nonVoid() {
060:                if (true) {
061:                    return (2); // should complain about missing WS after return
062:                } else {
063:                    return 2; // this is ok
064:                }
065:            }
066:
067:            /** test casts **/
068:            private void testCasts() {
069:                Object o = (Object) new Object(); // ok
070:                o = (Object) o; // error
071:                o = (Object) o; // ok
072:                o = (Object) o; // ok
073:            }
074:
075:            /** test questions **/
076:            private void testQuestions() {
077:                boolean b = (1 == 2) ? true : false;
078:                b = (1 == 2) ? false : true;
079:            }
080:
081:            /** star test **/
082:            private void starTest() {
083:                int x = 2 * 3 * 4;
084:            }
085:
086:            /** boolean test **/
087:            private void boolTest() {
088:                boolean a = true;
089:                boolean x = !a;
090:                int z = ~1 + ~2;
091:            }
092:
093:            /** division test **/
094:            private void divTest() {
095:                int a = 4 % 2;
096:                int b = 4 % 2;
097:                int c = 4 % 2;
098:                int d = 4 % 2;
099:                int e = 4 / 2;
100:                int f = 4 / 2;
101:                int g = 4 / 2;
102:                int h = 4 / 2;
103:            }
104:
105:            /** @return dot test **/
106:            private java.lang.String dotTest() {
107:                Object o = new java.lang.Object();
108:                o.toString();
109:                o.toString();
110:                o.toString();
111:                return o.toString();
112:            }
113:
114:            /** assert statement test */
115:            public void assertTest() {
116:                // OK
117:                assert true;
118:
119:                // OK
120:                assert true : "Whups";
121:
122:                // evil colons, should be OK
123:                assert "OK".equals(null) ? false : true : "Whups";
124:
125:                // missing WS around assert
126:                assert (true);
127:
128:                // missing WS around colon
129:                assert true : "Whups";
130:            }
131:
132:            /** another check */
133:            void donBradman(Runnable aRun) {
134:                donBradman(new Runnable() {
135:                    public void run() {
136:                    }
137:                });
138:
139:                final Runnable r = new Runnable() {
140:                    public void run() {
141:                    }
142:                };
143:            }
144:
145:            /** rfe 521323, detect whitespace before ';' */
146:            void rfe521323() {
147:                doStuff();
148:                //       ^ whitespace
149:                for (int i = 0; i < 5; i++) {
150:                    //        ^ whitespace
151:                }
152:            }
153:
154:            /** bug  806243 (NoWhitespaceBeforeCheck error for anonymous inner class) */
155:            private int i;
156:            //           ^ whitespace
157:            private int i1, i2, i3;
158:            //                    ^ whitespace
159:            private int i4, i5, i6;
160:
161:            /** bug  806243 (NoWhitespaceBeforeCheck error for anonymous inner class) */
162:            void bug806243() {
163:                Object o = new InputWhitespace() {
164:                    private int j;
165:                    //           ^ whitespace
166:                };
167:            }
168:
169:            void doStuff() {
170:            }
171:        }
172:
173:        /**
174:         * Bug 806242 (NoWhitespaceBeforeCheck error with an interface).
175:         * @author o_sukhodolsky
176:         * @version 1.0
177:         */
178:        interface IFoo {
179:            void foo();
180:            //        ^ whitespace
181:        }
182:
183:        /**
184:         * Avoid Whitespace errors in for loop.
185:         * @author lkuehne
186:         * @version 1.0
187:         */
188:        class SpecialCasesInForLoop {
189:            void forIterator() {
190:                // avoid conflict between WhiteSpaceAfter ';' and ParenPad(nospace)
191:                for (int i = 0; i++ < 5;) {
192:                    //                  ^ no whitespace
193:                }
194:
195:                // bug 895072
196:                // avoid confilct between ParenPad(space) and NoWhiteSpace before ';'
197:                int i = 0;
198:                for (; i < 5; i++) {
199:                    //   ^ whitespace
200:                }
201:                for (int anInt : getSomeInts()) {
202:                    //Should be ignored
203:                }
204:            }
205:
206:            int[] getSomeInts() {
207:                int i = (int) (2 / 3);
208:                return null;
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.