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