List of usage examples for org.apache.commons.collections Transformer Transformer
Transformer
From source file:com.redhat.rhn.domain.monitoring.Probe.java
/** * Return a transformer that maps command parameters to their values in this * probe.//from w w w . j av a2 s. c o m * @return a transformer that maps command parameters to their values in this * probe. */ public Transformer toValue() { return new Transformer() { public Object transform(Object input) { return getProbeParameterValue(((CommandParameter) input)).getValue(); } }; }
From source file:info.magnolia.cms.util.ContentUtilTest.java
@Test public void testOrderBeforeFirstNodeVariation4() throws RepositoryException, IOException { MockHierarchyManager hm = MockUtil.createHierarchyManager( "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n"); Content node = hm.getContent("/node"); Content c = node.getContent("f"); ContentUtil.orderBefore(c, "a"); Collection<Content> result = node.getChildren(); CollectionUtils.transform(result, new Transformer() { @Override/*w w w .ja v a 2s . c om*/ public Object transform(Object childObj) { return ((Content) childObj).getName(); } }); assertEquals(asList("f", "a", "b", "c", "d", "e"), result); }
From source file:de.tudarmstadt.lt.lm.lucenebased.CountingStringLM.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a va 2 s. com*/ public Iterator<List<Integer>> getNgramIdIterator() { return IteratorUtils.transformedIterator(getNgramIterator(), new Transformer() { @Override public Object transform(Object ngram) { return getNgramAsIds((List<String>) ngram); } }); }
From source file:flex2.compiler.mxml.rep.Model.java
public String getEffectNames() { Iterator eventNameIter = new TransformIterator(getEffectInitializerIterator(), new Transformer() { public Object transform(Object object) { return TextGen.quoteWord(((EffectInitializer) object).getName()); }//from w w w . ja va 2s. c o m }); return TextGen.toCommaList(eventNameIter); }
From source file:info.magnolia.cms.util.ContentUtilTest.java
@Test public void testOrderBeforeLastNodeVariation1() throws RepositoryException, IOException { MockHierarchyManager hm = MockUtil.createHierarchyManager( "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n"); Content node = hm.getContent("/node"); Content c = node.getContent("a"); ContentUtil.orderBefore(c, "f"); Collection<Content> result = node.getChildren(); CollectionUtils.transform(result, new Transformer() { @Override/*www . ja v a 2 s . c om*/ public Object transform(Object childObj) { return ((Content) childObj).getName(); } }); assertEquals(asList("b", "c", "d", "e", "a", "f"), result); }
From source file:edu.northwestern.bioinformatics.studycalendar.service.StudySiteService.java
@SuppressWarnings({ "unchecked" }) private List<Site> collectSites(List<StudySite> in) { return new ArrayList<Site>(collect(in, new Transformer() { public Object transform(Object o) { if (o instanceof StudySite) { return ((StudySite) o).getSite(); }/*from w ww . ja va2 s.c o m*/ return null; } })); }
From source file:flex2.compiler.mxml.rep.Model.java
public String getEffectEventNames() { Iterator eventNameIter = new TransformIterator(getEffectInitializerIterator(), new Transformer() { public Object transform(Object object) { return TextGen.quoteWord(((EffectInitializer) object).getEventName()); }/*from w ww . j a v a 2 s. com*/ }); return TextGen.toCommaList(eventNameIter); }
From source file:com.mulesoft.mule.cassandradb.CassandraDBUtils.java
/** * Utility method to convert a List of IndexExpression of type String to List of IndexExpression of type ByteBuffer. * * @param list List of IndexExpression.//from w ww .j a va2 s .c om * @return ByteBuffer type of IndexExpression List. */ @SuppressWarnings("unchecked") public static List<IndexExpression> toIndexExpression(List<IndexExpresion> list) { return (List<IndexExpression>) CollectionUtils.collect((List) list, new Transformer() { @Override public Object transform(Object input) { IndexExpresion sExp = (IndexExpresion) input; IndexExpression exp = new IndexExpression(); exp.setColumn_name(CassandraDBUtils.toByteBuffer(sExp.getColumnName())); exp.setOp(sExp.getOp()); exp.setValue(CassandraDBUtils.toByteBuffer(sExp.getValue())); return exp; } }); }
From source file:info.magnolia.cms.util.ContentUtilTest.java
@Test public void testOrderBeforeLastNodeVariation2() throws RepositoryException, IOException { MockHierarchyManager hm = MockUtil.createHierarchyManager( "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n"); Content node = hm.getContent("/node"); Content c = node.getContent("c"); ContentUtil.orderBefore(c, "f"); Collection<Content> result = node.getChildren(); CollectionUtils.transform(result, new Transformer() { @Override/* ww w. j ava 2 s . c o m*/ public Object transform(Object childObj) { return ((Content) childObj).getName(); } }); assertEquals(asList("a", "b", "d", "e", "c", "f"), result); }
From source file:com.alkacon.opencms.v8.comments.CmsCommentsAccess.java
/** * Returns the number of comments a given author has written.<p> * //from w ww .j a va 2s . c o m * To use this method you have to define a field called {@link CmsCommentFormHandler#FIELD_USERNAME}.<p> * * @return a map where the key is the author name and the value the number of comments */ @SuppressWarnings("unchecked") public Map<String, Integer> getCountByAuthor() { if (m_countByAuthor == null) { m_countByAuthor = LazyMap.decorate(new HashMap<String, Integer>(), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String author = String.valueOf(input); CmsFormDatabaseFilter filter = CmsFormDatabaseFilter.HEADERS; filter = filter.filterFormId(CmsCommentForm.FORM_ID); filter = filter.filterResourceId(getResource().getStructureId()); filter = filter.filterField(CmsCommentFormHandler.FIELD_USERNAME, author); try { return new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } return new Integer(0); } }); } return m_countByAuthor; }