Example usage for org.apache.commons.lang StringUtils equals

List of usage examples for org.apache.commons.lang StringUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils equals.

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:eionet.meta.exports.VocabularyOutputHelper.java

/**
 * Finds list of data element values by name and language.
 *
 * @param elemName/*  w  w  w .ja va2 s . c  o m*/
 *            element name to be looked for
 * @param lang
 *            element lang to be looked for
 * @param elems
 *            list containing element definitions with values
 * @return list of dataelement objects containing values
 */
public static List<DataElement> getDataElementValuesByNameAndLang(String elemName, String lang,
        List<List<DataElement>> elems) {
    boolean isLangEmpty = StringUtils.isEmpty(lang);
    ArrayList<DataElement> elements = new ArrayList<DataElement>();
    if (elems != null) {
        for (List<DataElement> elem : elems) {
            if (elem == null || elem.size() < 1 || !StringUtils.equals(elem.get(0).getIdentifier(), elemName)) { // check first
                                                                                                                 // one
                continue;
            }
            for (DataElement elemMeta : elem) {
                String elemLang = elemMeta.getAttributeLanguage();
                if ((isLangEmpty && StringUtils.isEmpty(elemLang)) || StringUtils.equals(lang, elemLang)) {
                    elements.add(elemMeta);
                } else if (elements.size() > 0) {
                    break;
                }
            }
            // return elements;
        }
    }
    return elements;
}

From source file:com.edgenius.wiki.search.interceptor.CommentIndexInterceptor.java

@SuppressWarnings("unchecked")
public void afterReturning(Object retValue, Method method, Object[] args, Object target) throws Throwable {

    if (StringUtils.equals(method.getName(), CommentService.createComment)) {
        PageComment comment = (PageComment) retValue;

        log.info("JMS message send for comment index creating/updating.");
        IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_INSERT_COMMENT, comment.getUid());
        jmsTemplate.convertAndSend(queue, mqObj);

        int requireNotify = (Integer) args[3];
        sendPostNotify(comment, requireNotify);

    } else if (StringUtils.equals(method.getName(), CommentService.sendDailyCommentNotify)) {
        log.info("Send daily comment notify is invoked.");
        //Warning - this intercetor of sendDailyCommentNotify is triggered in Quartz, 
        //hibernate session available here becuase OpenSessionInView is not turned on.
        //So, don't try to use commentDAO.
        List<Integer> pageUidList = (List<Integer>) retValue;
        if (pageUidList != null) {
            for (Integer pageUid : pageUidList) {
                sendEmailNotify(null, pageUid);
            }/*from   w ww .  j  a va  2s  . c  om*/
        }
    } else if (StringUtils.equals(method.getName(), CommentService.removePageComments)) {
        List<PageComment> comments = (List<PageComment>) retValue;
        if (comments != null) {
            for (PageComment pageComment : comments) {
                log.info("JMS message send for comment index delete.");
                IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_REMOVE_COMMENT,
                        pageComment.getUid());
                jmsTemplate.convertAndSend(queue, mqObj);
            }
        }
    }

}

From source file:cn.vlabs.duckling.vwb.CPSFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    int advSiteId = Integer.parseInt(StringUtils.defaultIfEmpty(request.getParameter("as"), "-1"));

    if (advSiteId <= 0) {
        chain.doFilter(request, response);
        return;//from   w w  w.jav  a 2  s . c om
    }

    HttpServletResponse rep = (HttpServletResponse) response;
    HttpServletRequest req = (HttpServletRequest) request;
    request.setAttribute("cps", advSiteId);

    Cookie[] cookies = req.getCookies();

    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (StringUtils.equals(CPS_ADV, cookie.getName())) {
                cookie.setPath(req.getContextPath());
                cookie.setMaxAge(0);
            }
        }
    }

    Cookie myCookie = new Cookie(CPS_ADV, advSiteId + "");
    myCookie.setMaxAge(60 * 60 * 24);//
    myCookie.setPath(req.getContextPath());
    rep.addCookie(myCookie);
    chain.doFilter(request, response);
}

From source file:beans.HmacImpl.java

@Override
public boolean compare(String hmac, Object... objs) {
    return StringUtils.equals(hmac, sign(objs));
}

From source file:info.magnolia.importexport.BootstrapFilesComparator.java

@Override
public int compare(File file1, File file2) {
    String name1 = getName(file1);
    String name2 = getName(file2);

    String ext1 = getExtension(file1);
    String ext2 = getExtension(file2);

    if (StringUtils.equals(ext1, ext2)) {
        // a simple way to detect nested nodes
        if (name1.length() != name2.length()) {
            return name1.length() - name2.length();
        }// ww w .j av  a2  s.  co  m
    } else {
        // import xml first
        if (ext1.equalsIgnoreCase("xml")) {
            return -1;
        } else if (ext2.equalsIgnoreCase("xml")) {
            return 1;
        }
    }

    return name1.compareTo(name2);
}

From source file:com.activecq.api.ActiveProperties.java

/**
 * Uses reflection to create a List of the keys defined in the ActiveField subclass (and its inheritance tree).
 * Only fields that meet the following criteria are returned:
 * - public//  w  ww.  j a  va2  s .  c  o  m
 * - static
 * - final
 * - String
 * - Upper case 
 * @return a List of all the Fields
 */
