KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > codegen > indent > GarbageClass


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.test.codegen.indent;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26
27 /**
28  *
29  * @author Pavel Flaska
30  */

31 public class GarbageClass {
32     
33     /**
34      * Test method, will be moved.
35      */

36     public static String JavaDoc alois() {
37         // line comment before statement
38
new ArrayList JavaDoc().add(null); // end line comment
39

40         Object JavaDoc o = new Object JavaDoc();
41         List JavaDoc l; // end line comment
42

43         /* return question mark */
44         return "?"; // return statement
45
}
46     
47     public static void lojza()
48     {
49         // opening 'chlupata' bracket is at new line
50
; // empty statement used.
51

52         Map JavaDoc m = new HashMap JavaDoc();
53         Iterator JavaDoc it = m.values().iterator(); // get the iterator
54

55         /* iterate */
56         while (it.hasNext()) {
57             Class JavaDoc c = it.next().getClass();
58         } // end while
59

60         while (it.hasNext())
61             it.next(); // once more without 'chlupata'
62

63     } // end method
64

65     static void gianluigi() /* will test for statements */ {
66         for (int i = 0; i < 10; i++) {
67             if (i == 10) {
68                 // do anything
69
Thread.dumpStack();
70             } // endif
71
} // endfor
72

73         String JavaDoc s = "";
74         if (s.equals("")) {
75             s = "aa" + "bb"; // ?
76
} else {
77             System.err.println("Do nothing.");
78         }
79         
80         if ("test".equals(s) || "test2".equals(s))
81             s = "wow";
82     }
83     
84     static void call() {
85         List JavaDoc l = new ArrayList JavaDoc(10);
86         
87         // here are the several method call formatted
88
// first one is on one line
89
l.add(0, new Object JavaDoc());
90         
91         // second one is on one line with comments inside
92
l.add(1, /* new */ new Object JavaDoc());
93         
94         // third one is multiline call
95
l.addAll(
96             3, // position
97
java.util.Collections.EMPTY_LIST
98         );
99     }
100 }
101
Popular Tags