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