@SuppressWarnings("unchecked")
public List<String> getKeys() {
    ArrayList<String> keys = new ArrayList<String>();
    ArrayList<String> names = new ArrayList<String>();
    Class cls = this.getClass();

    if (cls == null) {
        return Collections.unmodifiableList(keys);
    }

    Field fieldList[] = cls.getFields();

    for (Field fld : fieldList) {
        int mod = fld.getModifiers();

        // Only look at public static final fields
        if (!Modifier.isPublic(mod) || !Modifier.isStatic(mod) || !Modifier.isFinal(mod)) {
            continue;
        }

        // Only look at String fields
        if (!String.class.equals(fld.getType())) {
            continue;
        }

        // Only look at uppercase fields
        if (!StringUtils.equals(fld.getName().toUpperCase(), fld.getName())) {
            continue;
        }

        // Get the value of the field
        String value;
        try {
            value = StringUtils.stripToNull((String) fld.get(this));
        } catch (IllegalArgumentException e) {
            continue;
        } catch (IllegalAccessException e) {
            continue;
        }

        // Do not add duplicate or null keys, or previously added named fields
        if (value == null || names.contains(fld.getName()) || keys.contains(value)) {
            continue;
        }

        // Success! Add key to key list
        keys.add(value);

        // Add field named to process field names list
        names.add(fld.getName());

    }

    return Collections.unmodifiableList(keys);
}

From source file:com.cyclopsgroup.tornado.security.impl.DefaultUserAuthenticator.java

/**
 * Override method authenticate in class DefaultUserAuthenticator
 *
 * @see com.cyclopsgroup.tornado.security.UserAuthenticator#authenticate(java.lang.String, java.lang.String)
 *//* www  .ja  va 2 s.c om*/
public UserAuthenticationResult authenticate(String userName, String password) {
    try {
        User user = sem.findUserByName(userName);
        if (user == null) {
            return UserAuthenticationResult.NO_SUCH_USER;
        }
        if (!StringUtils.equals(user.getPrivatePassword(), password)) {
            return UserAuthenticationResult.WRONG_PASSWORD;
        }
        return UserAuthenticationResult.SUCCESS;
    } catch (Exception e) {
        getLogger().error("User authentication error", e);
        return UserAuthenticationResult.ERROR;
    }
}

From source file:com.inkubator.hrm.web.personalia.BusinessTravelDetailController.java

@PostConstruct
@Override/*from   w w w  . ja  v  a 2s .com*/
public void initialization() {
    try {
        super.initialization();
        String execution = FacesUtil.getRequestParameter("execution");
        String param = execution.substring(0, 1);
        if (StringUtils.equals(param, "e")) {
            /* parameter (id) ini datangnya dari businesstravel Flow atau View */
            selectedBusinessTravel = businessTravelService
                    .getEntityByPkWithDetail(Long.parseLong(execution.substring(1)));
        } else {
            /* parameter (activityNumber) ini datangnya dari home approval request history View */
            selectedBusinessTravel = businessTravelService
                    .getEntityByApprovalActivityNumberWithDetail(execution.substring(1));
        }

        selectedApprovalActivity = approvalActivityService
                .getEntityByActivityNumberLastSequence(selectedBusinessTravel.getApprovalActivityNumber());
        businessTravelComponents = businessTravelComponentService
                .getAllDataByBusinessTravelId(selectedBusinessTravel.getId());
        for (BusinessTravelComponent btc : businessTravelComponents) {
            totalAmount = totalAmount + btc.getPayByAmount();
        }
    } catch (Exception ex) {
        LOGGER.error("Error", ex);

    }
}

From source file:com.apexxs.neonblack.dao.FinalLocation.java

public FinalLocation(DetectedLocation dloc) {
    this.name = dloc.name;
    this.startPositions = dloc.startPos;
    this.detectedBy = dloc.detectedBy;
    this.geoNamesEntries = dloc.geoNamesEntries;
    if (this.geoNamesEntries.size() > 0) {
        this.topCandidate = checkTopCandidate(this.geoNamesEntries);
    } else {//from ww w  .  j a  va2 s.c o m
        this.topCandidate = new GeoNamesEntry();
        this.topCandidate.name = dloc.name;

    }

    if (StringUtils.equals(this.detectedBy, "RGX")) {
        if (this.topCandidate != null) {
            this.topCandidate.lonLat = String.valueOf(dloc.geocoordMatch.getLongitude()) + " "
                    + String.valueOf(dloc.geocoordMatch.getLatitude());
            Queries queries = new Queries();
            this.geoNamesEntries = queries.geoNamesWithinDistanceOf(this.topCandidate.lonLat,
                    config.getProximalDistance());
        }
    }
}

From source file:gov.nih.nci.cabig.caaers.domain.LabValue.java

@Override
public boolean equals(Object obj) {
    if (obj == this)
        return true;

    if (obj == null)
        return false;
    if (!(obj instanceof LabValue))
        return false;

    LabValue lv = (LabValue) obj;/*from w w  w.  j  a va2  s  .  co  m*/

    if (date == null && lv.date != null)
        return false;
    if (date != null && lv.date == null)
        return false;
    if (lv.date != null && !date.equals(lv.date))
        return false;

    if (!StringUtils.equals(value, lv.value))
        return false;

    return true;
}