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:gov.nih.nci.cabig.caaers.domain.dto.TermDTO.java

public void clearFields(String... fields) {
    for (String f : fields) {
        if (StringUtils.equals(f, "code"))
            setCode(null);//from  w w  w. ja v  a 2 s.  co  m
        if (StringUtils.equals(f, "name"))
            setName(null);
        if (StringUtils.equals(f, "otherSpecify"))
            setOtherSpecify(null);
    }
}

From source file:com.alibaba.otter.node.etl.common.io.EncryptUtils.java

public static byte[] decrypt(EncryptedData encode) {
    String destCrc = ChecksumUtils.checksum(encode.getData());
    //?sign/*from  www .  j  a v a  2s  .c om*/
    if (false == StringUtils.equals(encode.getCrc(), destCrc)) {
        throw new ChecksumException(String.format("orig: %s, parsed: %s not match", encode.getCrc(), destCrc));
    }

    // 
    AESUtils aes = new AESUtils();
    aes.setSecretKeyString(encode.getKey());
    // ?
    return COMPRESSOR.decompress(aes.decrypt(encode.getData()));
}

From source file:com.edm.app.auth.Auth.java

public static void robot(String robotPath) {
    BufferedReader reader = null;
    try {//from ww  w. j  av a 2  s  .co m
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(robotPath), "UTF-8"));
        String line = null;

        while ((line = reader.readLine()) != null) {
            if (StringUtils.isBlank(line)) {
                continue;
            }
            String key = StringUtils.substringBefore(line, "=");
            String val = StringUtils.substringAfter(line, "=");
            boolean r = StringUtils.equals(md5.encode(StringUtils.upperCase(key)),
                    "cebb21b542877339c40e7e8ecc96796e");
            if (StringUtils.isNotBlank(key) && r) {
                if (StringUtils.isNotBlank(val)) {
                    ROBOT = StringUtils.lowerCase(val);
                    break;
                }
            }
        }
    } catch (Exception e) {
        logger.error("(Auth:robot) error: ", e);
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException e) {
        }
    }
}

From source file:fr.inria.atlanmod.neoemf.core.impl.NeoEMFResourceFactoryImpl.java

@Override
public Resource createResource(URI uri) {
    if (StringUtils.equals(NeoEMFURI.NEOEMF_HBASE_SCHEME, uri.scheme())) {
        return new NeoEMFHbaseResourceImpl(uri);
    } else {//from w  w  w . j  a v a 2s  . c  om
        return null;
    }
}

From source file:com.assemblade.opendj.LdapUtils.java

public static void createSingleEntryModification(List<Modification> modifications, Entry currentEntry,
        String attributeName, String value) {
    AttributeType type = DirectoryServer.getAttributeType(attributeName);
    AttributeBuilder builder = new AttributeBuilder(type);
    if (currentEntry.hasAttribute(type)) {
        if (StringUtils.isEmpty(value)) {
            modifications.add(new Modification(ModificationType.DELETE, builder.toAttribute()));
        } else {/* ww  w .j a va  2 s  .co m*/
            String oldValue = getSingleAttributeStringValue(currentEntry.getAttribute(attributeName));
            if (!StringUtils.equals(oldValue, value)) {
                builder.add(value);
                modifications.add(new Modification(ModificationType.REPLACE, builder.toAttribute()));
            }
        }
    } else {
        if (StringUtils.isNotEmpty(value)) {
            builder.add(value);
            modifications.add(new Modification(ModificationType.ADD, builder.toAttribute()));
        }
    }
}

From source file:com.gongpingjia.carplay.service.util.ActivityUtil.java

private static List<ActivityWeight> sortActivityList(List<Activity> activities, Date currentTime,
        Landmark nowLandmark, double maxDistance, long maxPubTime, int genderType, Set<String> toRemoveSet) {
    ArrayList<ActivityWeight> awList = new ArrayList<>(activities.size());
    for (Activity activity : activities) {
        Map<String, Object> user = activity.getOrganizer();

        ////ww w  . j  a  v  a2s . c  o  m
        if (genderType == 0) {
            if (!StringUtils.equals(String.valueOf(user.get("gender")), Constants.UserGender.MALE)) {
                continue;
            }
        } else if (genderType == 1) {
            if (!StringUtils.equals(String.valueOf(user.get("gender")), Constants.UserGender.FEMALE)) {
                continue;
            }
        }
        if (null != toRemoveSet && !toRemoveSet.isEmpty()) {
            if (toRemoveSet.contains(activity.getActivityId())) {
                continue;
            }
        }

        ActivityWeight aw = new ActivityWeight(activity);
        //  ?
        if (StringUtils.equals(String.valueOf(user.get("licenseAuthStatus")), Constants.AuthStatus.ACCEPT)) {
            aw.setCarOwnerFlag(true);
        }
        //??
        if (StringUtils.equals(String.valueOf(user.get("photoAuthStatus")), Constants.AuthStatus.ACCEPT)) {
            aw.setAvatarFlag(true);
        }
        //TODO
        //? ????

        //???
        initWeight(currentTime, nowLandmark, aw, maxDistance, maxPubTime);
        awList.add(aw);
    }
    Collections.sort(awList);
    return awList;
}

