1 2 29 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify; 30 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 35 36 40 public class ExternalPackage extends ExternalDefinition implements IPackage { 41 42 String _name; 43 IPackage _parent; 44 45 Map _packages; 46 47 public ExternalPackage(String name, IPackage parent) { 48 _name = name; 49 _parent = parent; 50 51 _packages = new HashMap (); 52 } 53 54 public IClass getClass(String name) { 55 IClass result = null; 56 57 try { 58 Class theClass 59 = ClassManager.getClassLoader().loadClass(getQualifiedName() 60 + "." 61 + name); 62 result = new ExternalClass(theClass); 63 } 64 catch (ClassNotFoundException e) { 65 } 67 68 return result; 69 } 70 71 public void addDefinition(IPackage pkg) { 72 _packages.put(pkg.getName(), pkg); 73 } 74 75 public IPackage getEnclosingPackage() { 76 return _parent; 77 } 78 79 public String getName() { 80 return _name; 81 } 82 83 public String getQualifiedName() { 84 StringBuffer result = new StringBuffer (); 85 86 if (_parent != null) { 87 result.append(_parent.getQualifiedName()); 88 result.append("."); 89 } 90 91 result.append(getName()); 92 93 return result.toString(); 94 } 95 } 96 | Popular Tags |