KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > usage > transmogrify > UnknownClass


1
2 // Transmogrify License
3
//
4
// Copyright (c) 2001, ThoughtWorks, Inc.
5
// All rights reserved.
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions
8
// are met:
9
// - Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// - Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
// Neither the name of the ThoughtWorks, Inc. nor the names of its
15
// contributors may be used to endorse or promote products derived from this
16
// software without specific prior written permission.
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28

29 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
30
31
32
33 import java.util.Iterator JavaDoc;
34 import java.util.List JavaDoc;
35 import java.util.Vector JavaDoc;
36
37
38
39 public class UnknownClass implements IClass {
40
41   String JavaDoc _name;
42   SymTabAST _node;
43
44   public UnknownClass(String JavaDoc name, SymTabAST node) {
45     _name = name;
46     _node = node;
47     //System.out.println("Creating unknown class [" + name + " : " + node + "]");
48
}
49
50   /**
51    * returns the <code>ClassDef</code> that for the superclass
52    *
53    * @return the <code>ClassDef</code> for the superclass
54    */

55   public IClass getSuperclass() {
56     return null;
57   }
58
59   public IClass[] getInterfaces() {
60     return new IClass[0];
61   }
62
63   /**
64    * returns a collection of the direct subclasses of this class
65    *
66    * @return a collection of the direct subclasses of this class
67    */

68   public List JavaDoc getSubclasses() {
69     return new Vector JavaDoc();
70   }
71
72   public IClass getClassDefinition(String JavaDoc name) {
73     return null;
74   }
75
76   /**
77    * gets the method associated with the given name and signature
78    *
79    * @param name the name of the method
80    * @param signature the signature (formal parameter types) of the method
81    *
82    * @return MethodDef
83    *
84    * @see MethodSignature
85    */

86   public IMethod getMethodDefinition(String JavaDoc name,
87                                      ISignature signature) {
88     return null;
89   }
90
91   /**
92    * gets the <code>VariableDef</code> associated with the given name
93    *
94    * @param name the name of the variable
95    *
96    * @return VariableDef
97    */

98   public IVariable getVariableDefinition(String JavaDoc name) {
99     return null;
100   }
101
102   // end definitions interface
103

104   /**
105    * adds <code>ClassDef</code> to the collection of (direct?) subclasses of
106    * this class
107    *
108    * @param subclass the class to add
109    */

110   public void addSubclass(ClassDef subclass) {}
111
112   /**
113    * adds <code>ClassDef</code> to the collection of implemented interfaces
114    * of this class
115    *
116    * @param implementor the interface to add
117    */

118   public void addImplementor(ClassDef implementor) {}
119
120   /**
121    * gets the list of <code>ClassDefs</code> that implmement this interface
122    *
123    * @return Vector the list of implementors
124    */

125   public List JavaDoc getImplementors() {
126     return new Vector JavaDoc();
127   }
128
129   public boolean isCompatibleWith(IClass type) {
130     return false;
131   }
132
133   public void addReference(Reference reference) {}
134   public Iterator JavaDoc getReferences() {
135     return new Vector JavaDoc().iterator();
136   }
137
138   public int getNumReferences() {
139     return 0;
140   }
141
142   public boolean isPrimitive() {
143     return false;
144   }
145
146   public boolean isSourced() {
147     return false;
148   }
149
150   public IClass[] getInnerClasses() {
151     return new IClass[0];
152   }
153
154   public String JavaDoc getName() {
155     return _name;
156   }
157
158   public String JavaDoc getQualifiedName() {
159     return _name;
160   }
161
162   public boolean equals(Object JavaDoc o) {
163     //TODO: handle Checkstyle condition for two unknown classes
164
if (o instanceof UnknownClass) {
165         final UnknownClass other = (UnknownClass) o;
166         return other.getName().equals(getName());
167     }
168     return false;
169   }
170
171   public String JavaDoc toString() {
172     return UnknownClass.class + "[" + getName() + "]";
173   }
174 }
175
Popular Tags