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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.model.License.java

public static License byName(String name) {
    for (License license : values()) {
        if (license.toString().equals(name) || StringUtils.equals(license.longName, name)) {
            return license;
        }//from ww  w.jav a2 s. c o  m
    }
    return UNKNOWN;
}

From source file:com.serotonin.m2m2.module.license.DataSourceTypePointsLimit.java

public static void checkLimit(String dataSourceType, ProcessResult response) {
    for (DataSourceTypePointsLimit limit : ModuleRegistry
            .getLicenseEnforcements(DataSourceTypePointsLimit.class)) {
        if (StringUtils.equals(dataSourceType, limit.getDataSourceType())) {
            // Found a limit object. 
            ModuleLicense license = ModuleRegistry.getModule(limit.getModuleName()).license();
            int pointLimit = -1;
            if (license == null)
                // No license.
                pointLimit = limit.getNoLicenselimit();
            else if (limit.getFeatureName() != null) {
                try {
                    LicenseFeature feature = license.getFeature(limit.getFeatureName());
                    if (feature != null)
                        pointLimit = Integer.parseInt(feature.getName());
                } catch (NumberFormatException e) {
                    // If the feature is non-numeric, we assume that it is unlimited.
                }// www.j a  va  2  s  .c  o  m
            }

            if (pointLimit != -1) {
                // Find out how many points there are for this type of data source.
                int count = new DataPointDao().countPointsForDataSourceType(dataSourceType);

                // Apply count restriction.
                if (count >= pointLimit)
                    response.addGenericMessage("license.dataSourcePointLimit", pointLimit);
            }
        }
    }
}

From source file:fi.foyt.fni.utils.licenses.CreativeCommonsUtils.java

public static CreativeCommonsLicense parseLicenseUrl(String url) {
    if (StringUtils.isNotBlank(url)) {
        boolean secure = url.startsWith("https:");

        url = url.substring(secure ? 6 : 5);

        if (StringUtils.startsWith(url, CreativeCommonsLicense.URL_PREFIX)) {
            String[] parts = StringUtils.substring(url, CreativeCommonsLicense.URL_PREFIX.length()).split("/");
            if (parts.length == 1) {
                // Public domain ? 
                if (StringUtils.equals(parts[0], "publicdomain")) {
                    return new CreativeCommonsLicense(secure, new String[] { "publicdomain" }, "", "");
                } else {
                    // Without jurisdiction and version
                    return new CreativeCommonsLicense(secure, parts[0].split("-"), "3.0", "");
                }//from  w  w w.  jav  a 2 s.  co m
            } else if (parts.length == 2) {
                // Without jurisdiction
                return new CreativeCommonsLicense(secure, parts[0].split("-"), parts[1], "");
            } else if (parts.length == 3) {
                // With jurisdiction
                return new CreativeCommonsLicense(secure, parts[0].split("-"), parts[1], parts[2]);
            }
        }
    }

    return null;
}

From source file:com.serotonin.m2m2.module.license.PublisherTypePointsLimit.java

public static void checkLimit(PublisherVO<? extends PublishedPointVO> publisher, ProcessResult response) {
    String publisherType = publisher.getDefinition().getPublisherTypeName();

    for (PublisherTypePointsLimit limit : ModuleRegistry
            .getLicenseEnforcements(PublisherTypePointsLimit.class)) {
        if (StringUtils.equals(publisherType, limit.getPublisherType())) {
            // Found a limit object. 
            ModuleLicense license = ModuleRegistry.getModule(limit.getModuleName()).license();
            int pointLimit = -1;
            if (license == null)
                // No license.
                pointLimit = limit.getNoLicenselimit();
            else if (limit.getFeatureName() != null) {
                try {
                    LicenseFeature feature = license.getFeature(limit.getFeatureName());
                    if (feature != null)
                        pointLimit = Integer.parseInt(feature.getName());
                } catch (NumberFormatException e) {
                    // If the feature is non-numeric, we assume that it is unlimited.
                }/*from   w  w w  .  ja  v  a 2s . c o  m*/
            }

            if (pointLimit != -1) {
                int count = new PublisherDao().countPointsForPublisherType(publisherType, publisher.getId());
                count += publisher.getPoints().size();

                // Apply count restriction.
                if (count > pointLimit)
                    response.addGenericMessage("license.publisherPointLimit", pointLimit);
            }
        }
    }
}

From source file:com.mirth.connect.util.CharsetUtils.java

/**
 * If the specified charset encoding equals DEFAULT_ENCODING or is
 * NULL/empty, then the specified default encoding will be returned. If the
 * specified default encoding is also NULL/empty then the default charset on
 * the server is returned./*from   w  ww .j  ava2s. c o  m*/
 * 
 * @param charsetEncoding
 * @param defaultEncoding
 * @return
 */
public static String getEncoding(String charsetEncoding, String defaultEncoding) {
    if (StringUtils.equals(charsetEncoding, DEFAULT_ENCODING) || StringUtils.isBlank(charsetEncoding)) {
        if (StringUtils.isNotBlank(defaultEncoding)) {
            return defaultEncoding;
        } else {
            return Charset.defaultCharset().name();
        }
    } else {
        return charsetEncoding;
    }
}

