View Javadoc
1   /*
2   AvoidStaticImport
3   excludes = java.io.File.listRoots.listRoots, javax.swing.WindowConstants, javax.swing.*, \
4              sun.net.ftpclient.FtpClient.*FtpClient, sun.net.ftpclient.FtpClientjunk, \
5              java.io.File.listRootsmorejunk
6   
7   
8   */
9   
10  package com.puppycrawl.tools.checkstyle.checks.imports.avoidstaticimport;
11  
12  import java.io.*;
13  import java.lang.*;
14  import java.sql.Connection;
15  import java.util.List;
16  import java.util.List;
17  import java.lang.*;
18  import java.util.Iterator;
19  import java.util.Enumeration;
20  import java.util.Arrays;
21  
22  import javax.swing.JToolBar;
23  import javax.swing.JToggleButton;
24  import javax.swing.ScrollPaneLayout;
25  import javax.swing.BorderFactory;
26  import static java.io.File.listRoots; // violation
27  
28  import static javax.swing.WindowConstants.*; // violation
29  import static java.io.File.createTempFile; // violation
30  import static java.io.File.pathSeparator; // violation
31  import static java.lang.Math.E; // violation
32  import static java.lang.Math.sqrt; // violation
33  import static com.puppycrawl.tools.checkstyle.checks.imports.avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass; // violation
34  import static com.puppycrawl.tools.checkstyle.checks.imports.avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one; // violation
35  
36  import java.awt.Component;
37  import java.awt.Graphics2D;
38  import java.awt.HeadlessException;
39  import java.awt.Label;
40  import java.util.Date;
41  import java.util.Calendar;
42  import java.util.BitSet;
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  /**
53   * Test case for imports
54   * Here's an import used only by javadoc: {@link Date}.
55   * @author Oliver Burn
56   * @author lkuehne
57   * @author Michael Studman
58   * @see Calendar Should avoid unused import for Calendar
59   **/
60  class InputAvoidStaticImportDefault4
61  {
62      /** ignore **/
63      private Class mUse1 = Connection.class;
64      /** ignore **/
65      private Class mUse2 = File.class;
66      /** ignore **/
67      private Class mUse3 = Iterator[].class;
68      /** ignore **/
69      private Class mUse4 = Enumeration[].class;
70      /** usage of illegal import **/
71      private String ftpClient = null;
72  
73      /** usage via static method, both normal and fully qualified */
74      {
75          int[] x = {};
76          Arrays.sort(x);
77          Object obj = BorderFactory.createEmptyBorder();
78          File[] files = listRoots();
79      }
80  
81      /** usage of inner class as type */
82      private JToolBar.Separator mSep = null;
83  
84      /** usage of inner class in Constructor */
85      private Object mUse5 = new Object();
86  
87      /** usage of inner class in constructor, fully qualified */
88      private Object mUse6 = new JToggleButton.ToggleButtonModel();
89  
90      /** we use class name as member's name.
91       *  also an inline JavaDoc-only import {@link Vector linkText} */
92      private int Component;
93  
94      /**
95       * method comment with JavaDoc-only import {@link BitSet#aMethod()}
96       */
97      public void Label() {}
98  
99      /**
100      * Renders to a {@linkplain Graphics2D graphics context}.
101      * @throws HeadlessException if no graphis environment can be found.
102      * @exception HeadlessException if no graphis environment can be found.
103      */
104     public void render() {}
105 
106     /**
107      * First is a class with a method with arguments {@link TestClass1#method1(TestClass2)}.
108      * Next is a class with typed method {@link TestClass3#method2(TestClass4, TestClass5)}.
109      *
110      * @param param1 with a link {@link TestClass6}
111      * @throws TestClass7 when broken
112      * @deprecated in 1 for removal in 2. Use {@link TestClass8}
113      */
114     public void aMethodWithManyLinks() {}
115 }