public boolean include(T object) { if (filters.isEmpty()) { return true; } for (Filter<T> filter : filters) { if (filter.include(object)) { return true; } } return false; } }
public boolean include(T object) { if (filters.isEmpty()) { return true; } for (Filter<T> filter : filters) { if (!filter.include(object)) { return false; } } return true; } }
public boolean include(T object) { if (filters.isEmpty()) { return true; } for (Filter<T> filter : filters) { if (!filter.include(object)) { return false; } } return true; } }
public boolean include(T object) { if (filters.isEmpty()) { return true; } for (Filter<T> filter : filters) { if (filter.include(object)) { return true; } } return false; } }
/** * This method searches a given directory recursively for resource files. * * @param directory * is the directory to be searched for resource files. * @param filter * is a {@link Filter} to be applied to all found files to * recognize resource files. * @return A list of {@link File} is returned containing all as resource * recognized files. */ static List<File> findResourcesRecursively(File directory, Filter<File> filter) { List<File> resources = new ArrayList<File>(); Collection<File> files = FileUtils.listFiles(directory, null, true); for (File file : files) { if (filter == null || filter.include(file)) { resources.add(file); } } return resources; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#getContent(org.jboss.shrinkwrap.api.Filter) */ @Override public Map<ArchivePath, Node> getContent(Filter<ArchivePath> filter) { Validate.notNull(filter, "Filter must be specified"); Map<ArchivePath, Node> filteredContent = new LinkedHashMap<ArchivePath, Node>(); for (Map.Entry<ArchivePath, NodeImpl> contentEntry : content.entrySet()) { if (filter.include(contentEntry.getKey())) { if (!contentEntry.getKey().equals(new BasicPath("/"))) { filteredContent.put(contentEntry.getKey(), contentEntry.getValue()); } } } return filteredContent; }
@Override public boolean include(final ArchivePath archivePath) { if (!delegate.include(archivePath)) { return false; } if (archivePath.get().contains("shiro.ini")) { paths.put(archivePath, addArquillianServletInUrls(archivePath)); return false; } return true; }
@Override public boolean include(final ArchivePath archivePath) { if (!delegate.include(archivePath)) { return false; } if (archivePath.get().contains("shiro.ini")) { paths.put(archivePath, addArquillianServletInUrls(archivePath)); return false; } return true; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#getContent(org.jboss.shrinkwrap.api.Filter) */ @Override public Map<ArchivePath, Node> getContent(Filter<ArchivePath> filter) { Validate.notNull(filter, "Filter must be specified"); Map<ArchivePath, Node> filteredContent = new LinkedHashMap<ArchivePath, Node>(); for (Map.Entry<ArchivePath, NodeImpl> contentEntry : content.entrySet()) { if (filter.include(contentEntry.getKey())) { if (!contentEntry.getKey().equals(new BasicPath("/"))) { filteredContent.put(contentEntry.getKey(), contentEntry.getValue()); } } } return filteredContent; }
private <T> List<T> executeFilter(Class<T> clazz, List<T> items, Filter<T> filter) { List<T> result = new ArrayList<T>(); for (T item : items) { if (filter.include(item)) { result.add(item); } } return result; } }
private void doImport(File root, File[] files, Filter<ArchivePath> filter) { for (File file : files) { if (log.isLoggable(Level.FINER)) { log.finer("Importing: " + file.getAbsolutePath()); } final Archive<?> archive = this.getArchive(); final ArchivePath path = calculatePath(root, file); if( filter.include(path) ) { if (file.isDirectory()) { archive.addAsDirectory(path); doImport(root, file.listFiles(), filter); } else { archive.add(new FileAsset(file), path); } } } }
private void doImport(File root, File[] files, Filter<ArchivePath> filter) { for (File file : files) { if (log.isLoggable(Level.FINER)) { log.finer("Importing: " + file.getAbsolutePath()); } final Archive<?> archive = this.getArchive(); final ArchivePath path = calculatePath(root, file); if( filter.include(path) ) { if (file.isDirectory()) { archive.addAsDirectory(path); doImport(root, file.listFiles(), filter); } else { archive.add(new FileAsset(file), path); } } } }
@Override public void classFound(String className, Asset asset) { ArchivePath classNamePath = AssetUtil.getFullPathForClassResource(className); if (!filter.include(classNamePath)) { return; } ArchivePath location = new BasicPath(getClassesPath(), classNamePath); delete(location); } };
@Override public void classFound(String className, Asset asset) { ArchivePath classNamePath = AssetUtil.getFullPathForClassResource(className); if (!filter.include(classNamePath)) { return; } //Asset asset = new ClassLoaderAsset(classNamePath.get().substring(1), classLoader); ArchivePath location = new BasicPath(getClassesPath(), classNamePath); add(asset, location); } };
@Override public void classFound(String className, Asset asset) { ArchivePath classNamePath = AssetUtil.getFullPathForClassResource(className); if (!filter.include(classNamePath)) { return; } //Asset asset = new ClassLoaderAsset(classNamePath.get().substring(1), classLoader); ArchivePath location = new BasicPath(getClassesPath(), classNamePath); add(asset, location); } };
@Override public void classFound(String className, Asset asset) { ArchivePath classNamePath = AssetUtil.getFullPathForClassResource(className); if (!filter.include(classNamePath)) { return; } ArchivePath location = new BasicPath(getClassesPath(), classNamePath); delete(location); } };
private ZipImporter importFrom(final ZipFile file, Filter<ArchivePath> filter) throws ArchiveImportException { Validate.notNull(file, "File must be specified"); try { Enumeration<? extends ZipEntry> entries = file.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); // Get the entry (path) name final String entryName = entry.getName(); if(!filter.include(ArchivePaths.create(entryName))) { continue; } // Get the archive final Archive<?> archive = this.getArchive(); // Handle directories separately if (entry.isDirectory()) { archive.addAsDirectory(entryName); continue; } archive.add(new ZipFileEntryAsset(file, entry), new BasicPath(entryName)); } } catch (Exception e) { throw new ArchiveImportException("Could not import file", e); } return this; } }
final Node node = contentEntry.getValue(); ArchivePath nodePath = new BasicPath(path, contentEntry.getKey()); if (!filter.include(nodePath)) { continue;
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#shallowCopy(Filter) */ @Override public Archive<T> shallowCopy(Filter<ArchivePath> filter) { Validate.notNull(filter, "Filter must be specified"); // Get the actual class type and make a shallow copy of the the underlying archive, // using the same underlying configuration final Class<T> actualClass = this.getActualClass(); final Archive<?> underlyingArchive = this.getArchive(); final Configuration existingConfig = ((Configurable) underlyingArchive).getConfiguration(); final Domain domain = ShrinkWrap.createDomain(existingConfig); final ArchiveFactory factory = domain.getArchiveFactory(); final Archive<T> newArchive = factory.create(actualClass, this.getName()); final Map<ArchivePath, Node> contents = underlyingArchive.getContent(); for (final ArchivePath path : contents.keySet()) { Asset asset = contents.get(path).getAsset(); if (asset != null) { if(!filter.include(path)) { continue; } newArchive.add(asset, path); } } return newArchive; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#shallowCopy(Filter) */ @Override public Archive<T> shallowCopy(Filter<ArchivePath> filter) { Validate.notNull(filter, "Filter must be specified"); // Get the actual class type and make a shallow copy of the the underlying archive, // using the same underlying configuration final Class<T> actualClass = this.getActualClass(); final Archive<?> underlyingArchive = this.getArchive(); final Configuration existingConfig = ((Configurable) underlyingArchive).getConfiguration(); final Domain domain = ShrinkWrap.createDomain(existingConfig); final ArchiveFactory factory = domain.getArchiveFactory(); final Archive<T> newArchive = factory.create(actualClass, this.getName()); final Map<ArchivePath, Node> contents = underlyingArchive.getContent(); for (final ArchivePath path : contents.keySet()) { Asset asset = contents.get(path).getAsset(); if (asset != null) { if(!filter.include(path)) { continue; } newArchive.add(asset, path); } } return newArchive; }