1 24 25 package org.aspectj.compiler.crosscuts.ast; 26 27 import org.aspectj.compiler.base.ast.*; 28 29 import org.aspectj.compiler.base.JavaCompiler; 30 31 import java.util.*; 32 33 39 40 public class NameTypeDPattern extends ASTObject { 41 private Set _typeDecs = null; 42 43 private String getMyPackageName() { 44 if (packageName == null) { 45 return getCompilationUnit().getPackageName(); 47 } else { 48 return packageName; 49 } 50 } 51 52 public boolean matches(TypeD typeD) { 53 return matches(typeD.getType()); 54 } 55 56 private boolean matches(Type type) { 57 if (type == null) return false; 58 59 if (!className.matches(type.getId())) { 60 return false; 61 } 62 String packageName = type.getPackageName(); 63 String myPackageName = getMyPackageName(); 64 if (myPackageName == null) return packageName == null; 65 if (packageName == null) return false; 66 67 if (includeSubpackages) { 68 return packageName.startsWith(myPackageName); 70 } else { 71 return myPackageName.equals(packageName); 72 } 73 } 74 75 76 80 99 protected String packageName; 101 public String getPackageName() { return packageName; } 102 public void setPackageName(String _packageName) { packageName = _packageName; } 103 104 protected NamePattern className; 105 public NamePattern getClassName() { return className; } 106 public void setClassName(NamePattern _className) { className = _className; } 107 108 protected boolean includeSubpackages; 109 public boolean getIncludeSubpackages() { return includeSubpackages; } 110 public void setIncludeSubpackages(boolean _includeSubpackages) { includeSubpackages = _includeSubpackages; } 111 112 public NameTypeDPattern(SourceLocation location, String _packageName, NamePattern _className, boolean _includeSubpackages) { 113 super(location); 114 setPackageName(_packageName); 115 setClassName(_className); 116 setIncludeSubpackages(_includeSubpackages); 117 } 118 protected NameTypeDPattern(SourceLocation source) { 119 super(source); 120 } 121 122 public ASTObject copyWalk(CopyWalker walker) { 123 NameTypeDPattern ret = new NameTypeDPattern(getSourceLocation()); 124 ret.preCopy(walker, this); 125 ret.packageName = packageName; 126 ret.className = className; 127 ret.includeSubpackages = includeSubpackages; 128 return ret; 129 } 130 131 132 public String getDefaultDisplayName() { 133 return "NameTypeDPattern(packageName: "+packageName+", "+"className: "+className+", "+"includeSubpackages: "+includeSubpackages+")"; 134 } 135 136 } 138 | Popular Tags |