AsmAnalyzer { void findGlobs(String globPattern, Map<String, ClassReader> zipClasses, Map<String, ClassReader> inOutFound) throws LogAbortException { globPattern = globPattern.replaceAll("\\$", "\\\\\\$"); globPattern = globPattern.replaceAll("\\.", "\\\\."); globPattern = globPattern.replaceAll("\\*\\*", "@"); globPattern = globPattern.replaceAll("\\*", "[^.]*"); globPattern = globPattern.replaceAll("@", ".*"); globPattern += "$"; Pattern regexp = Pattern.compile(globPattern); for (Entry<String, ClassReader> entry : zipClasses.entrySet()) { String class_name = entry.getKey(); if (regexp.matcher(class_name).matches()) { findClass(class_name, zipClasses, inOutFound); } } } AsmAnalyzer(Log log, List<String> osJarPath, AsmGenerator gen,
            String[] deriveFrom, String[] includeGlobs); void analyze();  }
@Test public void testFindGlobs() throws IOException, LogAbortException { Map<String, ClassReader> zipClasses = mAa.parseZip(mOsJarPath); TreeMap<String, ClassReader> found = new TreeMap<String, ClassReader>(); found.clear(); mAa.findGlobs("mock_android.view", zipClasses, found); assertArrayEquals(new String[] { }, found.keySet().toArray()); mAa.findGlobs("mock_android.*.*Group$*Layout*", zipClasses, found); assertArrayEquals(new String[] { "mock_android.view.ViewGroup$LayoutParams", "mock_android.view.ViewGroup$MarginLayoutParams" }, found.keySet().toArray()); mAa.findGlobs("mock_android.**Group*", zipClasses, found); assertArrayEquals(new String[] { "mock_android.view.ViewGroup", "mock_android.view.ViewGroup$LayoutParams", "mock_android.view.ViewGroup$MarginLayoutParams" }, found.keySet().toArray()); found.clear(); mAa.findGlobs("mock_android.view.View", zipClasses, found); assertArrayEquals(new String[] { "mock_android.view.View" }, found.keySet().toArray()); found.clear(); mAa.findGlobs("mock_android.view.*", zipClasses, found); assertArrayEquals(new String[] { "mock_android.view.View", "mock_android.view.ViewGroup", "mock_android.view.ViewGroup$LayoutParams", "mock_android.view.ViewGroup$MarginLayoutParams" }, found.keySet().toArray()); for (String key : found.keySet()) { ClassReader value = found.get(key); assertNotNull("No value for " + key, value); assertEquals(key, AsmAnalyzer.classReaderToClassName(value)); } }