org.apache.commons.collections4.iterators.IteratorChain Java Examples

The following examples show how to use org.apache.commons.collections4.iterators.IteratorChain. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentCheckJob.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
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();
}
 
Example #2
Source File: ContentCheckJob.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
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();
}
 
Example #3
Source File: Algebra.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
public Iterable<X> allXs() {
	IteratorChain<X> it = new IteratorChain<>();
	for (En en : schema().ens) {
		it.addIterator(en(en).iterator());
	}
	return new IteratorIterable<>(it, false);
}
 
Example #4
Source File: SkeletonSaturatedInstance.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Iterable<Entry<Integer, En>> gens() {
	IteratorChain<Entry<Integer, En>> r = new IteratorChain<>();
	for (En en : schema().ens) {
		r.addIterator(new UpToF<>(xo(en), xo(en) + xs(en), gen -> Map.entry(gen, en)));
	}
	return new IteratorIterable<>(r, true);
}
 
Example #5
Source File: SkeletonSaturatedInstance.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Iterable<Entry<Integer, Ty>> sks() {
	IteratorChain<Entry<Integer, Ty>> r = new IteratorChain<>();
	for (Ty en : schema().typeSide.tys) {
		r.addIterator(new UpToF<>(yo(en), yo(en) + ys(en), gen -> Map.entry(gen, en)));
	}
	return new IteratorIterable<>(r, true);
}
 
Example #6
Source File: CongruenceProverUniform.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
private void merge1(KBExp<C, V> u, KBExp<C, V> v) {
	T t = this.kb.syms.get(u.f()).second; // u.type(this.kb.syms, Collections.emptyMap());
	UnionFind<KBExp<C, V>> uf = ufs.get(t);
	if (uf.connected(u, v)) {
		return;
	}

	IteratorChain<KBExp<C, V>> lpu = new IteratorChain<>();
	IteratorChain<KBExp<C, V>> lpv = new IteratorChain<>();

	Map<KBExp<C, V>, Set<KBExp<C, V>>> m = pred.get(t);
	for (KBExp<C, V> exp : m.keySet()) {
		Set<KBExp<C, V>> z = null;
		if (uf.connected(u, exp)) {
			z = m.get(exp);
			lpu.addIterator(z.iterator());
		}
		if (uf.connected(v, exp)) {
			if (z == null) {
				z = m.get(exp);
			}
			lpv.addIterator(z.iterator());
		}
	}

	uf.union(u, v);

	IteratorIterable<KBExp<C, V>> qq = new IteratorIterable<>(lpv, true);
	for (KBExp<C, V> x : new IteratorIterable<>(lpu, false)) {
		for (KBExp<C, V> y : qq) {
			if (x.f().equals(y.f())) {
				T tt = kb.syms.get(x.f()).second;
				if (!ufs.get(tt).connected(x, y) && congruent(x, y)) {
					merge1(x, y);
				}
			}
		}
	}
}
 
Example #7
Source File: MySession.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
public Enumeration getAttributeNames()
{
	Set<String> nonPortableAttributeNames = m_nonPortalSession.getAllAttributes().keySet();
	IteratorChain ic = new IteratorChain(m_attributes.keySet().iterator(),nonPortableAttributeNames.iterator());
	return new IteratorEnumeration(ic);
}
 
Example #8
Source File: MySession.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
public Enumeration getAttributeNames()
{
	Set<String> nonPortableAttributeNames = m_nonPortalSession.getAllAttributes().keySet();
	IteratorChain ic = new IteratorChain(m_attributes.keySet().iterator(),nonPortableAttributeNames.iterator());
	return new IteratorEnumeration(ic);
}
 
Example #9
Source File: Thue.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
public Iterable<Pair<ConsList<X>, ConsList<X>>> rules(X y) {
	IteratorChain<Pair<ConsList<X>, ConsList<X>>> chain = new IteratorChain<>();
	chain.addIterator(rs.get(y).iterator());
	chain.addIterator(es1.get(y).iterator());
	return new IteratorIterable<>(chain, false);
}
 
Example #10
Source File: MyLittleSession.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * @inheritDoc
 */
public Enumeration getAttributeNames()
{
	IteratorChain ic = new IteratorChain(m_attributes.keySet().iterator(),m_nonPortalSession.getAllAttributes().keySet().iterator());
	return new IteratorEnumeration(ic);
}
 
Example #11
Source File: MyLittleSession.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * @inheritDoc
 */
public Enumeration getAttributeNames()
{
	IteratorChain ic = new IteratorChain(m_attributes.keySet().iterator(),m_nonPortalSession.getAllAttributes().keySet().iterator());
	return new IteratorEnumeration(ic);
}