List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2)
Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
null s are handled without exceptions.
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
private boolean validateSign() { if (logger.isDebugEnabled()) { logger.debug("[VALIDATE]"); }/*from w w w.jav a2 s .c o m*/ boolean isValid = true; // // Validate the Source JAR field // if (StringUtils.isBlank(activeProfile.getSourceFileFileName())) { if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) { tfSourceFile.getStyleClass().add("tf-validation-error"); } isValid = false; } else { if (!new File(activeProfile.getSourceFileFileName()).exists()) { if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) { tfSourceFile.getStyleClass().add("tf-validation-error"); } Alert alert = new Alert(Alert.AlertType.ERROR, "Specified Source " + activeProfile.getArgsType() + " does not exist"); alert.showAndWait(); isValid = false; } } // // Validate the TargetJAR field // if (StringUtils.isBlank(activeProfile.getTargetFileFileName())) { if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) { tfTargetFile.getStyleClass().add("tf-validation-error"); } isValid = false; } if (activeProfile.getArgsType() == SigningArgumentsType.FOLDER) { if (StringUtils.equalsIgnoreCase(activeProfile.getSourceFileFileName(), activeProfile.getTargetFileFileName())) { if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) { tfTargetFile.getStyleClass().add("tf-validation-error"); } Alert alert = new Alert(Alert.AlertType.ERROR, "Source folder and target folder cannot be the same"); alert.showAndWait(); isValid = false; } } // // #13 Validate the Jarsigner Config form // String jarsignerConfigField = ""; String jarsignerConfigMessage = ""; if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeystore())) { jarsignerConfigField = "Keystore"; jarsignerConfigMessage = "A keystore must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigStorepass())) { jarsignerConfigField = "Storepass"; jarsignerConfigMessage = "A password for the keystore must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigAlias())) { jarsignerConfigField = "Alias"; jarsignerConfigMessage = "An alias for the key must be specified"; } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeypass())) { jarsignerConfigField = "Keypass"; jarsignerConfigMessage = "A password for the key must be specified"; } if (StringUtils.isNotEmpty(jarsignerConfigMessage)) { if (logger.isDebugEnabled()) { logger.debug("[VALIDATE] jarsigner config not valid {}", jarsignerConfigMessage); } Alert alert = new Alert(Alert.AlertType.ERROR, "Set " + jarsignerConfigField + " in Configure"); alert.setHeaderText(jarsignerConfigMessage); FlowPane fp = new FlowPane(); Label lbl = new Label("Set " + jarsignerConfigField + " in "); Hyperlink link = new Hyperlink("Configure"); fp.getChildren().addAll(lbl, link); link.setOnAction((evt) -> { alert.close(); openJarsignerConfig(); }); alert.getDialogPane().contentProperty().set(fp); alert.showAndWait(); isValid = false; } // // #38 check keystore prior to running // KeytoolCommand keytoolCommand = keytoolCommandProvider.get(); Task<Boolean> keytoolTask = new Task<Boolean>() { @Override protected Boolean call() throws Exception { final List<String> aliases = keytoolCommand.findAliases( activeConfiguration.getKeytoolCommand().toString(), activeProfile.getJarsignerConfigKeystore(), activeProfile.getJarsignerConfigStorepass()); if (logger.isDebugEnabled()) { logger.debug("[KEYTOOL] # aliases=" + CollectionUtils.size(aliases)); } return true; } }; new Thread(keytoolTask).start(); try { if (!keytoolTask.get()) { if (logger.isDebugEnabled()) { logger.debug("[KEYTOOL] keystore or configuration not valid"); } isValid = false; } } catch (InterruptedException | ExecutionException e) { isValid = false; logger.error("error accessing keystore", e); Alert alert = new Alert(Alert.AlertType.ERROR, e.getMessage() // contains formatted string ); alert.showAndWait(); } return isValid; }
From source file:cgeo.geocaching.connector.gc.GCParser.java
public static SearchResult searchByAddress(final String address, final CacheType cacheType, final boolean showCaptcha, RecaptchaReceiver recaptchaReceiver) { if (StringUtils.isBlank(address)) { Log.e("GCParser.searchByAddress: No address given"); return null; }// w w w . j av a 2 s . com try { final JSONObject response = Network.requestJSON("http://www.geocaching.com/api/geocode", new Parameters("q", address)); if (response == null) { return null; } if (!StringUtils.equalsIgnoreCase(response.getString("status"), "success")) { return null; } if (!response.has("data")) { return null; } final JSONObject data = response.getJSONObject("data"); if (data == null) { return null; } return searchByCoords(new Geopoint(data.getDouble("lat"), data.getDouble("lng")), cacheType, showCaptcha, recaptchaReceiver); } catch (final JSONException e) { Log.w("GCParser.searchByAddress", e); } return null; }
From source file:gtu._work.ui.DirectoryCompareUI.java
private JComboBox getDiffToolComboBox() { if (diffToolComboBox == null) { DefaultComboBoxModel diffToolComboBoxModel = new DefaultComboBoxModel(); for (DiffMergeCommand e : DiffMergeCommand.values()) { diffToolComboBoxModel.addElement(e); }//from ww w .j av a2 s . c o m diffToolComboBox = new JComboBox(); diffToolComboBox.setModel(diffToolComboBoxModel); diffToolComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DiffMergeCommand e = (DiffMergeCommand) diffToolComboBox.getSelectedItem(); if (e == DiffMergeCommand.StarTeam) { String path = getStarTeamPath_FileCompareMerge(false); if (StringUtils.isBlank(path)) { try { File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { Validate.isTrue(false, "!"); } Validate.isTrue( StringUtils.equalsIgnoreCase("File Compare Merge.exe", file.getName()), "??File Compare Merge.exe"); String starTeamConfig = file.getCanonicalPath(); Properties prop = configBean.getConfigProp(); prop.setProperty(STARTEAM_KEY, starTeamConfig); configBean.store(); JCommonUtil._jOptionPane_showMessageDialog_info("?!"); } catch (Exception ex) { JCommonUtil.handleException(ex, false); } } } } }); } return diffToolComboBox; }
From source file:com.nridge.core.base.field.data.DataBag.java
/** * Returns the number of fields that match the feature name * and value parameters. The value is matched in a case * insensitive manner.//from w ww. ja v a 2s .c om * * @param aName Feature name. * @param aValue Feature value. * * @return Matching count. */ public int featureNameValueCount(String aName, String aValue) { String featureValue; int nameValueCount = 0; for (DataField dataField : mFields) { featureValue = dataField.getFeature(aName); if (StringUtils.equalsIgnoreCase(featureValue, aValue)) nameValueCount++; } return nameValueCount; }
From source file:com.norconex.commons.lang.map.Properties.java
@Override public final List<String> get(Object key) { if (!caseSensitiveKeys) { return super.get(key); }/*from w w w. j av a2 s . c o m*/ List<String> values = new ArrayList<String>(); for (String k : keySet()) { if (StringUtils.equalsIgnoreCase(k, Objects.toString(key, null))) { values.addAll(super.get(k)); } } return values; }
From source file:com.logiware.accounting.domain.EdiInvoice.java
private void createMaerskLineInvoice(File file) throws Exception { InputStream inputStream = null; try {/* w ww . ja va 2 s . com*/ TradingPartnerDAO tradingPartnerDAO = new TradingPartnerDAO(); vendorNumber = "MAEINC0001"; vendorName = tradingPartnerDAO.getAccountName(this.vendorNumber); status = ConstantsInterface.STATUS_EDI_OPEN; company = Company.MAERSK_LINE; CompanyModel companyModel = new SystemRulesDAO().getCompanyDetails(); this.billToParty = companyModel.getName() + "\n" + companyModel.getAddress(); inputStream = new FileInputStream(file); List<String> lines = IOUtils.readLines(inputStream); ediInvoiceContainers = new ArrayList<EdiInvoiceContainer>(); ediInvoiceDetails = new ArrayList<EdiInvoiceDetail>(); for (String line : lines) { if (CommonUtils.isStartsWith(line, "B3")) { String[] values = line.split("\\*"); invoiceNumber = values[2]; //Invoice Number searchInvoiceNumber = invoiceNumber.replaceAll("[^\\p{Alpha}\\p{Digit}]+", ""); etd = DateUtils.parseDate(values[6], "yyyyMMdd"); //ETD invoiceAmount = (Double.parseDouble(values[7].replaceAll("[^0-9.]", "")) / 100); //Invoice Amount eta = DateUtils.parseDate(values[9], "yyyyMMdd"); //ETA invoiceDate = DateUtils.parseDate(values[12], "yyyyMMdd"); //Invoice Date Vendor vendor = tradingPartnerDAO.getVendor(vendorNumber); Integer termValue = 0; String termDesc = "Due Upon Receipt"; if (null != vendor && null != vendor.getCterms()) { termValue = Integer.parseInt(vendor.getCterms().getCode()); termDesc = vendor.getCterms().getCodedesc(); } dueDate = DateUtils.addDays(invoiceDate, termValue); paymentTerms = termDesc; } else if (CommonUtils.isStartsWith(line, "N9")) { String[] values = line.split("\\*"); if (StringUtils.equalsIgnoreCase(values[1], "BN")) { bookingNumber = values[2]; //Booking Number } else if (StringUtils.equalsIgnoreCase(values[1], "MB")) { masterBl = values[2]; //Master BL } else if (StringUtils.equalsIgnoreCase(values[1], "SI")) { yourReference1 = values[2]; // Your Reference } } else if (CommonUtils.isStartsWith(line, "V1")) { String[] values = line.split("\\*"); vesselName = values[2]; //Vessel Name voyageNumber = values[4]; //Voyage Number } else if (CommonUtils.isStartsWith(line, "L11")) { String[] values = line.split("\\*"); if (StringUtils.equalsIgnoreCase(values[2], "BM")) { blNumber = values[1]; //Bl Number } } else if (CommonUtils.isStartsWith(line, "C3")) { String[] values = line.split("\\*"); currency = values[1]; //Currency } else if (CommonUtils.isStartsWith(line, "R4")) { String[] values = line.split("\\*"); if (StringUtils.equalsIgnoreCase(values[1], "D")) { portOfDischarge = values[4]; //Port of Discharge } else if (StringUtils.equalsIgnoreCase(values[1], "E")) { placeOfDelivery = values[4]; //Place of Delivery } else if (StringUtils.equalsIgnoreCase(values[1], "L")) { portOfLoading = values[4]; //Port of Loading } else if (StringUtils.equalsIgnoreCase(values[1], "R")) { placeOfReceipt = values[4]; //Place of Receipt } } else if (CommonUtils.isStartsWith(line, "L1")) { String[] values = line.split("\\*"); EdiInvoiceDetail ediInvoiceDetail = new EdiInvoiceDetail(); ediInvoiceDetail.setEdiInvoice(this); ediInvoiceDetail.setCurrency(currency); ediInvoiceDetail.setDescription(values[12]); //Description of Charges ediInvoiceDetail.setQuantity(values[17]); //Qty ediInvoiceDetail.setUom(values[8]); //UoM ediInvoiceDetail.setPrice(values[2]); //Unit Price ediInvoiceDetails.add(ediInvoiceDetail); } else if (CommonUtils.isStartsWith(line, "N7")) { String[] values = line.split("\\*"); ediInvoiceContainers .add(new EdiInvoiceContainer(values[1] + "-" + values[2] + "-" + values[3], this)); //Container No } } } catch (Exception e) { log.info("createMaerskLineInvoice failed on " + new Date(), e); } finally { if (null != inputStream) { inputStream.close(); } } }
From source file:com.norconex.commons.lang.map.Properties.java
@Override public final List<String> remove(Object key) { if (!caseSensitiveKeys) { return super.remove(key); }//from w w w . j a v a 2s .c om List<String> oldValues = null; List<String> keysToRemove = new ArrayList<String>(); for (Iterator<String> it = keySet().iterator(); it.hasNext();) { String k = it.next(); if (StringUtils.equalsIgnoreCase(k, Objects.toString(key, null))) { keysToRemove.add(k); } } for (String k : keysToRemove) { List<String> previous = super.remove(k); if (previous != null) { if (oldValues == null) { oldValues = new ArrayList<>(); } oldValues.addAll(previous); } } return oldValues; }
From source file:com.glaf.core.util.DBUtils.java
public static List<ColumnDefinition> getColumnDefinitions(Connection conn, String tableName) { List<ColumnDefinition> columns = new java.util.ArrayList<ColumnDefinition>(); ResultSet rs = null;//from ww w . j a va2s . c om try { List<String> primaryKeys = getPrimaryKeys(conn, tableName); String dbType = DBConnectionFactory.getDatabaseType(conn); DatabaseMetaData metaData = conn.getMetaData(); if ("h2".equals(dbType)) { tableName = tableName.toUpperCase(); } else if ("oracle".equals(dbType)) { tableName = tableName.toUpperCase(); } else if ("db2".equals(dbType)) { tableName = tableName.toUpperCase(); } else if ("mysql".equals(dbType)) { tableName = tableName.toLowerCase(); } else if ("postgresql".equals(dbType)) { tableName = tableName.toLowerCase(); } rs = metaData.getColumns(null, null, tableName, null); while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); String typeName = rs.getString("TYPE_NAME"); int dataType = rs.getInt("DATA_TYPE"); int nullable = rs.getInt("NULLABLE"); int length = rs.getInt("COLUMN_SIZE"); int ordinal = rs.getInt("ORDINAL_POSITION"); ColumnDefinition column = new ColumnDefinition(); column.setColumnName(columnName.toLowerCase()); column.setTitle(column.getName()); column.setEnglishTitle(column.getName()); column.setJavaType(FieldType.getJavaType(dataType)); column.setName(StringTools.camelStyle(column.getColumnName().toLowerCase())); if (nullable == 1) { column.setNullable(true); } else { column.setNullable(false); } column.setLength(length); column.setOrdinal(ordinal); if ("String".equals(column.getJavaType())) { if (column.getLength() > 8000) { column.setJavaType("Clob"); } } if ("Double".equals(column.getJavaType())) { if (column.getLength() == 19) { column.setJavaType("Long"); } } if (StringUtils.equalsIgnoreCase(typeName, "bool") || StringUtils.equalsIgnoreCase(typeName, "boolean") || StringUtils.equalsIgnoreCase(typeName, "bit") || StringUtils.equalsIgnoreCase(typeName, "tinyint") || StringUtils.equalsIgnoreCase(typeName, "smallint")) { column.setJavaType("Boolean"); } if (primaryKeys.contains(columnName.toLowerCase())) { column.setPrimaryKey(true); } if (!columns.contains(column)) { logger.debug("column name:" + column.getColumnName()); columns.add(column); } } return columns; } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } finally { JdbcUtils.close(rs); } }
From source file:com.dell.asm.asmcore.asmmanager.util.firmwarerepository.FirmwareUtil.java
private boolean haEnabled(ServiceTemplateComponent vcenterComponent) { ServiceTemplateSetting haSetting = vcenterComponent .getTemplateSetting(ServiceTemplateSettingIDs.SERVICE_TEMPLATE_CLUSTER_CLUSTER_HA_ID); return (StringUtils.equalsIgnoreCase("true", haSetting.getValue())); }