List of usage examples for org.apache.commons.lang ArrayUtils contains
public static boolean contains(boolean[] array, boolean valueToFind)
Checks if the value is in the given array.
From source file:com.activecq.samples.eventhandlers.impl.SampleEventHandler.java
@Override public void handleEvent(Event event) { boolean handleLocally = false; boolean handleWithMaster = !handleLocally; for (String name : event.getPropertyNames()) { log.debug("{} : {}", name, event.getProperty(name)); }//from w w w . j a v a 2 s . c o m if (!ArrayUtils.contains(event.getPropertyNames(), EventUtil.PROPERTY_DISTRIBUTE)) { // This is the check for a distributed event or not; if this property does not exist, it usually // means that this event handler should process the job, as no other event handlers // will see this event. JobUtil.processJob(event, this); } else if (handleLocally && EventUtil.isLocal(event)) { // This is a distributed event (first 'if' condition failed) // If this server created the event // then only this server should process the event // This will call this's process(..) method, passing in the event obj // JobUtil.processJob(..) sends/checks for an ack for this job // Jobs guarantee the event will be processed (though doesnt guarentee the job will be processed SUCCESSFULLY) JobUtil.processJob(event, this); } else if (handleWithMaster && this.isMaster) { // This is a distributed event (first 'if' condition failed) // If a event is distributed, you may only want to execute it the Master node in // the cluster. JobUtil.processJob(event, this); } else { // DO NOTHING! } }
From source file:com.adobe.acs.samples.events.impl.SampleSlingEventHandler.java
@Override public void handleEvent(final Event event) { boolean handleLocally = false; boolean handleWithLeader = !handleLocally; /**//w w w . j av a 2 s . c o m * Sling Event Properties - VERY handy * * This aren't guaranteed to have non-null values; so check before using. */ // Resource path "undergoing" the event event.getProperty(SlingConstants.PROPERTY_PATH); // Resource type event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE); // Resource super type event.getProperty(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE); // Properties names that were added/changes/removed event.getProperty(SlingConstants.PROPERTY_ADDED_ATTRIBUTES); event.getProperty(SlingConstants.PROPERTY_CHANGED_ATTRIBUTES); event.getProperty(SlingConstants.PROPERTY_REMOVED_ATTRIBUTES); // User id event.getProperty(SlingConstants.PROPERTY_USERID); if (!ArrayUtils.contains(event.getPropertyNames(), EventUtil.PROPERTY_DISTRIBUTE)) { // This is the check for a distributed event or not; if this property does not exist, it usually // means that this event handler should process the job, as no other event handlers // will see this event. // There must be a JobConsumer registered for this Topic jobManager.addJob("com/adobe/acs/samples/sample-job", new HashMap<String, Object>()); } else if (handleLocally && EventUtil.isLocal(event)) { // This is a distributed event (first 'if' condition failed) // If this server created the event // then only this server should process the event // This will call this's process(..) method, passing in the event obj // JobUtil.processJob(..) sends/checks for an ack for this job // Jobs guarantee the event will be processed (though doesn't guarantee the job will be // processed SUCCESSFULLY) // There must be a JobConsumer registered for this Topic jobManager.addJob("com/adobe/acs/samples/sample-job", new HashMap<String, Object>()); } else if (handleWithLeader && this.isLeader) { // This is a distributed event (first 'if' condition failed) // If a event is distributed, you may only want to execute it the Leader node in // the cluster. // There must be a JobConsumer registered for this Topic jobManager.addJob("com/adobe/acs/samples/sample-job", new HashMap<String, Object>()); } else { // DO NOTHING! } }
From source file:com.activecq.samples.contentfinder.impl.viewhandler.QueryBuilderViewHandler.java
/** * Assume query should be treated as a QueryBuilder query, rather than a GQL query * <p/>/*from w ww . j ava 2 s. c om*/ * This intelligently converts default Fulltext and Limit parameters to QueryBuilder equivalents * * @param request * @param queryString * @return */ private Map<String, String> getQueryBuilderParams(final SlingHttpServletRequest request, final String queryString) { Map<String, String> map = new LinkedHashMap<String, String>(); for (final String key : (Set<String>) request.getParameterMap().keySet()) { // Skip known content finder parameters that are unused for QueryBuilder if (!ArrayUtils.contains(ContentFinderConstants.QUERYBUILDER_BLACKLIST, key)) { map.put(key, request.getParameter(key)); } else { log.debug("Rejecting property [ {} ] due to blacklist match", key); } } map = GQLToQueryBuilderConverter.addFulltext(request, map, queryString); map = GQLToQueryBuilderConverter.addLimitAndOffset(request, map); return map; }
From source file:net.navasoft.madcoin.backend.services.WorkRequestQueryFilter.java
/** * Choose filter./* w ww . j a v a2 s . c om*/ * * @param entryVO * the entry vo * @return the generic filter * @since 27/07/2014, 06:48:16 PM */ @Override public GenericFilter<WorkRequestQueryVO> chooseFilter(WorkRequestQueryVO entryVO) { GenericFilter<WorkRequestQueryVO> selector = null; Method[] accessors = WorkRequestQueryVO.class.getMethods(); try { accessors = (Method[]) ArrayUtils.removeElement(accessors, WorkRequestQueryVO.class.getMethod("getClass", ArrayUtils.EMPTY_CLASS_ARRAY)); } catch (NoSuchMethodException e1) { e1.printStackTrace(); } catch (SecurityException e1) { e1.printStackTrace(); } try { if (entryVO != null) { for (Method beanGetters : accessors) { if (beanGetters.getName().startsWith("get")) { Object fieldValue; fieldValue = beanGetters.invoke(entryVO, ArrayUtils.EMPTY_OBJECT_ARRAY); if (fieldValue != null) { String fieldToFilter = beanGetters.getName().replace("get", ""); EFilters guessedFilters = null; if (ArrayUtils.contains(mandatory, fieldToFilter)) { guessedFilters = EFilters.valueOf(fieldToFilter.toUpperCase() + "_FILTER"); } else { if (guessedFilters == null) { guessedFilters = optionalCorrelation.get(fieldToFilter); } } selector = (GenericFilter<WorkRequestQueryVO>) Class .forName(guessedFilters.getImplementingClass()).getConstructor(EFilters.class) .newInstance(guessedFilters); } } } if (selector == null) { selector = WorkRequestNoFilter.class.newInstance(); } else { selector.setScope(entryVO); } return selector; } else { selector = WorkRequestNoFilter.class.newInstance(); } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return selector; }
From source file:jef.tools.string.StringSpliter.java
/** * ???key/*from w w w. j a va2 s.c o m*/ * @param chars * @return */ public boolean expandKeyRight(char[] chars) { boolean res = false; if (keyword == null) return res; Substring right = getRight(); while (right.firstCharacter() != null && ArrayUtils.contains(chars, right.firstCharacter().charValue())) { right.setStart(right.getStart() + 1); res = true; } if (res) this.keyword = source.subAbsoultOffset(keyword.getStart(), right.getStart()); return res; }
From source file:com.qccr.livtrip.web.template.BaseDirective.java
/** * ?/*from w w w .ja v a2 s . c om*/ * * @param params * ? * @param type * ? * @param ignoreProperties * * @return */ protected List<Filter> getFilters(Map<String, TemplateModel> params, Class<?> type, String... ignoreProperties) throws TemplateModelException { List<Filter> filters = new ArrayList<Filter>(); PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(type); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { String propertyName = propertyDescriptor.getName(); Class<?> propertyType = propertyDescriptor.getPropertyType(); if (!ArrayUtils.contains(ignoreProperties, propertyName) && params.containsKey(propertyName)) { Object value = FreeMarkerUtils.getParameter(propertyName, propertyType, params); filters.add(Filter.eq(propertyName, value)); } } return filters; }
From source file:gov.nih.nci.cabig.caaers.domain.AdverseEventMeddraLowLevelTerm.java
@Override @Transient// ww w . ja va 2 s . com public boolean isPositiveAttributionNeeded() { return !(getLowLevelTerm() != null && ArrayUtils.contains(new String[] { "10042434", "10011912", "10011914", "10042435", "10016479" }, getLowLevelTerm().getMeddraCode())); }
From source file:com.pureinfo.srm.auth.ShowCheckboxGroupFunctionHandler.java
private String doPerform(String _sName, String _sValue, String[] _arrayMaps) { String[] values = _sValue == null ? null : _sValue.split("\\$"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < _arrayMaps.length; i++) { String map[] = _arrayMaps[i].split(":"); if (map == null || map.length < 1) { continue; }//from w ww . j av a 2 s . c o m String sBoxValue = map[0]; String sBoxShow = map.length > 1 ? map[1] : " "; sb.append("<INPUT type=\"checkbox\" name=\"").append(_sName).append("\" value=\"").append(sBoxValue) .append("\""); if (ArrayUtils.contains(values, sBoxValue)) { sb.append(" checked"); } sb.append('>').append(sBoxShow); } String sResult = new String(sb); sb.setLength(0); return sResult; }
From source file:com.canoo.webtest.extension.VerifyContent.java
protected void verifyParameters() { super.verifyParameters(); nullParamCheck(getReferenceFile(), "referenceFile"); if (!getReferenceFile().exists()) { throw new StepFailedException("Reference file doesn't exist: " + getReferenceFile().getAbsolutePath()); }//from ww w. ja va2s . c om final String mode = getMode().toLowerCase(); final String[] allowedModes = { DIFF_MODE_AUTO, DIFF_MODE_BIN, DIFF_MODE_TEXT, DIFF_MODE_REGEXPERLINE }; if (!ArrayUtils.contains(allowedModes, mode)) { throw new StepExecutionException("Unallowed diff mode >" + getMode() + "<. " + "Allowed modes are " + ArrayUtils.toString(allowedModes) + ".", this); } }
From source file:eu.dime.ps.semantic.query.BasicQueryTest.java
@Test public void testLikeExpression() throws Exception { Collection<FileDataObject> results = resourceStore.find(FileDataObject.class).where(NFO.fileName) .like("motivation").results(); assertEquals(1, results.size());/*from w ww . j a v a 2 s. c om*/ URI[] files = new URI[] { new URIImpl("file:/home/ismriv/example/dir1/motivation-long-tail.png"), }; for (FileDataObject f : results) { assertTrue(ArrayUtils.contains(files, f.asURI())); } }