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 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); } } }
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); } } } }
if (files[f] != null) { if (instr.matches(files[f])) { if (!instr.isNegated()) { if (relative) result.add(files[f]);
if (files[f] != null) { if (instr.matches(files[f])) { if (!instr.isNegated()) { if (relative) result.add(files[f]);
if (from != null) { Instruction f = Instruction.getPattern(from); if (!f.matches(source) || f.isNegated()) return null;
if (instruction.matches(file.getName())) { if (!instruction.isNegated()) { builders.add(getSubBuilder(file));
/** * 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; }
System.out.println("fqn " + c.getFQN() + " " + instruction); if (instruction.matches(c.getFQN())) { if (instruction.isNegated()) i.remove(); else {
if (instr.isNegated()) // - * - = +! break; else
public Resource process(String source) { Map<Instruction, Map<String, String>> make = getMakeHeader(); builder.trace("make " + source); for (Map.Entry<Instruction, Map<String, String>> entry : make .entrySet()) { Instruction instr = entry.getKey(); Matcher m = instr.getMatcher(source); if (m.matches() || instr.isNegated()) { Map<String, String> arguments = replace(m, entry.getValue()); List<MakePlugin> plugins = builder.getPlugins(MakePlugin.class); for (MakePlugin plugin : plugins) { try { Resource resource = plugin.make(builder, source, arguments); if (resource != null) { builder.trace("Made " + source + " from args " + arguments + " with " + plugin); return resource; } } catch (Exception e) { builder.error("Plugin " + plugin + " generates error when use in making " + source + " with args " + arguments, e); } } } } return null; }
public Resource process(String source) { Map<Instruction, Map<String, String>> make = getMakeHeader(); builder.trace("make " + source); for (Map.Entry<Instruction, Map<String, String>> entry : make .entrySet()) { Instruction instr = (Instruction) entry.getKey(); Matcher m = instr.getMatcher(source); if (m.matches() || instr.isNegated()) { Map<String, String> arguments = replace(m, entry.getValue()); List<MakePlugin> plugins = builder.getPlugins(MakePlugin.class); for (MakePlugin plugin : plugins) { try { Resource resource = plugin.make(builder, source, arguments); if (resource != null) { builder.trace("Made " + source + " from args " + arguments + " with " + plugin); return resource; } } catch (Exception e) { builder.error("Plugin " + plugin + " generates error when use in making " + source + " with args " + arguments, e); } } } } return null; }
Instruction i = matches(instructions, pack, null, r.getName()); if (i != null) return !i.isNegated();