List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:com.cyberway.issue.crawler.extractor.JerichoExtractorHTMLTest.java
/** * Test a POST FORM ACTION being found with non-default setting * //from w w w . jav a 2 s . c o m * @throws URIException * @throws ReflectionException * @throws MBeanException * @throws InvalidAttributeValueException * @throws AttributeNotFoundException */ public void testFormsLinkFindPost() throws URIException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { CrawlURI curi = new CrawlURI(UURIFactory.getInstance("http://www.example.org")); CharSequence cs = "<form name=\"testform\" method=\"POST\" action=\"redirect_me?form=true\"> " + " <INPUT TYPE=CHECKBOX NAME=\"checked[]\" VALUE=\"1\" CHECKED> " + " <INPUT TYPE=CHECKBOX NAME=\"unchecked[]\" VALUE=\"1\"> " + " <select name=\"selectBox\">" + " <option value=\"selectedOption\" selected>option1</option>" + " <option value=\"nonselectedOption\">option2</option>" + " </select>" + " <input type=\"submit\" name=\"test\" value=\"Go\">" + "</form>"; this.extractor.setAttribute(new Attribute(ExtractorHTML.ATTR_EXTRACT_ONLY_FORM_GETS, false)); this.extractor.extract(curi, cs); curi.getOutLinks(); assertTrue(CollectionUtils.exists(curi.getOutLinks(), new Predicate() { public boolean evaluate(Object object) { return ((Link) object).getDestination().toString().indexOf( "/redirect_me?form=true&checked[]=1&unchecked[]=&selectBox=selectedOption&test=Go") >= 0; } })); }
From source file:mondrian.olap.IdBatchResolver.java
/** * Filters the children list to those that contain identifiers * we think we can batch resolve, then transforms the Id list * to the corresponding NameSegment.//from ww w .j a v a 2 s . c o m */ private List<Id.NameSegment> collectChildrenNameSegments(final Member parentMember, List<Id> children) { filter(children, new Predicate() { // remove children we can't support public boolean evaluate(Object theId) { Id id = (Id) theId; return !Util.matches(parentMember, id.getSegments()) && supportedIdentifier(id); } }); return new ArrayList(CollectionUtils.collect(children, new Transformer() { // convert the collection to a list of NameSegments public Object transform(Object theId) { Id id = (Id) theId; return getLastSegment(id); } })); }
From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java
public List<TeacherMasterDegreeService> getMasterDegreeServices() { return (List<TeacherMasterDegreeService>) CollectionUtils.select(getServiceItemsSet(), new Predicate() { @Override/*from ww w. j ava 2s .co m*/ public boolean evaluate(Object arg0) { return arg0 instanceof TeacherMasterDegreeService; } }); }
From source file:net.sf.wickedshell.ui.shell.viewer.proposal.CompletionController.java
/** * Identifies all possible enviromental value completion for the given * prefix./*from www . j a v a 2s . c o m*/ * * @return the <code>List</code> of <code>Completions</code> referring * to the given prefix */ @SuppressWarnings("unchecked") public static List getEnviromentalValueCompletions(IShellDescriptor descriptor, final String environmentalValuePrefix, final String command) { List currentEnviromentalValueCompletions = new ArrayList(); CollectionUtils.select(descriptor.getEnviromentalValues().entrySet(), new Predicate() { public boolean evaluate(Object object) { Entry entry = (Entry) object; String enviromentalValue = (String) entry.getKey(); return enviromentalValue.toLowerCase().startsWith(environmentalValuePrefix.toLowerCase()); } }, currentEnviromentalValueCompletions); CollectionUtils.transform(currentEnviromentalValueCompletions, new Transformer() { public Object transform(Object object) { Entry entry = (Entry) object; String completion = command + (String) entry.getKey(); String description = (String) entry.getKey() + " <" + (String) entry.getValue() + "> - Environmental value (Cascading completion)"; String imagePath = "img/environmentalValue.gif"; return ICompletion.Factory.newInstance(completion, description, imagePath); } }); Collections.sort(currentEnviromentalValueCompletions, new CompletionComparator()); return currentEnviromentalValueCompletions; }
From source file:com.projity.pm.graphic.spreadsheet.common.transfer.NodeListTransferHandler.java
public boolean importData(JComponent c, Transferable t) { SpreadSheet spreadSheet = getSpreadSheet(c); if (spreadSheet == null) return false; DataFlavor flavor = getFlavor(t.getTransferDataFlavors()); if (flavor != null) { try {//from w ww . jav a2 s . c o m NodeModel model = ((CommonSpreadSheetModel) spreadSheet.getModel()).getCache().getModel(); Object data = t.getTransferData(flavor); if (data == null) return false; List nodes = null; if (data instanceof ArrayList) { nodes = (List) data; for (Iterator i = nodes.iterator(); i.hasNext();) { Node node = (Node) i.next(); transformSubprojectBranches(node, model.getDataFactory(), new Predicate() { public boolean evaluate(Object arg0) { Node parent = (Node) arg0; //change implementation NormalTask task = new NormalTask(); Task source = ((Task) parent.getImpl()); source.cloneTo(task); //task.setDuration(source.getActualDuration()); parent.setImpl(task); return true; } }); } SpreadSheet.SpreadSheetAction a = getNodeListPasteAction().getSpreadSheetAction(); a.execute(nodes); } else if (data instanceof String) { // ArrayList fields=spreadSheet.getSelectedFields(); // if (fields==null){ // fields=spreadSheet.getSelectableFields(); //The whole line is selected // nodes=NodeListTransferable.stringToNodeList((String)data,spreadSheet,fields,model.getDataFactory()); // }else{ // NodeListTransferable.pasteString((String)data,spreadSheet); // } NodeListTransferable.pasteString((String) data, spreadSheet); } else return false; return true; } catch (UnsupportedFlavorException ufe) { } catch (IOException ioe) { } } return false; }
From source file:module.mailtracking.domain.CorrespondenceEntry.java
public static java.util.List<CorrespondenceEntry> getActiveEntries(final CorrespondenceType type) { java.util.Collection<CorrespondenceEntry> allEntries = Bennu.getInstance().getCorrespondenceEntriesSet(); java.util.List<CorrespondenceEntry> activeEntries = new java.util.ArrayList<CorrespondenceEntry>(); CollectionUtils.select(allEntries, new Predicate() { @Override// w w w.j ava 2s .c o m public boolean evaluate(Object arg0) { CorrespondenceEntry entry = (CorrespondenceEntry) arg0; return CorrespondenceEntryState.ACTIVE.equals(entry.getState()) && (type == null || type.equals(entry.getType())); } }, activeEntries); return activeEntries; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.professorship.CreateProfessorshipDispatchAction.java
private void setChoosedExecutionPeriod(HttpServletRequest request, List executionPeriodsNotClosed, DynaValidatorForm personExecutionCourseForm) { String executionPeriodIdValue = null; try {//from ww w.ja v a 2 s . c om executionPeriodIdValue = (String) personExecutionCourseForm.get("executionPeriodId"); } catch (Exception e) { // do nothing } final String executionPeriodId = executionPeriodIdValue; InfoExecutionPeriod infoExecutionPeriod = null; if (executionPeriodId == null) { infoExecutionPeriod = (InfoExecutionPeriod) CollectionUtils.find(executionPeriodsNotClosed, new Predicate() { @Override public boolean evaluate(Object input) { InfoExecutionPeriod infoExecutionPeriod = (InfoExecutionPeriod) input; return infoExecutionPeriod.getState().equals(PeriodState.CURRENT); } }); } else { infoExecutionPeriod = (InfoExecutionPeriod) CollectionUtils.find(executionPeriodsNotClosed, new Predicate() { @Override public boolean evaluate(Object input) { InfoExecutionPeriod infoExecutionPeriod = (InfoExecutionPeriod) input; return infoExecutionPeriod.getExternalId().equals(executionPeriodId); } }); } request.setAttribute("infoExecutionPeriod", infoExecutionPeriod); }
From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java
public TeacherPastService getPastService() { return (TeacherPastService) CollectionUtils.find(getServiceItemsSet(), new Predicate() { @Override//from www. ja v a 2 s. c om public boolean evaluate(Object arg0) { return arg0 instanceof TeacherPastService; } }); }
From source file:module.siadap.domain.ExceedingQuotaProposal.java
public static List<ExceedingQuotaProposal> getQuotaProposalFor(final Unit unit, final int year, final SiadapUniverse siadapUniverse, final boolean quotasUniverse, final ExceedingQuotaSuggestionType type) { List<ExceedingQuotaProposal> unitProposals = Collections.EMPTY_LIST; SiadapYearConfiguration configuration = SiadapYearConfiguration.getSiadapYearConfiguration(year); if (configuration == null) { return unitProposals; }//w ww . j ava2 s . c o m unitProposals = new ArrayList<ExceedingQuotaProposal>( getQuotaProposalsByPredicate(unit.getExceedingQuotasProposalsSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { ExceedingQuotaProposal exceedingQuotaProposal = (ExceedingQuotaProposal) arg0; if (exceedingQuotaProposal.getSiadapUniverse() == null) { return false; } return (exceedingQuotaProposal.getSiadapUniverse().equals(siadapUniverse) && exceedingQuotaProposal.getWithinOrganizationQuotaUniverse() == quotasUniverse && exceedingQuotaProposal.getUnit().equals(unit) && exceedingQuotaProposal.getYear() == year && exceedingQuotaProposal.getSuggestionType().equals(type)); } })); return unitProposals; }
From source file:net.sourceforge.fenixedu.domain.accounting.events.export.SIBSOutgoingPaymentFile.java
public static List<SIBSOutgoingPaymentFile> readSuccessfulSentPaymentFiles() { List<SIBSOutgoingPaymentFile> files = new ArrayList<SIBSOutgoingPaymentFile>(); CollectionUtils.select(readGeneratedPaymentFiles(), new Predicate() { @Override//from w w w . j a va 2 s. c o m public boolean evaluate(Object arg0) { return ((SIBSOutgoingPaymentFile) arg0).getSuccessfulSentDate() != null; } }, files); return files; }