List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, final Transformer transformer, final Collection outputCollection)
From source file:com.redhat.rhn.domain.monitoring.test.MonitoringTestUtils.java
/** * Return the names of the probe parameters of <code>probe</code> * @param probe the probe/*from w w w . ja va2 s . c o m*/ * @return the names of the probe parameters */ public static Set parameterNameSet(Probe probe) { Set ppvSet = probe.getProbeParameterValues(); assert ppvSet != null && ppvSet.size() > 0; Transformer transform = new ProbeParameterToName(); return (Set) CollectionUtils.collect(ppvSet, transform, new HashSet()); }
From source file:com.redhat.rhn.domain.monitoring.test.MonitoringTestUtils.java
/** * Return the names of the parameters of <code>command</code> * @param command the command/*from ww w. ja va2 s . c o m*/ * @return the names of the parameters of <code>command</code> */ public static Set parameterNameSet(Command command) { Set cps = command.getCommandParameters(); Transformer transform = new CommandParameterToName(); return (Set) CollectionUtils.collect(cps, transform, new HashSet()); }
From source file:net.sf.wickedshell.domain.configuration.ShellDescriptorPropertiesDao.java
/** * Returns the <code>List</code> of * <code>IShellDescriptorProperties</code> stored as shell descriptor * configuration in the <i>StateLocation</i>. First checks whether the * corresponding XML-File exists. If not an empty one is created. * //from w w w . j av a2 s .com * @return the <code>List</code> of <code>CommandDescriptor</code> * @throws IOException * if creating/parsing the file fails */ @SuppressWarnings("unchecked") public List<IShellDescriptorProperties> readShellDescriptorProperties() throws IOException, XmlException { String stateLocation = DomainPlugin.getDefault().getStateLocation().toOSString(); File shelldescriptorConfigurationDocumentFile = new File(stateLocation, DomainID.SHELL_DESCRIPTOR_CONFIGURATION_FILE); if (!shelldescriptorConfigurationDocumentFile.exists()) { writeDefaultShellDescriptorProperties(); } ShellDescriptorConfigurationDocument shellDescriptorConfigurationDocument = ShellDescriptorConfigurationDocument.Factory .parse(shelldescriptorConfigurationDocumentFile); return (List) CollectionUtils.collect(Arrays.asList(shellDescriptorConfigurationDocument .getShellDescriptorConfiguration().getShellDescriptorPropertiesArray()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { return IShellDescriptorProperties.Factory.newInstance((ShellDescriptorProperties) object); } }, new ArrayList()); }
From source file:net.sf.wickedshell.domain.batch.BatchFileDescriptorDao.java
/** * Returns the <code>List</code> of <code>IBatchFileDescriptor</code> stored in the * <i>StateLocation</i>. First checks whether the corresponding XML-File exists. If not an empty * one is created.//from ww w. j a v a2 s. c o m * * @return the <code>List</code> of <code>IBatchFileDescriptor</code> * @throws IOException * if creating/parsing the file fails */ @SuppressWarnings("unchecked") public List<IBatchFileDescriptor> readBatchFileDescriptors() throws IOException, XmlException { BatchFileDescriptorListDocument batchFileDescriptorListDocument; String stateLocation = DomainPlugin.getDefault().getStateLocation().toOSString(); File batchFileDescriptorListDocumentFile = new File(stateLocation, DomainID.BATCH_FILES_FILE); if (!batchFileDescriptorListDocumentFile.exists()) { batchFileDescriptorListDocument = BatchFileDescriptorListDocument.Factory.newInstance(); batchFileDescriptorListDocument.addNewBatchFileDescriptorList(); batchFileDescriptorListDocument.save(batchFileDescriptorListDocumentFile); } else { batchFileDescriptorListDocument = BatchFileDescriptorListDocument.Factory .parse(batchFileDescriptorListDocumentFile); } return (List<IBatchFileDescriptor>) CollectionUtils.collect( Arrays.asList( batchFileDescriptorListDocument.getBatchFileDescriptorList().getBatchFileDescriptorArray()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { return IBatchFileDescriptor.Factory.newInstance((BatchFileDescriptor) object); } }, new ArrayList()); }
From source file:net.sf.wickedshell.domain.command.CommandDescriptorDao.java
/** * Returns the <code>List</code> of <code>CommandDescriptor</code> * stored as command history in the <i>StateLocation</i>. First checks * whether the corresponding XML-File exists. If not an empty one is * created./*w w w .j a v a 2 s . c o m*/ * * @return the <code>List</code> of <code>CommandDescriptor</code> * @throws IOException * if creating/parsing the file fails */ @SuppressWarnings("unchecked") public List<ICommandDescriptor> readCommandHistory() throws IOException, XmlException { CommandHistoryListDocument commandHistoryListDocument; String stateLocation = DomainPlugin.getDefault().getStateLocation().toOSString(); File commandFileDescriptorListDocumentFile = new File(stateLocation, DomainID.COMMAND_HISTORY_FILE); if (!commandFileDescriptorListDocumentFile.exists()) { commandHistoryListDocument = CommandHistoryListDocument.Factory.newInstance(); commandHistoryListDocument.addNewCommandHistoryList(); commandHistoryListDocument.save(commandFileDescriptorListDocumentFile); } else { commandHistoryListDocument = CommandHistoryListDocument.Factory .parse(commandFileDescriptorListDocumentFile); } return (List<ICommandDescriptor>) CollectionUtils.collect( Arrays.asList(commandHistoryListDocument.getCommandHistoryList().getCommandDescriptorArray()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { return ICommandDescriptor.Factory.newInstance((CommandDescriptor) object); } }, new ArrayList()); }
From source file:net.sf.wickedshell.domain.xmlShellDescriptor.XMLShellDescriptorDao.java
/** * Returns the <code>List</code> of <code>IXMLShellDescriptors</code> * stored as command history in the <i>StateLocation</i>. First checks * whether the corresponding XML-File exists. If not an empty one is * created./*from w w w. j ava 2s . c om*/ * * @return the <code>List</code> of <code>IXMLShellDescriptors</code> * @throws IOException * if creating/parsing the file fails */ @SuppressWarnings("unchecked") public List<IXMLShellDescriptor> readXMLShellDescriptors() throws IOException, XmlException { XmlShellDescriptorListDocument xmlShellDescriptorListDocument; String stateLocation = DomainPlugin.getDefault().getStateLocation().toOSString(); File xmlShellDescriptorListDocumentFile = new File(stateLocation, DomainID.XML_SHELL_DESCRIPTORS_FILE); if (!xmlShellDescriptorListDocumentFile.exists()) { xmlShellDescriptorListDocument = XmlShellDescriptorListDocument.Factory.newInstance(); xmlShellDescriptorListDocument.addNewXmlShellDescriptorList(); xmlShellDescriptorListDocument.save(xmlShellDescriptorListDocumentFile); } else { xmlShellDescriptorListDocument = XmlShellDescriptorListDocument.Factory .parse(xmlShellDescriptorListDocumentFile); } return (List) CollectionUtils.collect( Arrays.asList( xmlShellDescriptorListDocument.getXmlShellDescriptorList().getXmlShellDescriptorArray()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { return IXMLShellDescriptor.Factory.newInstance((XmlShellDescriptor) object); } }, new ArrayList()); }
From source file:net.sf.wickedshell.domain.completion.CompletionDao.java
/** * Returns the <code>List</code> of <code>ICompletions</code> stored in * the <i>StateLocation</i>. First checks whether the corresponding * XML-File exists. If not an empty one is created. * /*from www .j ava 2 s .co m*/ * @return the <code>List</code> of <code>ICompletions</code> * @throws IOException * if creating/parsing the file fails */ @SuppressWarnings("unchecked") public List<ICompletion> readCompletions(File staticCompletionListDocumentFile) throws IOException, XmlException { if (!staticCompletionListDocumentFile.exists()) { writeDefaultCompletions(); } StaticCompletionListDocument staticCompletionListDocument = StaticCompletionListDocument.Factory .parse(staticCompletionListDocumentFile); return (List) CollectionUtils.collect( Arrays.asList(staticCompletionListDocument.getStaticCompletionList().getStaticCompletionArray()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { return ICompletion.Factory.newInstance((StaticCompletion) object); } }, new ArrayList()); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.coordinator.ReadDegreeCurricularPlanBaseService.java
protected List<InfoCurricularCourseScope> readActiveCurricularCourseScopes( final String degreeCurricularPlanId) { List<InfoCurricularCourseScope> infoActiveScopes = null; if (degreeCurricularPlanId != null) { DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanId); List<CurricularCourseScope> allActiveScopes = degreeCurricularPlan.getActiveCurricularCourseScopes(); if (allActiveScopes != null && allActiveScopes.size() > 0) { infoActiveScopes = new ArrayList<InfoCurricularCourseScope>(); CollectionUtils.collect(allActiveScopes, new Transformer() { @Override//from w ww . j ava 2 s.c o m public Object transform(Object input) { CurricularCourseScope curricularCourseScope = (CurricularCourseScope) input; return InfoCurricularCourseScope.newInfoFromDomain(curricularCourseScope); } }, infoActiveScopes); } } return infoActiveScopes; }
From source file:com.clican.pluto.cms.ui.action.model.TemplateAction.java
public void configureTemplateAndSite(IDataModel dataModel) { this.dataModel = dataModel; selectedIdPairs = templateService.getTemplateSiteIdPairs(dataModel); allTemplateList = new ArrayList<String>(); allSiteList = new ArrayList<String>(); CollectionUtils.collect(templateService.getAllTemplates(), new SelectItem2StringTransfer(), allTemplateList);/*from www.j a v a2s . c o m*/ CollectionUtils.collect(siteService.getAllSites(), new SelectItem2StringTransfer(), allSiteList); }
From source file:net.sf.wickedshell.facade.descriptor.XMLShellDescriptor.java
/** * @see net.sf.wickedshell.facade.descriptor.IShellDescriptor#getExecutableFiles(boolean) *//* w ww. j av a2 s . com*/ @SuppressWarnings("unchecked") public IExecutableFile[] getExecutableFiles(boolean batchFileOnly) { List executableFiles = new ArrayList(); CollectionUtils.collect(Arrays.asList(adaptedDescriptor.getExecutableBatchFiles()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { String executableFile = (String) object; return IExecutableFile.Factory.newInstance("Excutable Batch File", executableFile, true); } }, executableFiles); if (!batchFileOnly) { CollectionUtils.collect(Arrays.asList(adaptedDescriptor.getExecutableFiles()), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object object) { String executableFile = (String) object; return IExecutableFile.Factory.newInstance("Excutable File", executableFile, false); } }, executableFiles); } return (IExecutableFile[]) executableFiles.toArray(new IExecutableFile[0]); }