public Iterable<PE> unorderedIterable() { return new Iterable<PE>() { @Override public Iterator<PE> iterator() { return new Iterator<PE>() { final private IteratorChain chain = new IteratorChain(); { // initialize the chain with the unordered iterators of the per sample pileups for ( PileupElementTracker<PE> pet : pileup.values() ) { chain.addIterator(pet.unorderedIterator()); } } @Override public boolean hasNext() { return chain.hasNext(); } @Override public PE next() { return (PE)chain.next(); } @Override public void remove() { throw new UnsupportedOperationException("Cannot remove"); } }; } }; }
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { MessageDigest digest; try { digest = MessageDigest.getInstance(ALGORITHM); } catch (NoSuchAlgorithmException e) { throw new JobExecutionException("Can't get digest for "+ ALGORITHM); } String[] types = { ResourceType.TYPE_HTML, ResourceType.MIME_TYPE_TEXT, ResourceType.TYPE_UPLOAD }; IteratorChain allFiles = new IteratorChain(); for (String type : types) { Iterator<ContentResource> resourceIterator = new ContentHostingIterator<ContentResource>(type); allFiles.addIterator(resourceIterator); } // Now check all the files. ContentResourceChecker checker = new ContentResourceChecker(allFiles, digest); checker.check(); }
public Iterator toIterator() { switch (size()) { case 0: return Collections.emptyList().iterator(); case 1: return get(0); default: return new IteratorChain(this); } }
/** * */ public final Iterator<Initializer> getNonStagePropertyInitializerIterator() { return new FilterIterator(new IteratorChain(root.getPropertyInitializerIterator(false), getTopLevelInitializerIterator()), new Predicate() { public boolean evaluate(Object object) { if (object instanceof NamedInitializer) return (!StandardDefs.isStageProperty(((NamedInitializer)object).getName())) && (!((NamedInitializer)object).isDesignLayer()); return true; } }); }
/** * */ public final Iterator<Initializer> getStagePropertyInitializerIterator() { return new FilterIterator(new IteratorChain(root.getPropertyInitializerIterator(false), getTopLevelInitializerIterator()), new Predicate() { public boolean evaluate(Object object) { if (object instanceof NamedInitializer) return StandardDefs.isStageProperty(((NamedInitializer)object).getName()); return false; } }); }
/** * a little trickiness here: we need to initialize both our superclass properties, and document variables that * have initializers */ public final Iterator<Initializer> getPropertyInitializerIterator() { return new IteratorChain(root.getPropertyInitializerIterator(false), getTopLevelInitializerIterator()); }
@Override public void init() throws MessagingException { super.init(); sieveMailet = new SieveMailet(); sieveMailet.setUsersRepository(usersRepository); sieveMailet.setMailboxManager(mailboxManager); sieveMailet.setFileSystem(fileSystem); sieveMailet.init(new MailetConfig() { /* * @see org.apache.mailet.MailetConfig#getInitParameter(java.lang.String) */ public String getInitParameter(String name) { if ("addDeliveryHeader".equals(name)) { return "Delivered-To"; } else if ("resetReturnPath".equals(name)) { return "true"; } else { return getMailetConfig().getInitParameter(name); } } /* * @see org.apache.mailet.MailetConfig#getInitParameterNames() */ public Iterator<String> getInitParameterNames() { IteratorChain c = new IteratorChain(); Collection<String> h = new ArrayList<String>(); h.add("addDeliveryHeader"); h.add("resetReturnPath"); c.addIterator(getMailetConfig().getInitParameterNames()); c.addIterator(h.iterator()); return c; } /* * @see org.apache.mailet.MailetConfig#getMailetContext() */ public MailetContext getMailetContext() { return getMailetConfig().getMailetContext(); } /* * @see org.apache.mailet.MailetConfig#getMailetName() */ public String getMailetName() { return getMailetConfig().getMailetName(); } }); // Override the default value of "quiet" sieveMailet.setQuiet(getInitParameter("quiet", true)); sieveMailet.setFolder(getInitParameter("folder", "INBOX")); }
/** * @see org.apache.mailet.base.GenericMailet#init() */ public void init() throws MessagingException { super.init(); recipientRewriteTable = new RecipientRewriteTable(); recipientRewriteTable.setDomainList(domainList); recipientRewriteTable.setRecipientRewriteTable(rrt); recipientRewriteTable.init(getMailetConfig()); sieveMailet = new SieveMailet(); sieveMailet.setUsersRepository(usersRepository); sieveMailet.setMailboxManager(mailboxManager); sieveMailet.setFileSystem(fileSystem); sieveMailet.init(new MailetConfig() { /* * @see org.apache.mailet.MailetConfig#getInitParameter(java.lang.String) */ public String getInitParameter(String name) { if ("addDeliveryHeader".equals(name)) { return "Delivered-To"; } else if ("resetReturnPath".equals(name)) { return "true"; } else { return getMailetConfig().getInitParameter(name); } } /* * @see org.apache.mailet.MailetConfig#getInitParameterNames() */ public Iterator<String> getInitParameterNames() { IteratorChain c = new IteratorChain(); Collection<String> h = new ArrayList<String>(); h.add("addDeliveryHeader"); h.add("resetReturnPath"); c.addIterator(getMailetConfig().getInitParameterNames()); c.addIterator(h.iterator()); return c; } /* * @see org.apache.mailet.MailetConfig#getMailetContext() */ public MailetContext getMailetContext() { return getMailetConfig().getMailetContext(); } /* * @see org.apache.mailet.MailetConfig#getMailetName() */ public String getMailetName() { return getMailetConfig().getMailetName(); } }); // Override the default value of "quiet" sieveMailet.setQuiet(getInitParameter("quiet", true)); sieveMailet.setFolder("INBOX"); }
/** * Returns an iterator for the concatenation of <code>iterator1</code> and * <code>iterator2</code>. * * @param <T> * @param iterator1 * @param iterator2 * @return */ @SuppressWarnings("unchecked") public static <T> Iterator<T> iteratorChain(Iterator<? extends T> iterator1, Iterator<? extends T> iterator2) { return new IteratorChain(iterator1, iterator2); }
/** * Returns an iterator for the concatenation of all the given <code>iterators</code>. * * @param <T> * @param iterators * @return */ @SuppressWarnings("unchecked") public static <T> Iterator<T> iteratorChain(Iterator<? extends T>[] iterators) { return new IteratorChain(iterators); }
/** * Returns an iterator for the concatenation of all the given <code>iterators</code>. * * @param <T> * @param iterators * @return */ @SuppressWarnings("unchecked") public static <T> Iterator<T> iteratorChain(Collection<? extends T> iterators) { return new IteratorChain(iterators); }