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.googlecode.jtiger.modules.ecside.view.html.FormBuilder.java
public void userDefinedParameters() { Map parameterMap = model.getRegistry().getParameterMap(); String includeParameters = table.getIncludeParameters(); String excludeParameters = table.getExcludeParameters(); // includeParameters=StringUtils.isNotBlank(includeParameters)?","+includeParameters+",":null; // excludeParameters=StringUtils.isNotBlank(excludeParameters)?","+excludeParameters+",":null; Set keys = parameterMap.keySet(); String[] keyField = new String[] { //ECSideConstants.EASY_DATA_ACCESS_FLAG, //ECSideConstants.EASY_DATA_LIST_FLAG, //ECSideConstants.EASY_DATA_EXPORT_FLAG };// w ww. ja v a2 s . com for (Iterator iter = keys.iterator(); iter.hasNext();) { String name = (String) iter.next(); if (name.startsWith(model.getTableHandler().prefixWithTableId()) || excludeParameters != null && isInParameters(excludeParameters, name) || includeParameters != null && !isInParameters(includeParameters, name) || ArrayUtils.contains(keyField, name)) { continue; } String values[] = (String[]) parameterMap.get(name); if (values == null || values.length == 0) { html.newline(); html.input("hidden").name(name).xclose(); } else { for (int i = 0; i < values.length; i++) { html.newline(); html.input("hidden").name(name).value(values[i]).xclose(); } } } }
From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java
private Color getColor(int classIndex) { Color c = paintList.get(classIndex); MapPNode mapPNode = CommonSOMViewerStateData.getInstance().mapPNode; if (mapPNode == null) { // happens e.g. if we are not in the SOMViewer, but in stand-alone apps // such as VisualisationImageSaver return c; }//from w ww . ja v a 2 s.c om GeneralUnitPNode pnode = mapPNode.getUnit(unit); int[] selI = pnode.getSelectedClassIndices(); if (selI != null && !ArrayUtils.contains(selI, classIndex)) { // if there is some selection, but not this class // This would be the nice way: // c = new Color(c.getRed(), c.getGreen(), c.getBlue(), 0); // FIXME: This is a workaround, see Ticket #265 c = Color.WHITE; } return c; }
From source file:com.adobe.acs.commons.packaging.impl.PackageHelperImplTest.java
@Test public void testGetPathFilterSetPreviewJSON() throws Exception { final List<PathFilterSet> pathFilterSets = new ArrayList<PathFilterSet>(); pathFilterSets.add(new PathFilterSet("/a/b/c")); pathFilterSets.add(new PathFilterSet("/d/e/f")); pathFilterSets.add(new PathFilterSet("/g/h/i")); final String actual = packageHelper.getPathFilterSetPreviewJSON(pathFilterSets); final JSONObject json = new JSONObject(actual); assertEquals("preview", json.getString("status")); assertEquals("Not applicable (Preview)", json.getString("path")); final String[] expectedFilterSets = new String[] { "/a/b/c", "/d/e/f", "/g/h/i" }; JSONArray actualArray = json.getJSONArray("filterSets"); for (int i = 0; i < actualArray.length(); i++) { JSONObject tmp = actualArray.getJSONObject(i); assertTrue(ArrayUtils.contains(expectedFilterSets, tmp.get("rootPath"))); }/*from ww w . j a v a2s .c o m*/ assertEquals(expectedFilterSets.length, actualArray.length()); }
From source file:com.manydesigns.portofino.model.database.DatabaseLogic.java
public static String normalizeName(String name) { name = StringUtils.replaceChars(name, ".", "_"); String firstLetter = name.substring(0, 1); String others = name.substring(1); StringBuilder result = new StringBuilder(); result.append(checkFirstLetter(firstLetter)); for (int i = 0; i < others.length(); i++) { String letter = String.valueOf(others.charAt(i)); result.append(checkOtherLetters(letter)); }//from ww w.j a va 2s . c o m String normalizedName = result.toString(); if (ArrayUtils.contains(HQL_KEYWORDS, normalizedName.toLowerCase())) { normalizedName = "_" + normalizedName; } if (!name.equals(normalizedName)) { logger.info("Name " + name + " normalized to " + normalizedName); } return normalizedName; }
From source file:gov.nih.nci.cabig.caaers.domain.repository.ReportRepositoryImpl.java
/** * Find report deliveries./*from w w w . j ava 2 s . c o m*/ * * @param aReport the a report * @return the list * {@inheritDoc} */ public List<ReportDelivery> findReportDeliveries(Report aReport) { List<ReportDelivery> deliveries = new ArrayList<ReportDelivery>(); //reload the report Report report = reportDao.getById(aReport.getId()); ReportDefinition reportDefinition = report.getReportDefinition(); ExpeditedAdverseEventReport aeReport = report.getAeReport(); List<ReportDeliveryDefinition> deliveryDefinitions = reportDefinition.getDeliveryDefinitions(); if (deliveryDefinitions != null) { for (ReportDeliveryDefinition reportDeliveryDefinition : deliveryDefinitions) { //fetch the contact mechanism for role based entities. if (reportDeliveryDefinition.getEntityType() == ReportDeliveryDefinition.ENTITY_TYPE_ROLE) { String roleName = reportDeliveryDefinition.getEndPoint(); List<String> addresses = null; if (ArrayUtils.contains(RoleUtils.reportSpecificRoles, roleName)) { addresses = report.findEmailAddressByRole(roleName); } else if (ArrayUtils.contains(RoleUtils.sponsorAndCoordinatingCenterSpecificRoles, roleName)) { addresses = aeReport.getStudy().getStudyCoordinatingCenter() .findEmailAddressByRole(roleName); addresses.addAll(aeReport.getStudy().getStudyFundingSponsors().get(0) .findEmailAddressByRole(roleName)); } else if (ArrayUtils.contains(RoleUtils.studySiteSpecificRoles, roleName)) { addresses = aeReport.getStudySite().findEmailAddressByRole(roleName); } else { addresses = aeReport.getStudy().findEmailAddressByRole(roleName); } for (String address : addresses) { if (StringUtils.isNotEmpty(address)) { ReportDelivery reportDelivery = reportDeliveryDefinition.createReportDelivery(); reportDelivery.setEndPoint(address); deliveries.add(reportDelivery); } } } else { if (StringUtils.isNotEmpty(reportDeliveryDefinition.getEndPoint())) { ReportDelivery reportDelivery = reportDeliveryDefinition.createReportDelivery(); reportDelivery.setEndPoint(reportDeliveryDefinition.getEndPoint()); deliveries.add(reportDelivery); } } } } return deliveries; }
From source file:com.fengduo.bee.commons.util.StringFormatter.java
private static boolean isMatch(char charAt) { String binaryString = Integer.toBinaryString(charAt); if (binaryString.length() > 8) { return false; } else {/* w w w .ja v a2 s . c o m*/ return !ArrayUtils.contains(array, charAt); } }
From source file:com.evolveum.polygon.connector.ldap.ad.AdSchemaTranslator.java
@Override protected boolean isOperational(AttributeType ldapAttribute) { if (super.isOperational(ldapAttribute)) { return true; }/*from ww w . ja va 2 s. co m*/ String attrName = ldapAttribute.getName().toLowerCase(); if (attrName.startsWith("msds-")) { return true; } return ArrayUtils.contains(OPERATIONAL_ATTRIBUTE_NAMES, attrName); }
From source file:com.manydesigns.elements.fields.search.SelectSearchField.java
private void valueToXhtmlCheckbox(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); int counter = 0; for (Map.Entry<Object, SelectionModel.Option> option : options.entrySet()) { if (!option.getValue().active) { continue; }//from w w w . j a v a2s . c o m Object optionValue = option.getKey(); String optionStringValue = OgnlUtils.convertValueToString(optionValue); String optionLabel = option.getValue().label; boolean checked = ArrayUtils.contains(values, optionValue); String checkboxId = id + "_" + counter; xb.openElement("label"); xb.addAttribute("class", "checkbox"); xb.addAttribute("for", checkboxId); xb.writeNbsp(); xb.write(optionLabel); xb.writeNbsp(); xb.writeInputCheckbox(checkboxId, inputName, optionStringValue, checked); xb.writeNbsp(); xb.closeElement("label"); counter++; } xb.closeElement("div"); }
From source file:info.novatec.inspectit.rcp.editor.tree.DeferredTreeViewer.java
/** * Checks if the given element is one of the root object in the input list of the tree viewer. * /*from w w w.ja v a 2 s .c o m*/ * @param element * Element to check. * @return True if the element is one of the root objects. */ private boolean isRootElement(Object element) { Object input = getRoot(); Object[] rootElemens = ((ITreeContentProvider) getContentProvider()).getElements(input); return ArrayUtils.contains(rootElemens, element); }
From source file:io.dataplay.storm.workers.AbstractBoltTest.java
/** * Ensure the constructor is abstract./*from w w w . j a v a2 s. co m*/ * * @throws Exception Creating an abstract class should throw an error. */ @Test public void testConstructor() throws Exception { Constructor<AbstractBolt> constructor = AbstractBolt.class.getDeclaredConstructor(); // Must not be accessible (abstract) Assert.assertFalse(constructor.isAccessible()); // Assert interface Class[] interfaces = AbstractBolt.class.getInterfaces(); Assert.assertTrue(ArrayUtils.contains(interfaces, IDataWorker.class)); // Override the private constructor and create an instance try { constructor.newInstance(); Assert.fail("Constructor must not be accessible"); } catch (InstantiationException e) { Assert.assertTrue(true); } // Assert extensibility. IDataWorker worker = new WorkerImpl(); Assert.assertNotNull(worker); }