From source file:com.mirth.connect.connectors.dimse.DICOMConfigurationUtil.java

public static void configureDcmRcv(MirthDcmRcv dcmrcv, DICOMReceiver connector,
        DICOMReceiverProperties connectorProperties, String[] protocols) throws Exception {
    if (!StringUtils.equals(connectorProperties.getTls(), "notls")) {
        if (connectorProperties.getTls().equals("without")) {
            dcmrcv.setTlsWithoutEncyrption();
        } else if (connectorProperties.getTls().equals("3des")) {
            dcmrcv.setTls3DES_EDE_CBC();
        } else if (connectorProperties.getTls().equals("aes")) {
            dcmrcv.setTlsAES_128_CBC();/*from w  w w. j a  v  a  2s  .  co m*/
        }

        String trustStore = connector.getReplacer().replaceValues(connectorProperties.getTrustStore(),
                connector.getChannelId(), connector.getChannel().getName());
        if (StringUtils.isNotBlank(trustStore)) {
            dcmrcv.setTrustStoreURL(trustStore);
        }

        String trustStorePW = connector.getReplacer().replaceValues(connectorProperties.getTrustStorePW(),
                connector.getChannelId(), connector.getChannel().getName());
        if (StringUtils.isNotBlank(trustStorePW)) {
            dcmrcv.setTrustStorePassword(trustStorePW);
        }

        String keyPW = connector.getReplacer().replaceValues(connectorProperties.getKeyPW(),
                connector.getChannelId(), connector.getChannel().getName());
        if (StringUtils.isNotBlank(keyPW)) {
            dcmrcv.setKeyPassword(keyPW);
        }

        String keyStore = connector.getReplacer().replaceValues(connectorProperties.getKeyStore(),
                connector.getChannelId(), connector.getChannel().getName());
        if (StringUtils.isNotBlank(keyStore)) {
            dcmrcv.setKeyStoreURL(keyStore);
        }

        String keyStorePW = connector.getReplacer().replaceValues(connectorProperties.getKeyStorePW(),
                connector.getChannelId(), connector.getChannel().getName());
        if (StringUtils.isNotBlank(keyStorePW)) {
            dcmrcv.setKeyStorePassword(keyStorePW);
        }

        dcmrcv.setTlsNeedClientAuth(connectorProperties.isNoClientAuth());

        protocols = ArrayUtils.clone(protocols);

        if (connectorProperties.isNossl2()) {
            if (ArrayUtils.contains(protocols, "SSLv2Hello")) {
                List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols));
                protocolsList.remove("SSLv2Hello");
                protocols = protocolsList.toArray(new String[protocolsList.size()]);
            }
        } else if (!ArrayUtils.contains(protocols, "SSLv2Hello")) {
            List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols));
            protocolsList.add("SSLv2Hello");
            protocols = protocolsList.toArray(new String[protocolsList.size()]);
        }

        dcmrcv.setTlsProtocol(MirthSSLUtil.getEnabledHttpsProtocols(protocols));

        dcmrcv.initTLS();
    }
}

From source file:ch.cyberduck.core.PathRelativizer.java

public static String relativize(String root, final String path) {
    if (StringUtils.isBlank(root)) {
        return path;
    }/*from   w  w w  . j a v a 2 s  .c o  m*/
    if (!StringUtils.equals(root, String.valueOf(Path.DELIMITER))) {
        root = root + String.valueOf(Path.DELIMITER);
    }
    if (StringUtils.contains(path, root)) {
        return path.substring(path.indexOf(root) + root.length());
    }
    return path;
}

From source file:io.github.autsia.crowly.services.sentiment.Sentiment.java

public static Sentiment get(String sentiment) {
    for (Sentiment s : values()) {
        if (StringUtils.equals(sentiment, s.toString())) {
            return s;
        }/*  w ww  . java2s.c o m*/
    }
    return null;
}

From source file:com.hybris.mobile.app.commerce.utils.ArrayUtils.java

/**
 * Return the index of the value in the tab, tab.length if value not found
 *
 * @param tabToSearch//from   w w w  .  jav  a  2  s  . c  o m
 * @param valueToSearch
 * @return
 */
public static int indexOf(String[] tabToSearch, String valueToSearch) {
    int indexKey = 0;
    boolean keyFound = false;

    // Looking for the value index in the value tab
    while (!keyFound && indexKey < tabToSearch.length) {

        if (StringUtils.equals(tabToSearch[indexKey], valueToSearch)) {
            keyFound = true;
        } else {
            indexKey++;
        }

    }

    if (!keyFound) {
        indexKey--;
    }

    return indexKey;
}

From source file:com.citytechinc.cq.clientlibs.core.structures.graph.dag.EdgeType.java

public static EdgeType getEdgeType(String type) {

    for (EdgeType edgeType : values()) {

        if (StringUtils.equals(type, edgeType.getType())) {

            return edgeType;

        }//from  w w w  .j  a v  a 2s  .  c  o m

    }

    throw new IllegalArgumentException();

}