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.autentia.wuija.persistence.impl.hibernate.HibernateGroupManagementTest.java
/** * Comprueba si en la base de datos hay dados de alta exactamente los mismos grupos que se pasan como parmetro. * // w w w .ja va 2s . c om * @param groups array de grupos que deben estar en la base de datos, ni uno ms ni uno menos. */ private void checkGroups(String[] groups) { final String[] loadedGroups = groupManager.findAllGroups(); Assert.assertEquals("loaded groups length", groups.length, loadedGroups.length); for (String loadedGroup : loadedGroups) { Assert.assertTrue("groups contains loaded group " + loadedGroup, ArrayUtils.contains(groups, loadedGroup)); } }
From source file:de.unisb.cs.st.javalanche.mutation.util.AddOffutt96Sufficient.java
private static int[] getContainingArray(int operator, int[]... arrays) { for (int[] array : arrays) { if (ArrayUtils.contains(array, operator)) { return array; }//from w w w .j av a2s . co m } return new int[0]; }
From source file:jef.tools.StringUtils.java
/** * ????????/*w w w .j a va 2 s .c om*/ * * @param base * * @param exists * * @param allowRaw * ????? * @param appendFormat * ?? * @return */ public static String escapeName(String base, String[] exists, boolean allowRaw, String appendFormat, int start) { if (allowRaw && !ArrayUtils.contains(exists, base)) { return base; } int n = start; while (ArrayUtils.contains(exists, base + (appendFormat == null ? n : String.format(appendFormat, n)))) { n++; } return base + (appendFormat == null ? n : String.format(appendFormat, n)); }
From source file:com.adobe.acs.tools.explain_query.impl.ExplainQueryServlet.java
private JSONArray compositeQueryDataToJSON(Collection<CompositeData> queries) throws JSONException { final JSONArray jsonArray = new JSONArray(); for (CompositeData query : queries) { Long duration = (Long) query.get("duration"); Integer occurrenceCount = (Integer) query.get("occurrenceCount"); String language = (String) query.get("language"); String statement = (String) query.get("statement"); if (!ArrayUtils.contains(LANGUAGES, language)) { // Not a supported language continue; } else if (StringUtils.startsWithIgnoreCase(statement, "EXPLAIN ") || StringUtils.startsWithIgnoreCase(statement, "MEASURE ")) { // Don't show EXPLAIN or MEASURE queries continue; }// w w w. j a v a2 s . co m final JSONObject json = new JSONObject(); try { json.put("duration", duration); json.put("language", language); json.put("occurrenceCount", occurrenceCount); json.put("statement", statement); jsonArray.put(json); } catch (JSONException e) { log.warn("Could not add query to results [ {} ]", statement); continue; } } return jsonArray; }
From source file:gov.nih.nci.cabig.caaers.web.ae.EditAdverseEventController.java
/** * Overriden to handle switching of reporting context. * Note:- Will update the mandatory sections and fields * //from ww w . jav a2 s .com */ @Override protected void onBind(HttpServletRequest request, Object command, BindException errors) throws Exception { super.onBind(request, command, errors); //bind the context report definitions int[] rdIds = { -9999 }; try { rdIds = ServletRequestUtils.getIntParameters(request, "reportingContextRdId"); } catch (Exception e) { } EditExpeditedAdverseEventCommand editCommand = (EditExpeditedAdverseEventCommand) command; //AJAX requests will not have reporting context information if (!(isAjaxRequest(request) || request.getParameter(AJAX_SUBVIEW_PARAMETER) != null)) { editCommand.getSelectedReportDefinitions().clear(); for (ReportDefinition rd : editCommand.getApplicableReportDefinitions()) { if (ArrayUtils.contains(rdIds, rd.getId().intValue())) { editCommand.getSelectedReportDefinitions().add(rd); } } } //now refresh the not applicable/mandatory fields. editCommand.refreshMandatorySections(); editCommand.updateFieldMandatoryness(); }
From source file:com.autentia.wuija.persistence.impl.hibernate.HibernateGroupManagementTest.java
private void checkUsersInGroup(String groupname, String[] userNames) { String[] users = groupManager.findUsersInGroup(groupname); log.debug("Checking users from group " + groupname); Assert.assertEquals("users.length", userNames.length, users.length); for (String name : userNames) { Assert.assertTrue("users contains " + name, ArrayUtils.contains(users, name)); }/*w w w .j a v a 2 s. com*/ }
From source file:com.gewara.util.XSSFilter.java
/** * /* ww w . ja v a 2 s.c o m*/ * @param entity * @param attrs * @return */ public static <T extends BaseObject> T filterObjAttrs(T entity, String... attrs) { if (ArrayUtils.isEmpty(attrs)) return entity; XSSFilter filter = new XSSFilter(); try { Map result = PropertyUtils.describe(entity); for (Object key : result.keySet()) { if (result.get(key) instanceof String && ArrayUtils.contains(attrs, String.valueOf(key))) { String cleanString = filter.filter(String.valueOf(result.get(key))); result.put(key, cleanString); } } BeanUtil.copyProperties(entity, result); } catch (Exception ex) { } return entity; }
From source file:com.cubusmail.mail.imap.IMAPMailFolder.java
public boolean hasChildren() throws MessagingException { return ArrayUtils.contains(this.folder.getAttributes(), ATTRIBUTE_HAS_CHILDREN); }
From source file:de.iteratec.iteraplan.businesslogic.exchange.common.informationflow.InformationFlowGraphConverter.java
private void addEdgesForConnection(InformationSystemInterface connection, LayoutNode startNode, LayoutNode endNode) {//from w w w. j a v a2s .c om // Validate start and end nodes if ((startNode == null) || (endNode == null) || doneEdgeIds.contains(connection.getId())) { return; } List<String> edgeLabels = new ArrayList<String>(); List<Direction> directions = new ArrayList<Direction>(); Direction directionInterface = setInterfaceEdgeDirection(connection); if (ArrayUtils.contains(lineCaptionSelected, InformationFlowOptionsBean.LINE_DESCR_BUSINESS_OBJECTS)) { setBusinessObjectEdgeLabelsAndDirections(connection, edgeLabels, directions); } else { edgeLabels.add(""); directions.add(directionInterface); } List<String> commonEdgeLabels = Lists.newArrayList(); for (int lineCaption : this.lineCaptionSelected) { String prefix = ""; switch (lineCaption) { case InformationFlowOptionsBean.LINE_DESCR_TECHNICAL_COMPONENTS: String edgeLabelForTcr = getEdgeLabelForTcr(connection); if (!edgeLabelForTcr.isEmpty()) { commonEdgeLabels.add(edgeLabelForTcr); } break; case InformationFlowOptionsBean.LINE_DESCR_ATTRIBUTES: commonEdgeLabels.add(getEdgeLabelForAttributes(connection)); break; case InformationFlowOptionsBean.LINE_DESCR_DESCRIPTION: prefix = MessageAccess.getStringOrNull("graphicalExport.informationflow.description.abbreviation") + ": "; commonEdgeLabels.add(prefix + connection.getDescription()); break; case InformationFlowOptionsBean.LINE_DESCR_NAME: prefix = MessageAccess.getStringOrNull("graphicalExport.informationflow.name.abbreviation") + ": "; if (!connection.getName().isEmpty()) { commonEdgeLabels.add(prefix + connection.getName()); } break; default: // Business Objects: do nothing, case already handled above } } // add edges for (int i = 0; i < edgeLabels.size(); i++) { String edgeLabel = buildEdgeLabel(commonEdgeLabels, edgeLabels.get(i)); addEdge(startNode, endNode, connection, edgeLabel, directions.get(i)); } // Mark the connection as done doneEdgeIds.add(connection.getId()); }
From source file:com.manydesigns.elements.fields.search.SelectSearchField.java
private void valueToXhtmlMultipleSelection(XhtmlBuffer xb) { xb.writeLabel(StringUtils.capitalize(label), id, ATTR_NAME_HTML_CLASS); xb.openElement("div"); xb.addAttribute("class", "controls"); Object[] values = getValues(); Map<Object, SelectionModel.Option> options = selectionModel.getOptions(selectionModelIndex); xb.openElement("select"); xb.addAttribute("id", id); xb.addAttribute("name", inputName); xb.addAttribute("multiple", "multiple"); xb.addAttribute("size", "5"); boolean checked; for (Map.Entry<Object, SelectionModel.Option> option : options.entrySet()) { if (!option.getValue().active) { continue; }// w w w. j av a 2 s .c o m Object optionValue = option.getKey(); String optionStringValue = OgnlUtils.convertValueToString(optionValue); String optionLabel = option.getValue().label; checked = ArrayUtils.contains(values, optionValue); xb.writeOption(optionStringValue, checked, optionLabel); } xb.closeElement("select"); xb.closeElement("div"); }