1 20 21 package cpmake; 22 23 import java.util.regex.*; 24 import java.io.*; 25 26 class PatternDependency implements Dependency 27 { 28 private Pattern m_pattern; 29 private String m_strPattern; 30 private String m_replacement; 31 private CPMake m_make; 32 33 public PatternDependency(CPMake make, String pattern, String replacement) 34 { 35 m_make = make; 36 m_strPattern = pattern; 37 m_pattern = Pattern.compile(pattern); 38 m_replacement = replacement; 39 } 40 41 public boolean matchTarget(String target) 42 { 43 return (m_pattern.matcher(target.replace('\\', '/')).matches()); 44 } 45 46 public String [] getDependencies(String target) 47 { 48 target = target.replace('\\', '/'); 49 String [] s = new String [1]; 50 File f; 51 52 s[0] = target.replaceFirst(m_strPattern, m_replacement); 53 if ((f = m_make.locateFile(s[0])) != null) 54 { 55 s[0] = f.getPath(); 56 } 57 58 return (s); 59 } 60 61 public String toString() 62 { 63 return (m_strPattern + " : " + m_replacement); 64 } 65 } 66 | Popular Tags |