List of usage examples for org.apache.commons.lang StringUtils equals
public static boolean equals(String str1, String str2)
Compares two Strings, returning true
if they are equal.
From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.ActivityReferenceXmlSerializer.java
public boolean validateElement(Activity activity, Element element) { boolean valid = true; if (element == null && activity == null) { return true; } else if ((element != null && activity == null) || (activity != null && element == null)) { return false; } else if (!StringUtils.equals(activity.getCode(), XsdAttribute.ACTIVITY_CODE.from(element))) { valid = false;/*from w w w . j av a 2s . c o m*/ } if ((activity.getSource() == null && XsdAttribute.ACTIVITY_SOURCE.from(element) != null) || (activity.getSource() != null && XsdAttribute.ACTIVITY_SOURCE.from(element) == null) || (!StringUtils.equals(activity.getSource().getName(), XsdAttribute.ACTIVITY_SOURCE.from(element)))) { valid = false; } return valid; }
From source file:gov.nih.nci.cabig.caaers.validation.annotation.UniqueIdentifierForParticipantValidator.java
/** * Will check in the DB whether there exist another participant with the same ID. *//* ww w. j a v a 2s . c o m*/ public boolean validate(final Object value) { // is value null ? if (value == null) return true; // is value not an Identifier instance ? if (!(value instanceof Identifier)) return true; Identifier other = (Identifier) value; ParticipantQuery participantQuery = new ParticipantQuery(); participantQuery.leftJoinFetchOnIdentifiers(); if (other.getValue() != null) participantQuery.filterByIdentifierValueExactMatch(other.getValue()); if (other.getType() != null) participantQuery.filterByIdentifierTypeExactMatch(other.getType()); List<Participant> participants = participantDao.searchParticipant(participantQuery); // there exist another participant with the same identifier ?. if (participants == null || participants.size() <= 0) { return true; } for (Participant p : participants) { for (Identifier identifier : p.getIdentifiers()) { if (StringUtils.equals(other.getValue(), identifier.getValue()) && StringUtils.equals(other.getType(), identifier.getType()) && !ObjectUtils.equals(other.getId(), identifier.getId())) return false; } } return true; }
From source file:net.shopxx.plugin.ccbPayment.CcbPaymentPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { PluginConfig pluginConfig = getPluginConfig(); PaymentLog paymentLog = getPaymentLog(sn); Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(); parameterMap.put("MERCHANTID", pluginConfig.getAttribute("partner")); parameterMap.put("POSID", pluginConfig.getAttribute("posId")); parameterMap.put("BRANCHID", pluginConfig.getAttribute("branchId")); parameterMap.put("ORDERID", sn); parameterMap.put("PAYMENT", paymentLog.getAmount().setScale(2).toString()); parameterMap.put("CURCODE", "01"); parameterMap.put("TXCODE", "520100"); parameterMap.put("REMARK1", "shopxx"); parameterMap.put("REMARK2", ""); if (StringUtils.equals(pluginConfig.getAttribute("isPhishing"), "true")) { String key = pluginConfig.getAttribute("key"); parameterMap.put("TYPE", "1"); parameterMap.put("PUB", StringUtils.substring(key, -30, key.length())); parameterMap.put("GATEWAY", ""); parameterMap.put("CLIENTIP", request.getRemoteAddr()); parameterMap.put("REGINFO", ""); parameterMap.put("PROINFO", ""); parameterMap.put("REFERER", ""); }/* ww w .j ava2 s . c o m*/ parameterMap.put("MAC", generateSign(parameterMap)); parameterMap.remove("PUB"); return parameterMap; }
From source file:hydrograph.ui.parametergrid.dialog.support.ParameterEditingSupport.java
@Override protected void setValue(Object element, Object userInputValue) { if (MultiParameterFileDialogConstants.PARAMETER_NAME.equals(columnName)) { if (!StringUtils.equals(((Parameter) element).getParameterName(), String.valueOf(userInputValue))) { ((Parameter) element).setParameterName(String.valueOf(userInputValue)); multiParameterFileDialog.getApplyButton().setEnabled(true); }// w ww.j a v a2 s . c o m } else if (MultiParameterFileDialogConstants.PARAMETER_VALUE.equals(columnName)) { if (!StringUtils.equals(((Parameter) element).getParameterValue(), String.valueOf(userInputValue))) { ((Parameter) element).setParameterValue(String.valueOf(userInputValue)); multiParameterFileDialog.getApplyButton().setEnabled(true); } } viewer.update(element, null); }
From source file:com.htmlhifive.tools.jslint.engine.option.CheckOptionPropertyWrapper.java
@Override public CheckOption getOption(String key, String engine) { String rawValue = optionProp.getProperty(getPrefix() + key); String[] valueClass = StringUtils.splitPreserveAllTokens(rawValue, JSLintPluginConstant.OPTION_SEPARATOR); Class<?> clazz = null;// ww w .j ava2s. c om if (StringUtils.equals(valueClass[2], "Boolean")) { clazz = Boolean.class; } else if (StringUtils.equals(valueClass[2], "Integer")) { clazz = Integer.class; } // TODO ? CheckOption option = new CheckOption(key, "", clazz, valueClass[3], valueClass[4]); option.setValue(valueClass[1]); option.setEnable(Boolean.valueOf(valueClass[0])); return option; }
From source file:com.sfs.whichdoctor.formatter.RotationFormatter.java
public static String getField(final RotationBean rotation, final String field, final String format, final PreferencesBean preferences) { String value = ""; if (rotation == null || field == null) { return value; }//from w w w.j a v a 2s . c o m if (field.compareTo("Tags") == 0) { value = OutputFormatter.toTagList(rotation.getTags()); } if (field.compareTo("GUID") == 0) { if (rotation.getGUID() > 0) { value = String.valueOf(rotation.getGUID()); } } if (field.compareTo("RotationId") == 0) { if (rotation.getId() > 0) { value = String.valueOf(rotation.getId()); } } if (field.compareTo("MIN") == 0) { if (rotation.getPerson() != null) { value = String.valueOf(rotation.getPerson().getPersonIdentifier()); } } if (field.compareTo("Title") == 0) { if (rotation.getPerson() != null) { PersonBean person = rotation.getPerson(); value = person.getTitle(); } } if (field.compareTo("Preferred Name") == 0) { if (rotation.getPerson() != null) { PersonBean person = rotation.getPerson(); value = person.getPreferredName(); } } if (field.compareTo("Last Name") == 0) { if (rotation.getPerson() != null) { PersonBean person = rotation.getPerson(); value = person.getLastName(); } } if (field.compareTo("Formatted Name") == 0) { if (rotation.getPerson() != null) { PersonBean person = rotation.getPerson(); value = OutputFormatter.toFormattedName(person); } } if (field.compareTo("Person") == 0) { if (rotation.getPerson() != null) { PersonBean person = rotation.getPerson(); value = OutputFormatter.toCasualName(person); } } if (StringUtils.equals(field, "First Organisation") && StringUtils.isNotBlank(rotation.getOrganisation1Name()) && !rotation.getInterruption()) { value = rotation.getOrganisation1Name(); if (StringUtils.isNotBlank(rotation.getOrganisation1Type())) { value += " (" + rotation.getOrganisation1Type() + ")"; } } if (StringUtils.equals(field, "Second Organisation") && StringUtils.isNotBlank(rotation.getOrganisation2Name())) { value = rotation.getOrganisation2Name(); if (StringUtils.isNotBlank(rotation.getOrganisation2Type())) { value += " (" + rotation.getOrganisation2Type() + ")"; } } if (field.compareTo("Address (mail merge)") == 0) { if (rotation.getPerson() != null) { PersonBean person = rotation.getPerson(); if (person.getAddress().size() > 0) { value = OutputFormatter.toAddress(person.getFirstAddress(), preferences); } } } if (field.compareTo("Type") == 0) { value = rotation.getRotationType(); } if (field.compareTo("Rotation Type") == 0) { value = rotation.getTrainingClass(); } if (field.compareTo("Interruption Reason") == 0) { value = rotation.getTrainingType(); if (rotation.getInterruption() && StringUtils.isNotBlank(rotation.getOrganisation1Name())) { value += " - " + rotation.getOrganisation1Name(); } } if (field.compareTo("Description") == 0) { value = rotation.getDescription(); } if (field.compareTo("Starting Date") == 0) { if (rotation.getStartDate() != null) { value = Formatter.conventionalDate(rotation.getStartDate()); } } if (field.compareTo("Completion Date") == 0) { if (rotation.getEndDate() != null) { value = Formatter.conventionalDate(rotation.getEndDate()); } } if (field.compareTo("Training Year") == 0) { if (rotation.getYear() > 0) { value = String.valueOf(rotation.getYear()); } } if (field.compareTo("Training Time") == 0) { value = String.valueOf(rotation.getTrainingTime() * 100) + "%"; } if (field.compareTo("Total Months") == 0) { value = String.valueOf(rotation.getTotalMonths()); } if (field.compareTo("Rotation Approved") == 0) { if (rotation.getAssessment() != null) { int i = 0; for (AssessmentBean assessment : rotation.getAssessment()) { if (value.compareTo("") != 0) { value += " / "; } value += assessment.getApproved(); if (assessment.getApprovedCondition().compareTo("") != 0) { value += " - " + assessment.getApprovedCondition(); } if (i < (rotation.getAssessment().size() - 1)) { value += " and "; } i++; } } } if (field.compareTo("Rotation Status") == 0) { if (rotation.getAssessment() != null) { int i = 0; for (AssessmentBean assessment : rotation.getAssessment()) { if (value.compareTo("") != 0) { value += " / "; } value += assessment.getStatus(); if (assessment.getStatusReason().compareTo("") != 0) { value += " - " + assessment.getStatusReason(); } if (i < (rotation.getAssessment().size() - 1)) { value += " and "; } i++; } } } if (field.compareTo("Supervisors") == 0) { StringBuilder supervisors = new StringBuilder(); if (rotation.getSupervisors() != null) { for (SupervisorBean supervisor : rotation.getSupervisors()) { if (supervisor.getPerson() != null) { if (supervisors.length() > 0) { supervisors.append(", "); } supervisors.append(OutputFormatter.toFormattedName(supervisor.getPerson())); if (StringUtils.isNotBlank(supervisor.getRelationshipType())) { supervisors.append(" - "); supervisors.append(supervisor.getRelationshipType()); } } } } value = supervisors.toString(); } if (field.compareTo("Created By") == 0) { value = rotation.getCreatedBy(); } if (field.compareTo("Date Created") == 0 && rotation.getCreatedDate() != null) { value = Formatter.conventionalDate(rotation.getCreatedDate()); } if (field.compareTo("Modified By") == 0) { value = rotation.getModifiedBy(); } if (field.compareTo("Date Modified") == 0 && rotation.getModifiedDate() != null) { value = Formatter.conventionalDate(rotation.getModifiedDate()); } if (value == null) { value = ""; } return value; }
From source file:edu.sampleu.travel.bo.FiscalOfficer.java
public final boolean equals(Object o) { if (o == null) return false; if (!(o instanceof FiscalOfficer)) return false; FiscalOfficer f = (FiscalOfficer) o; return StringUtils.equals(userName, f.getUserName()) && ObjectUtils.equals(id, f.getId()); }
From source file:FakeAuthenticator.java
public boolean authenticate(String username, String password) { // Never touch admin if (isAdmin(username)) { return true; }/*from ww w .ja v a2 s. c o m*/ reloadData(); checkExistence(username); String expectedPassword = data.get(username + ".password"); if (StringUtils.equals(password, expectedPassword)) { LOG.info("user {} with password {}", username, password); return true; } else { LOG.info("user " + username + " expected password " + expectedPassword + " , but was " + password); return false; } }
From source file:controllers.user.UserResumeApp.java
/** * ???????? ?//w ww. ja v a 2 s .c o m */ private static void sortJobExpList(List<JobExp> jobExps) { Collections.sort(jobExps, new Comparator<JobExp>() { public int compare(JobExp o1, JobExp o2) { if (o1 != null && o2 != null && o1.getEndYear() != null && o2.getEndYear() != null && o1.getEndMonth() != null && o2.getEndMonth() != null) { if (StringUtils.isBlank(o2.getEndYear()) || StringUtils.equals(o2.getEndYear(), "")) { return 1; } if (StringUtils.isBlank(o1.getEndYear()) || StringUtils.equals(o1.getEndYear(), "")) { return -1; } int result = Integer.valueOf(o2.getEndYear()) - Integer.valueOf(o1.getEndYear()); if (result == 0) { if (StringUtils.isBlank(o2.getEndMonth())) { return 1; } if (StringUtils.isBlank(o1.getEndMonth())) { return -1; } int result2 = Integer.valueOf(o2.getEndMonth()) - Integer.valueOf(o1.getEndMonth()); if (result2 == 0) { int result3 = Integer.valueOf(o2.getBeginYear()) - Integer.valueOf(o1.getBeginYear()); if (result3 == 0) { return Integer.valueOf(o2.getBeginMonth()) - Integer.valueOf(o1.getBeginMonth()); } else { return result3; } } else { return result2; } } else { return result; } } return 0; } }); }
From source file:com.alibaba.cobar.manager.util.CobarStringUtil.java
/** * e.g. {"mysql_1","mysql_2","mysql_3","mysql_5"} will return * {"mysql_$1-3","mysql_5"}<br/>/*from www . jav a 2 s .co m*/ * only merge last number */ public static List<String> mergeListedString(String[] input) { if (input == null || input.length < 1) return Collections.emptyList(); if (input.length == 1) { List<String> rst = new ArrayList<String>(1); rst.add(input[0]); return rst; } List<String> list = new ArrayList<String>(input.length); for (String str : input) list.add(str); Collections.sort(list, new Comparator<String>() { @Override public int compare(String o1, String o2) { if (StringUtils.equals(o1, o2)) return 0; if (o1.length() == o2.length()) return o1.compareTo(o2); return o1.length() < o2.length() ? -1 : 1; } }); List<String> rst = new ArrayList<String>(); String prefix = null; Integer from = null; Integer to = null; String last = list.get(0); for (int i = 1; i < list.size(); ++i) { String cur = list.get(i); if (StringUtils.equals(last, cur)) continue; int commonInd = indexOfLastEqualCharacter(last, cur); boolean isCon = false; if (commonInd >= 0) { String suffixLast = last.substring(1 + commonInd); String suffixCur = cur.substring(1 + commonInd); try { int il = Integer.parseInt(suffixLast); int ic = Integer.parseInt(suffixCur); if (ic - il == 1) isCon = true; } catch (Exception e) { } } if (isCon) { if (prefix == null) prefix = last.substring(0, commonInd + 1); if (from == null) from = Integer.parseInt(last.substring(commonInd + 1)); to = Integer.parseInt(cur.substring(commonInd + 1)); } else if (prefix != null) { rst.add(new StringBuilder(prefix).append('$').append(from).append('-').append(to).toString()); prefix = null; from = to = null; } else { rst.add(last); } last = cur; } if (prefix != null) { rst.add(new StringBuilder(prefix).append('$').append(from).append('-').append(to).toString()); prefix = null; from = to = null; } else { rst.add(last); } return rst; }