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.atolcd.pentaho.di.ui.trans.steps.gisrelate.GisRelateDialog.java
private void setOperatorFlags() { String operatorKey = getOperatorKey(wOperator.getText()); if (operatorKey != null) { wOperatorDescription//from w w w .j a va 2 s.c o m .setText(BaseMessages.getString(PKG, "GisRelate.Operator." + operatorKey + ".Description")); // Besoin de distance if (ArrayUtils.contains(input.getWithDistanceOperators(), operatorKey)) { wlDynamicDistance.setEnabled(true); wDynamicDistance.setEnabled(true); wlDistanceField.setEnabled(true); if (wDynamicDistance.getSelection()) { wDistanceField.setEnabled(true); wDistanceValue.setEnabled(false); wDistanceValue.setText(""); } else { wDistanceField.setEnabled(false); wDistanceField.setText(""); wDistanceValue.setEnabled(true); } } else { wlDynamicDistance.setEnabled(false); wDynamicDistance.setEnabled(false); wDynamicDistance.setSelection(false); wlDistanceField.setEnabled(false); wDistanceField.setEnabled(false); wDistanceField.setText(""); wDistanceValue.setEnabled(false); wDistanceValue.setText(""); } if (ArrayUtils.contains(input.getBoolResultOperators(), operatorKey)) { wlReturnType.setEnabled(true); wReturnType.setEnabled(true); } else { wlReturnType.setEnabled(false); wReturnType.setEnabled(false); wReturnType.setText(getReturnTypeLabel("ALL")); } } }
From source file:marytts.unitselection.analysis.Phone.java
/** * Get the factors required to convert the F0 values recovered from the Datagrams in a SelectedUnit to the target F0 values. * // w ww .j a v a 2 s. co m * @param unit * from which to recover the realized F0 values * @param target * for which to get the target F0 values * @return each Datagram's F0 factor in an array, or null if realized and target F0 values differ in length * @throws ArithmeticException * if any of the F0 values recovered from the unit's Datagrams is zero */ private double[] getUnitF0Factors(SelectedUnit unit, HalfPhoneTarget target) throws ArithmeticException { double[] unitF0Values = getUnitF0Values(unit); if (ArrayUtils.contains(unitF0Values, 0)) { throw new ArithmeticException("Unit frames must not have F0 of 0!"); } double[] targetF0Values; if (target == null || target.isLeftHalf()) { targetF0Values = getLeftTargetF0Values(); } else { targetF0Values = getRightTargetF0Values(); } double[] f0Factors = null; try { f0Factors = MathUtils.divide(targetF0Values, unitF0Values); } catch (IllegalArgumentException e) { // leave at null } return f0Factors; }
From source file:com.evolveum.polygon.connector.ldap.schema.AbstractSchemaTranslator.java
/** * Throws exception if the attribute is illegal. * Return null if the attribute is legal, but we do not have any definition for it. *//*from ww w.ja v a 2 s.com*/ public AttributeType toLdapAttribute(org.apache.directory.api.ldap.model.schema.ObjectClass ldapObjectClass, String icfAttributeName) { if (Name.NAME.equals(icfAttributeName)) { return null; } String ldapAttributeName; if (Uid.NAME.equals(icfAttributeName)) { ldapAttributeName = configuration.getUidAttribute(); } else if (OperationalAttributeInfos.PASSWORD.is(icfAttributeName)) { ldapAttributeName = configuration.getPasswordAttribute(); } else { ldapAttributeName = icfAttributeName; } try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry(ldapAttributeName); if (attributeType == null && configuration.isAllowUnknownAttributes()) { // Create fake attribute type attributeType = createFauxAttributeType(ldapAttributeName); } return attributeType; } catch (LdapException e) { if (ArrayUtils.contains(configuration.getOperationalAttributes(), ldapAttributeName) || configuration.isAllowUnknownAttributes()) { // Create fake attribute type AttributeType attributeType = new AttributeType(ldapAttributeName); attributeType.setNames(ldapAttributeName); return attributeType; } else { throw new IllegalArgumentException("Unknown LDAP attribute " + ldapAttributeName + " (translated from ICF attribute " + icfAttributeName + ")", e); } } }
From source file:mitm.application.djigzo.james.mailets.PDFEncrypt.java
private void addEncryptedPDF(MimeMessage message, byte[] pdf) throws MessagingException { /*/*from w ww .ja v a2 s . c om*/ * Find the existing PDF. The expect that the message is a multipart/mixed. */ if (!message.isMimeType("multipart/mixed")) { throw new MessagingException("Content-type should have been multipart/mixed."); } Multipart mp; try { mp = (Multipart) message.getContent(); } catch (IOException e) { throw new MessagingException("Error getting message content.", e); } BodyPart pdfPart = null; /* * Fallback in case the template does not contain a DjigzoHeader.MARKER */ BodyPart fallbackPart = null; for (int i = 0; i < mp.getCount(); i++) { BodyPart part = mp.getBodyPart(i); if (ArrayUtils.contains(part.getHeader(DjigzoHeader.MARKER), DjigzoHeader.ATTACHMENT_MARKER_VALUE)) { pdfPart = part; break; } /* * Fallback scanning for application/pdf in case the template does not contain a DjigzoHeader.MARKER */ if (part.isMimeType("application/pdf")) { fallbackPart = part; } } if (pdfPart == null) { if (fallbackPart != null) { getLogger().info("Marker not found. Using ocet-stream instead."); /* * Use the octet-stream part */ pdfPart = fallbackPart; } else { throw new MessagingException("Unable to find the attachment part in the template."); } } pdfPart.setDataHandler(new DataHandler(new ByteArrayDataSource(pdf, "application/pdf"))); }
From source file:com.haulmont.cuba.gui.ComponentsHelper.java
/** * Set field's "required" flag to false if the value has been filtered by Row Level Security * This is necessary to allow user to submit form with filtered attribute even if attribute is required *///from www . j ava 2 s. co m public static void handleFilteredAttributes(Field component, Datasource datasource, MetaPropertyPath mpp) { if (component.isRequired() && datasource.getState() == Datasource.State.VALID && datasource.getItem() != null && mpp.getMetaProperty().getRange().isClass()) { Entity targetItem = datasource.getItem(); MetaProperty[] propertiesChain = mpp.getMetaProperties(); if (propertiesChain.length > 1) { String basePropertyItem = Arrays.stream(propertiesChain).limit(propertiesChain.length - 1) .map(MetadataObject::getName).collect(Collectors.joining(".")); targetItem = datasource.getItem().getValueEx(basePropertyItem); } if (targetItem instanceof BaseGenericIdEntity) { String metaPropertyName = mpp.getMetaProperty().getName(); Object value = targetItem.getValue(metaPropertyName); BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) targetItem; String[] filteredAttributes = getFilteredAttributes(baseGenericIdEntity); if (value == null && filteredAttributes != null && ArrayUtils.contains(filteredAttributes, metaPropertyName)) { component.setRequired(false); } } } }
From source file:jp.primecloud.auto.nifty.process.NiftyProcessClient.java
protected VolumeDto waitVolume(String volumeId) { // Volume???/*from www . j a v a 2s . c o m*/ String[] stableStatus = new String[] { "available", "in-use" }; String[] unstableStatus = new String[] { "creating" }; VolumeDto volume = null; while (true) { volume = describeVolume(volumeId); String status; status = volume.getStatus(); if (ArrayUtils.contains(stableStatus, status)) { break; } if (!ArrayUtils.contains(unstableStatus, status)) { // ??? AutoException exception = new AutoException("EPROCESS-000620", volumeId, status); exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume)); throw exception; } } return volume; }
From source file:com.ecyrd.jspwiki.auth.authorize.GroupManager.java
/** * Checks if a String is blank or a restricted Group name, and if it is, * appends an error to the WikiSession's message list. * @param context the wiki context/*ww w . java 2 s.c o m*/ * @param name the Group name to test * @throws WikiSecurityException if <code>session</code> is * <code>null</code> or the Group name is illegal * @see Group#RESTRICTED_GROUPNAMES */ protected final void checkGroupName(WikiContext context, String name) throws WikiSecurityException { //TODO: groups cannot have the same name as a user // Name cannot be null InputValidator validator = new InputValidator(MESSAGES_KEY, context); validator.validateNotNull(name, "Group name"); // Name cannot be one of the restricted names either if (ArrayUtils.contains(Group.RESTRICTED_GROUPNAMES, name)) { throw new WikiSecurityException("The group name '" + name + "' is illegal. Choose another."); } }
From source file:info.novatec.inspectit.rcp.storage.util.DataRetriever.java
/** * Returns the map of the existing files for the given storage. The value in the map is file * size. Only wanted file types will be included in the map. * /* w w w . ja v a2s . c o m*/ * @param cmrRepositoryDefinition * {@link CmrRepositoryDefinition}. * @param storageData * {@link StorageData} * @param fileTypes * Files that should be included. * @return Map of file names with their size. * @throws BusinessException * If {@link BusinessException} occurs during service invocation. */ private Map<String, Long> getFilesFromCmr(CmrRepositoryDefinition cmrRepositoryDefinition, StorageData storageData, StorageFileType... fileTypes) throws BusinessException { Map<String, Long> allFiles = new HashMap<String, Long>(); // agent files if (ArrayUtils.contains(fileTypes, StorageFileType.AGENT_FILE)) { Map<String, Long> platformIdentsFiles = cmrRepositoryDefinition.getStorageService() .getAgentFilesLocations(storageData); allFiles.putAll(platformIdentsFiles); } // indexing files if (ArrayUtils.contains(fileTypes, StorageFileType.INDEX_FILE)) { Map<String, Long> indexingTreeFiles = cmrRepositoryDefinition.getStorageService() .getIndexFilesLocations(storageData); allFiles.putAll(indexingTreeFiles); } if (ArrayUtils.contains(fileTypes, StorageFileType.DATA_FILE)) { // data files Map<String, Long> dataFiles = cmrRepositoryDefinition.getStorageService() .getDataFilesLocations(storageData); allFiles.putAll(dataFiles); } if (ArrayUtils.contains(fileTypes, StorageFileType.CACHED_DATA_FILE)) { // data files Map<String, Long> dataFiles = cmrRepositoryDefinition.getStorageService() .getCachedDataFilesLocations(storageData); allFiles.putAll(dataFiles); } return allFiles; }
From source file:com.rtg.launcher.CommonFlags.java
/** * Initialise flag for AVR model to use for prediction * * @param flags shared flags//from w w w. j a v a 2 s.c o m * @param anonymous if true, register the flag as an anonymous flag * @return the newly registered flag */ public static Flag initAvrModel(final CFlags flags, boolean anonymous) { String description = "name of AVR model to use when scoring variants"; boolean hasDefault = false; final String modelDirName = Environment.getEnvironmentMap().get(ENVIRONMENT_MODELS_DIR); if (modelDirName != null) { final File modelDir = new File(modelDirName); if (modelDir.exists() && modelDir.isDirectory()) { final String[] models = modelDir.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".avr"); } }); if (!anonymous && models != null && models.length > 0) { final String[] newModels = new String[models.length + 1]; newModels[0] = AVR_NONE_NAME; System.arraycopy(models, 0, newModels, 1, models.length); description += " (Must be one of " + Arrays.toString(newModels) + " or a path to a model file)"; if (ArrayUtils.contains(newModels, MODEL_DEFAULT)) { hasDefault = true; } } } } final Flag modelFlag = anonymous ? flags.registerRequired(File.class, "file", description) .setCategory(CommonFlagCategories.REPORTING) : flags.registerOptional(AVR_MODEL_FILE_FLAG, File.class, "file", description) .setCategory(CommonFlagCategories.REPORTING); if (!anonymous && hasDefault) { modelFlag.setParameterDefault(MODEL_DEFAULT); } return modelFlag; }
From source file:com.manydesigns.portofino.pageactions.text.TextAction.java
@Button(list = "manage-attachments", key = "ok", order = 1, type = Button.TYPE_PRIMARY) @RequiresPermissions(level = AccessLevel.VIEW, permissions = { PERMISSION_EDIT }) public Resolution saveAttachments() { if (downloadable == null) { downloadable = new String[0]; }//from www.j a va 2 s .c o m if (textConfiguration == null) { textConfiguration = new TextConfiguration(); } for (Attachment attachment : textConfiguration.getAttachments()) { boolean contained = ArrayUtils.contains(downloadable, attachment.getId()); attachment.setDownloadable(contained); } saveConfiguration(textConfiguration); return cancel(); }