1 24 25 package org.aspectj.compiler.crosscuts.ast; 26 import org.aspectj.compiler.base.ast.*; 27 import org.aspectj.compiler.crosscuts.joinpoints.*; 28 29 import org.aspectj.compiler.base.JavaCompiler; 30 31 import java.util.*; 32 import org.aspectj.util.InvertableSet; 33 34 35 39 public class WildName extends NamePattern { 40 public String getLookupString() { 41 return "*"; 42 } 43 44 public boolean isStar() { return false; } 45 46 private boolean matches(String s, int sIndex, int pieceIndex) { 47 49 if (pieceIndex == pieces.size()) { 50 return sIndex == s.length(); 51 } 52 53 String piece = (String )pieces.get(pieceIndex); 54 if (piece == "*") { 55 for (int i=sIndex; i<=s.length(); i++) { 56 if (matches(s, i, pieceIndex+1)) return true; 57 } 58 return false; 59 } else { 60 if (!s.regionMatches(sIndex, piece, 0, piece.length())) return false; 61 else return matches(s, sIndex+piece.length(), pieceIndex+1); 62 } 63 } 64 65 66 public boolean matches(String s) { 67 return matches(s, 0, 0); 69 } 70 71 public String toShortString() { 72 StringBuffer buf = new StringBuffer (); 73 for (Iterator i = pieces.iterator(); i.hasNext(); ) { 74 buf.append(i.next()); 75 } 76 return buf.toString(); 77 } 78 79 protected List pieces; 81 public List getPieces() { return pieces; } 82 public void setPieces(List _pieces) { pieces = _pieces; } 83 84 public WildName(SourceLocation location, List _pieces) { 85 super(location); 86 setPieces(_pieces); 87 } 88 protected WildName(SourceLocation source) { 89 super(source); 90 } 91 92 public ASTObject copyWalk(CopyWalker walker) { 93 WildName ret = new WildName(getSourceLocation()); 94 ret.preCopy(walker, this); 95 ret.pieces = pieces; 96 return ret; 97 } 98 99 100 public String getDefaultDisplayName() { 101 return "WildName(pieces: "+pieces+")"; 102 } 103 104 } 106 107 108 | Popular Tags |