List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:com.u2apple.tool.ui.MainFrame.java
private void initDevice() { String brand = brandTextField.getText(); String model = modelTextField.getText(); String productId = AndroidDeviceUtils.buildProductId(brand, model); String productName = AndroidDeviceUtils.getProductName(brand, model); productIdTextField.setText(productId); String brandOfProductId = AndroidDeviceUtils.getBrandByProductId(productId); //Chinese// www . jav a 2s .c o m brandTextField.setText(deviceDao.getChineseBrand(brandOfProductId)); productTextField.setText(productName); aliasTextField.setText(""); //English enBrandTextField.setText(deviceDao.getEnglishBrand(brandOfProductId)); enProductTextField.setText(productName); enAliasTextField.setText(""); //Update condition checkbox. if (StringUtils.containsIgnoreCase(model, brand)) { conditionCheckBox.setSelected(false); } else { conditionCheckBox.setSelected(true); } //Initialize conditon text field. if (conditionComboBox.getSelectedIndex() != 1) { conditionComboBox.setSelectedIndex(1); } //ConditionComboBox must be set before conditionTextField. conditionTextField.setText(brand); condition2TextField.setText(""); typeComboBox.setSelectedIndex(0); vid2TextField.setText(""); }
From source file:com.u2apple.rt.ui.RecognitionToolJFrame.java
private void googleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_googleButtonActionPerformed String model = modelTextField.getText(); String brand = brandTextField.getText(); if (StringUtils.isNotBlank(brand) || StringUtils.isNotBlank(model)) { StringBuilder commandBuilder = new StringBuilder(); commandBuilder.append("explorer \"https://www.google.com.hk/#safe=strict&q="); //Append query. if (StringUtils.equalsIgnoreCase(model, brand) || StringUtils.containsIgnoreCase(model, brand)) { commandBuilder.append(model); } else {/*ww w . j a v a 2 s .c o m*/ commandBuilder.append(brand); commandBuilder.append(" "); commandBuilder.append(model); } commandBuilder.append(" \""); try { Runtime.getRuntime().exec(commandBuilder.toString()); } catch (IOException ex) { Logger.getLogger(RecognitionToolJFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(jPanel13, "Brand and Model both are blank."); } }
From source file:com.u2apple.rt.ui.RecognitionToolJFrame.java
private void baiduButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_baiduButtonActionPerformed String model = modelTextField.getText(); String brand = brandTextField.getText(); if (StringUtils.isNotBlank(brand) || StringUtils.isNotBlank(model)) { StringBuilder commandBuilder = new StringBuilder(); commandBuilder.append("explorer \"http://www.baidu.com/s?wd="); //Append query. if (StringUtils.equalsIgnoreCase(model, brand) || StringUtils.containsIgnoreCase(model, brand)) { commandBuilder.append(model); } else {// ww w.j ava2 s.c o m commandBuilder.append(brand); commandBuilder.append(" "); commandBuilder.append(model); } commandBuilder.append(" \""); try { Runtime.getRuntime().exec(commandBuilder.toString()); } catch (IOException ex) { Logger.getLogger(RecognitionToolJFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(jPanel13, "Brand and Model both are blank."); } }
From source file:com.u2apple.tool.ui.MainFrame.java
private void googleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_googleButtonActionPerformed String model = modelTextField.getText(); String brand = brandTextField.getText(); if (StringUtils.isBlank(brand)) { String productId = productIdTextField.getText(); brand = AndroidDeviceUtils.getBrandByProductId(productId); }/*from w w w. j a v a 2 s . c om*/ if (StringUtils.isNotBlank(brand) || StringUtils.isNotBlank(model)) { StringBuilder commandBuilder = new StringBuilder(); commandBuilder.append("explorer \"https://www.google.com/webhp?hl=zh-CN#hl=zh-CN&q="); //Append query. if (StringUtils.equalsIgnoreCase(model, brand) || StringUtils.containsIgnoreCase(model, brand)) { commandBuilder.append(model); } else { commandBuilder.append(brand); commandBuilder.append(" "); commandBuilder.append(model); } commandBuilder.append(" \""); try { Runtime.getRuntime().exec(commandBuilder.toString()); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(jPanel13, "Brand and Model both are blank."); } }
From source file:com.sonicle.webtop.core.CoreManager.java
/** * Returns a list of recipients beloging to a specified type. * @param fieldType The desired recipient type. * @param sourceIds A collection of sources in which look for. * @param queryText A text to filter out returned results. * @param max Max number of results.// ww w . ja va 2 s . c om * @return * @throws WTException */ public List<Recipient> listProviderRecipients(RecipientFieldType fieldType, Collection<String> sourceIds, String queryText, int max) throws WTException { CoreServiceSettings css = new CoreServiceSettings(CoreManifest.ID, getTargetProfileId().getDomainId()); ArrayList<Recipient> items = new ArrayList<>(); boolean autoProviderEnabled = css.getRecipientAutoProviderEnabled(); int remaining = max; for (String soId : sourceIds) { List<Recipient> recipients = null; if (StringUtils.equals(soId, RECIPIENT_PROVIDER_AUTO_SOURCE_ID)) { if (!autoProviderEnabled) continue; if (!fieldType.equals(RecipientFieldType.LIST)) { recipients = new ArrayList<>(); //TODO: Find a way to handle other RecipientFieldTypes if (fieldType.equals(RecipientFieldType.EMAIL)) { final List<OServiceStoreEntry> entries = listServiceStoreEntriesByQuery(SERVICE_ID, "recipients", queryText, remaining); for (OServiceStoreEntry entry : entries) { final InternetAddress ia = InternetAddressUtils.toInternetAddress(entry.getValue()); if (ia != null) recipients.add(new Recipient(RECIPIENT_PROVIDER_AUTO_SOURCE_ID, lookupResource(getLocale(), CoreLocaleKey.INTERNETRECIPIENT_AUTO), RECIPIENT_PROVIDER_AUTO_SOURCE_ID, ia.getPersonal(), ia.getAddress())); } } } } else if (StringUtils.equals(soId, RECIPIENT_PROVIDER_WEBTOP_SOURCE_ID)) { if (!fieldType.equals(RecipientFieldType.LIST)) { recipients = new ArrayList<>(); //TODO: Find a way to handle other RecipientFieldTypes if (fieldType.equals(RecipientFieldType.EMAIL)) { List<OUser> users = listUsers(true); for (OUser user : users) { UserProfile.Data userData = WT .getUserData(new UserProfileId(user.getDomainId(), user.getUserId())); if (userData != null) { if (StringUtils.containsIgnoreCase(user.getDisplayName(), queryText) || StringUtils .containsIgnoreCase(userData.getPersonalEmailAddress(), queryText)) recipients.add(new Recipient(RECIPIENT_PROVIDER_WEBTOP_SOURCE_ID, lookupResource(getLocale(), CoreLocaleKey.INTERNETRECIPIENT_WEBTOP), RECIPIENT_PROVIDER_AUTO_SOURCE_ID, user.getDisplayName(), userData.getPersonalEmailAddress())); } } } } } else { final RecipientsProviderBase provider = getProfileRecipientsProviders().get(soId); if (provider == null) continue; try { recipients = provider.getRecipients(fieldType, queryText, remaining); } catch (Throwable t) { logger.error("Error calling RecipientProvider [{}]", t, soId); } if (recipients == null) continue; } if (recipients != null) for (Recipient recipient : recipients) { remaining--; if (remaining < 0) break; recipient.setSource(soId); // Force composed id! items.add(recipient); } if (remaining <= 0) break; } return items; }
From source file:com.u2apple.tool.ui.MainFrame.java
private void baiduButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_baiduButtonActionPerformed String model = modelTextField.getText(); String brand = brandTextField.getText(); if (StringUtils.isBlank(brand)) { String productId = productIdTextField.getText(); brand = AndroidDeviceUtils.getBrandByProductId(productId); }/*from w w w . j ava 2 s. c om*/ if (StringUtils.isNotBlank(brand) || StringUtils.isNotBlank(model)) { StringBuilder commandBuilder = new StringBuilder(); commandBuilder.append("explorer \"http://www.baidu.com/s?wd="); //Append query. if (StringUtils.equalsIgnoreCase(model, brand) || StringUtils.containsIgnoreCase(model, brand)) { commandBuilder.append(model); } else { commandBuilder.append(brand); commandBuilder.append(" "); commandBuilder.append(model); } commandBuilder.append(" \""); try { Runtime.getRuntime().exec(commandBuilder.toString()); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(jPanel13, "Brand and Model both are blank."); } }
From source file:io.apiman.manager.api.jpa.JpaStorage.java
private boolean isMySql() throws StorageException { return StringUtils.containsIgnoreCase(getDialect(), "mysql"); }
From source file:com.lleps.jsamp.constant.model.VehicleModel.java
public static Optional<VehicleModel> getByPartOfName(String name, boolean ignoreCase) { if (ignoreCase) { return VALUES_BY_ID.values().stream().filter(v -> StringUtils.containsIgnoreCase(v.name, name)) .findFirst();/*from w w w . j av a 2 s . c o m*/ } else { return VALUES_BY_ID.values().stream().filter(v -> v.name.contains(name)).findFirst(); } }
From source file:org.apache.hive.spark.client.SparkSubmitSparkClient.java
@Override protected Future<Void> launchDriver(String isTesting, RpcServer rpcServer, String clientId) throws IOException { Callable<Void> runnable; String cmd = Joiner.on(" ").join(argv); LOG.info("Running client driver with argv: {}", cmd); ProcessBuilder pb = new ProcessBuilder("sh", "-c", cmd); // Prevent hive configurations from being visible in Spark. pb.environment().remove("HIVE_HOME"); pb.environment().remove("HIVE_CONF_DIR"); // Add credential provider password to the child process's environment // In case of Spark the credential provider location is provided in the jobConf when the job is submitted String password = getSparkJobCredentialProviderPassword(); if (password != null) { pb.environment().put(Constants.HADOOP_CREDENTIAL_PASSWORD_ENVVAR, password); }//from w w w. j a v a 2 s . c om if (isTesting != null) { pb.environment().put("SPARK_TESTING", isTesting); } final Process child = pb.start(); String threadName = Thread.currentThread().getName(); final List<String> childErrorLog = Collections.synchronizedList(new ArrayList<String>()); final LogRedirector.LogSourceCallback callback = () -> isAlive; LogRedirector.redirect("spark-submit-stdout-redir-" + threadName, new LogRedirector(child.getInputStream(), LOG, callback)); LogRedirector.redirect("spark-submit-stderr-redir-" + threadName, new LogRedirector(child.getErrorStream(), LOG, childErrorLog, callback)); runnable = () -> { try { int exitCode = child.waitFor(); if (exitCode != 0) { List<String> errorMessages = new ArrayList<>(); synchronized (childErrorLog) { for (String line : childErrorLog) { if (StringUtils.containsIgnoreCase(line, "Error")) { errorMessages.add("\"" + line + "\""); } } } String errStr = errorMessages.isEmpty() ? "?" : Joiner.on(',').join(errorMessages); rpcServer.cancelClient(clientId, new RuntimeException("spark-submit process failed " + "with exit code " + exitCode + " and error " + errStr)); } } catch (InterruptedException ie) { LOG.warn( "Thread waiting on the child process (spark-submit) is interrupted, killing the child process."); rpcServer.cancelClient(clientId, "Thread waiting on the child process (spark-submit) is interrupted"); Thread.interrupted(); child.destroy(); } catch (Exception e) { String errMsg = "Exception while waiting for child process (spark-submit)"; LOG.warn(errMsg, e); rpcServer.cancelClient(clientId, errMsg); } return null; }; FutureTask<Void> futureTask = new FutureTask<>(runnable); Thread driverThread = new Thread(futureTask); driverThread.setDaemon(true); driverThread.setName("SparkSubmitMonitor"); driverThread.start(); return futureTask; }
From source file:org.apache.james.mailbox.cassandra.mail.CassandraMailboxMapper.java
@Override public Mailbox findMailboxByPath(MailboxPath path) throws MailboxException { try {/* w w w .j av a 2s . co m*/ return mailboxPathDAO.retrieveId(path).thenCompose(cassandraIdOptional -> cassandraIdOptional .map(CassandraMailboxPathDAO.CassandraIdAndPath::getCassandraId) .map(mailboxDAO::retrieveMailbox).orElse(CompletableFuture.completedFuture(Optional.empty()))) .join().orElseThrow(() -> new MailboxNotFoundException(path)); } catch (CompletionException e) { if (e.getCause() instanceof InvalidQueryException) { if (StringUtils.containsIgnoreCase(e.getCause().getMessage(), VALUES_MAY_NOT_BE_LARGER_THAN_64_K)) { throw new TooLongMailboxNameException("too long mailbox name"); } throw new MailboxException("It has error with cassandra storage", e.getCause()); } throw e; } }