private Instruction matches( Map<Instruction, Map<String, String>> instructions, String pack, Set<Instruction> superfluousPatterns) { for (Instruction pattern : instructions.keySet()) { if (pattern.matches(pack)) { superfluousPatterns.remove(pattern); return pattern; } } return null; }
private boolean excluded(ArrayList instructions, String pkg) { for (Iterator i = instructions.iterator(); i.hasNext(); ) { Instruction f = (Instruction) i.next(); if (f.matches(pkg)) { return f.isNegated(); } } return true; }
public List<String> list(String regex) { Instruction pattern = null; if (regex != null) pattern = Instruction.getPattern(regex); List<String> result = new ArrayList<String>(); for (String f : index.keySet()) { if (pattern == null || pattern.matches(f)) result.add(f); } return result; }
public List<String> list(String regex) { Instruction pattern = null; if (regex != null) pattern = Instruction.getPattern(regex); String list[] = root.list(); List<String> result = new ArrayList<String>(); for (String f : list) { if (pattern == null || pattern.matches(f)) result.add(f); } return result; }
public boolean accept(File pathname) { if (doNotCopy != null && doNotCopy.matcher(pathname.getName()).matches()) { return false; } if (pathname.isDirectory() && isRecursive()) { return true; } if (instruction == null) { return true; } return !instruction.isNegated() == instruction.matches(pathname.getName()); } }
public boolean accept(File pathname) { if (Analyzer.doNotCopy.matcher(pathname.getName()).matches()) { return false; } if (pathname.isDirectory() && isRecursive()) { return true; } if (instruction == null) { return true; } return !instruction.isNegated() & instruction.matches(pathname.getName()); } }
void tree(List<String> list, File current, String path, Instruction instr) { if (path.length() > 0) path = path + "/"; String subs[] = current.list(); if (subs != null) { for (String sub : subs) { File f = new File(current, sub); if (f.isFile()) { if (instr.matches(sub) && !instr.isNegated()) list.add(path + sub); } else tree(list, f, path + sub, instr); } } }
void tree(List<String> list, File current, String path, Instruction instr) { if (path.length() > 0) path = path + "/"; String subs[] = current.list(); if (subs != null) { for (String sub : subs) { File f = new File(current, sub); if (f.isFile()) { if (instr.matches(sub) && !instr.isNegated()) list.add(path + sub); } else tree(list, f, path + sub, instr); } } }
void removeAttributes(Map<String, String> attributes) { // You can add a remove-attribute: directive with a regular // expression for attributes that need to be removed. We also // remove all attributes that have a value of !. This allows // you to use macros with ${if} to remove values. String remove = attributes.remove(REMOVE_ATTRIBUTE_DIRECTIVE); Instruction removeInstr = null; if (remove != null) removeInstr = Instruction.getPattern(remove); for (Iterator<Map.Entry<String, String>> i = attributes.entrySet().iterator(); i.hasNext();) { Map.Entry<String, String> entry = i.next(); if (entry.getValue().equals("!")) i.remove(); else if (removeInstr != null && removeInstr.matches((String) entry.getKey())) i.remove(); else { // Not removed ... } } }
@Override public List<String> list(String regex) { Instruction pattern = null; if (regex != null) pattern = Instruction.getPattern(regex); String list[] = getRoot().list(); List<String> result = new ArrayList<String>(); for (String f : list) { Matcher m = REPO_FILE.matcher(f); if (!m.matches()) { continue; } String s = m.group(1); if (pattern == null || pattern.matches(s)) result.add(s); } return result; } @Override
public static <T> Collection<T> select(Collection<Instruction> matchers, Collection<T> targets) { Collection<T> result = Create.list(); outer: for (T t : targets) { String s = t.toString(); for (Instruction i : matchers) { if (i.matches(s)) { if (!i.isNegated()) result.add(t); continue outer; } } } return result; } }
private void doView(File file, String resource, String charset, int options, File output) { // out.println("doView:" + file.getAbsolutePath() ); try { Instruction instruction = Instruction.getPattern(resource); FileInputStream fin = new FileInputStream(file); ZipInputStream in = new ZipInputStream(fin); ZipEntry entry = in.getNextEntry(); while (entry != null) { // out.println("view " + file + ": " // + instruction.getPattern() + ": " + entry.getName() // + ": " + output + ": " // + instruction.matches(entry.getName())); if (instruction.matches(entry.getName()) ^ instruction.isNegated()) doView(entry.getName(), in, charset, options, output); in.closeEntry(); entry = in.getNextEntry(); } in.close(); fin.close(); } catch (Exception e) { out.println("Can not process: " + file.getAbsolutePath()); e.printStackTrace(); } }
private void doView(File file, String resource, String charset, int options, File output) { // out.println("doView:" + file.getAbsolutePath() ); try { Instruction instruction = Instruction.getPattern(resource); FileInputStream fin = new FileInputStream(file); ZipInputStream in = new ZipInputStream(fin); ZipEntry entry = in.getNextEntry(); while (entry != null) { // out.println("view " + file + ": " // + instruction.getPattern() + ": " + entry.getName() // + ": " + output + ": " // + instruction.matches(entry.getName())); if (instruction.matches(entry.getName()) ^ instruction.isNegated()) doView(entry.getName(), in, charset, options, output); in.closeEntry(); entry = in.getNextEntry(); } in.close(); fin.close(); } catch (Exception e) { out.println("Can not process: " + file.getAbsolutePath()); e.printStackTrace(); } }
private void doView(String jar, String[] args, int i, String charset, int options, File output) { File path = new File(jar).getAbsoluteFile(); File dir = path.getParentFile(); if (dir == null) { dir = new File(""); } if (!dir.exists()) { error("No such file: " + dir.getAbsolutePath()); return; } String name = path.getName(); if (name == null) name = "META-INF/MANIFEST.MF"; Instruction instruction = Instruction.getPattern(path.getName()); File[] children = dir.listFiles(); for (int j = 0; j < children.length; j++) { String base = children[j].getName(); // out.println("Considering: " + // children[j].getAbsolutePath() + " " + // instruction.getPattern()); if (instruction.matches(base) ^ instruction.isNegated()) { for (; i < args.length; i++) { doView(children[j], args[i], charset, options, output); } } } }
private void doView(String jar, String[] args, int i, String charset, int options, File output) { File path = new File(jar).getAbsoluteFile(); File dir = path.getParentFile(); if (dir == null) { dir = new File(""); } if (!dir.exists()) { error("No such file: " + dir.getAbsolutePath()); return; } String name = path.getName(); if (name == null) name = "META-INF/MANIFEST.MF"; Instruction instruction = Instruction.getPattern(path.getName()); File[] children = dir.listFiles(); for (int j = 0; j < children.length; j++) { String base = children[j].getName(); // out.println("Considering: " + // children[j].getAbsolutePath() + " " + // instruction.getPattern()); if (instruction.matches(base) ^ instruction.isNegated()) { for (; i < args.length; i++) { doView(children[j], args[i], charset, options, output); } } } }
public List<String> list(String regex) throws Exception { init(); Instruction pattern = null; if (regex != null) pattern = Instruction.getPattern(regex); List<String> result = new ArrayList<String>(); if (root == null) { if (reporter != null) reporter.error("FileRepo root directory is not set."); } else { File[] list = root.listFiles(); if (list != null) { for (File f : list) { if (!f.isDirectory()) continue; // ignore non-directories String fileName = f.getName(); if (fileName.charAt(0) == '.') continue; // ignore hidden files if (pattern == null || pattern.matches(fileName)) result.add(fileName); } } else if (reporter != null) reporter.error("FileRepo root directory (%s) does not exist", root); } return result; }
/** * Add all the resources in the given jar that match the given filter. * * @param sub * the jar * @param filter * a pattern that should match the resoures in sub to be added */ public boolean addAll(Jar sub, Instruction filter, String destination) { boolean dupl = false; for (String name : sub.getResources().keySet()) { if ("META-INF/MANIFEST.MF".equals(name)) continue; if (filter == null || filter.matches(name) != filter.isNegated()) dupl |= putResource(Processor.appendPath(destination, name), sub.getResource(name), true); } return dupl; }
Clazz c = i.next(); System.out.println("fqn " + c.getFQN() + " " + instruction); if (instruction.matches(c.getFQN())) { if (instruction.isNegated()) i.remove();
if (instr.matches(bsn)) { if (instr.isNegated()) // - * - = +! break;