From source file:edu.duke.cabig.c3pr.webservice.integration.XMLUtils.java

/**
 * Does deep comparison of two DOM trees represented by the given
 * {@link Element}s. Elements are considered root nodes of the trees. <br>
 * <br>/* ww  w  . j  av  a  2s.  co  m*/
 * This version of the method will <b>only</b> process elements of types
 * {@link Node#ELEMENT_NODE},{@link Node#TEXT_NODE},
 * {@link Node#CDATA_SECTION_NODE}; others will be ignored. Content of text
 * nodes is normalized before comparison. <br>
 * <br>
 * When comparing two elements, their local names, namespaces, and
 * attributes (except <code>xmlns* and xsi:type</code>) are accounted for. <br>
 * <br>
 * Due to issues with using
 * <code>setIgnoringElementContentWhitespace(true)</code>, which does not
 * seem to work, this method will throw out empty text nodes when comparing
 * children.
 * 
 * @since 1.0
 * @param e1
 * @param e2
 * @return
 */
public static boolean isDeepEqual(Node n1, Node n2) {
    if (!StringUtils.equals(n1.getLocalName(), n2.getLocalName())) {
        log.info("Node local names are not equal: " + n1.getLocalName() + " " + n2.getLocalName());
        return false;
    }
    if (!StringUtils.equals(n1.getNamespaceURI(), n2.getNamespaceURI())) {
        log.info("Node namespaces are not equal: " + n1.getNamespaceURI() + " " + n2.getNamespaceURI());
        return false;
    }
    if (n1.getNodeType() != n2.getNodeType()) {
        log.info("Node types are not equal: " + n1.getNodeType() + " " + n2.getNodeType());
        return false;
    }
    // check attributes equality.
    NamedNodeMap attrs1 = n1.getAttributes();
    NamedNodeMap attrs2 = n2.getAttributes();
    if (!isEqual(attrs1, attrs2)) {
        return false;
    }

    short nodeType = n1.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        return isDeepEqual(filterOutEmptyTextNodes(n1.getChildNodes()),
                filterOutEmptyTextNodes(n2.getChildNodes()));
    case Node.TEXT_NODE:
        return isTextNodeEqual(n1, n2);
    case Node.CDATA_SECTION_NODE:
        return isTextNodeEqual(n1, n2);
    default:
        break;
    }
    return true;
}

From source file:cn.cuizuoli.appranking.enumeration.MediaType.java

/**
 * getObject/*from  w  w w. j  a v a  2s  . com*/
 * @param code
 * @return
 */
public static MediaType getObject(String code) {
    for (MediaType mediaType : MediaType.values()) {
        if (StringUtils.equals(mediaType.getCode(), code)) {
            return mediaType;
        }
    }
    return null;
}

From source file:net.shopxx.listener.CacheEventListener.java

public void notifyElementExpired(Ehcache ehcache, Element element) {
    String cacheName = ehcache.getName();
    if (StringUtils.equals(cacheName, Article.HITS_CACHE_NAME)) {
        Long id = (Long) element.getObjectKey();
        Long hits = (Long) element.getObjectValue();
        Article article = articleService.find(id);
        if (article != null && hits != null && hits > 0) {
            article.setHits(hits);/*from   www.  ja  v a  2s  .  c o  m*/
            articleService.update(article);
        }
    } else if (StringUtils.equals(cacheName, Goods.HITS_CACHE_NAME)) {
        Long id = (Long) element.getObjectKey();
        Long hits = (Long) element.getObjectValue();
        Goods goods = goodsService.find(id);
        if (goods != null && hits != null && hits > 0) {
            goods.setHits(hits);
            goodsService.update(goods);
        }
    }
}

From source file:com.cyclopsgroup.waterview.web.TypeFieldValidator.java

/**
 * Overwrite or implement method validate()
 *
 * @see com.cyclopsgroup.waterview.web.FieldValidator#validate(com.cyclopsgroup.waterview.web.Field, java.lang.String)
 *///from   w  w w .j  av a  2 s.c o  m
public ValidationResult validate(Field field, String fieldValue) {
    try {
        Object value = TypeUtils.convert(fieldValue, field.getType());
        String string = TypeUtils.toString(value);
        return StringUtils.equals(string, field.getValue()) ? ValidationResult.SUCCESS
                : new ValidationResult(false, "Invalid " + field.getType() + " format");
    } catch (Exception e) {
        return new ValidationResult(false, e.getMessage());
    }
}