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

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

Introduction

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

Prototype

public static boolean startsWithIgnoreCase(String str, String prefix) 

Source Link

Document

Case insensitive check if a String starts with a specified prefix.

Usage

From source file:mitm.application.djigzo.james.mailets.StripUnsupportedFormats.java

private void initAttachmentMatchers() {
    Iterator<?> it = getInitParameterNames();

    while (it.hasNext()) {
        Object o = it.next();/*from   www  . j a va2  s . co m*/

        if (!(o instanceof String)) {
            continue;
        }

        String name = (String) o;

        if (StringUtils.startsWithIgnoreCase(name, Parameter.CONTENT_WILDCARD.getName())) {
            String contentWildcard = getInitParameter(name);

            if (StringUtils.isBlank(contentWildcard)) {
                continue;
            }

            name = StringUtils.replaceOnce(name, Parameter.CONTENT_WILDCARD.getName(),
                    Parameter.FILENAME_WILDCARD.getName());

            String filenameWildcard = getInitParameter(name);

            if (StringUtils.isBlank(filenameWildcard)) {
                filenameWildcard = "*";
            }

            String[] wildcards = StringUtils.split(filenameWildcard, ',');

            for (String wildcard : wildcards) {
                attachmentMatchers.add(
                        new UnsupportedFormatStripper.MatchingPair(contentWildcard.trim(), wildcard.trim()));
            }
        }
    }
}

From source file:ips1ap101.lib.core.db.util.InterpreteSqlOracle.java

@Override
public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) {
    String command = StringUtils.stripToNull(comando);
    if (command != null) {
        String prefix;/*  w w w  .ja  v a  2 s .c  o  m*/
        String suffix;
        switch (tipoResultado) {
        case COMPOUND:
            prefix = COMANDO_EXECUTE_COMPUESTO;
            suffix = FIN_COMANDO_EXECUTE_COMPUESTO;
            break;
        case SIMPLE:
            prefix = COMANDO_EXECUTE_SIMPLE;
            suffix = FIN_COMANDO_EXECUTE_SIMPLE;
            break;
        default:
            prefix = COMANDO_EXECUTE;
            suffix = FIN_COMANDO_EXECUTE;
            break;
        }
        if (!StringUtils.startsWithIgnoreCase(command, prefix)) {
            command = prefix + " " + command;
        }
        String parametros = "";
        if (argumentos > 0) {
            for (int i = 0; i < argumentos; i++, parametros += ",?") {
            }
            parametros = "(" + parametros.substring(1) + ")";
        }
        if (!command.endsWith(";")) {
            if (!command.endsWith(parametros)) {
                command += parametros;
            }
            if (!command.endsWith(suffix)) {
                command += " " + suffix;
            }
        }
        command = StringUtils.removeEnd(command, ";");
        //          command = "{" + command + "}";
    }
    return command;
}

From source file:com.alibaba.otter.common.push.datasource.media.MediaPushDataSourceHandler.java

public static boolean isMediaPushDataSource(String url) {
    return StringUtils.startsWithIgnoreCase(url, "jdbc:") && StringUtils.containsIgnoreCase(url, "groupKey");
}

From source file:jp.primecloud.auto.process.DnsProcess.java

public void startDns(Platform platform, Long instanceNo) {
    Instance instance = instanceDao.read(instanceNo);
    // TODO CLOUD BRANCHING
    if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) {
        startDnsCloudstack(instanceNo);/*from   w  ww .j a v  a 2  s .  c o m*/
    } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) {
        if (platform.getInternal()) {
            //(VPN??)
            startDnsVcloud(instanceNo);
        } else {
            //(VPN?)
            startDnsVcloudVPN(instanceNo);
        }
        // Azure??
    } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) {
        startDnsAzure(instanceNo);
    } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) {
        startDnsOpenstack(instanceNo);
    } else if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) {
        PlatformAws platformAws = platformAwsDao.read(platform.getPlatformNo());
        if (platform.getInternal()) {
            // ???
            if (BooleanUtils.isTrue(platformAws.getEuca())) {
                // Eucalyptus??
                log.debug("DnsProcess:startDnsVpc[internal=true, vpc=euca]");
                startDnsNormalEuca(instanceNo);
            } else {
                // Amazon EC2??
                if (BooleanUtils.isTrue(platformAws.getVpc())) {
                    // VPC????
                    log.debug("DnsProcess:startDnsVpc[internal=true, vpc=true]");
                    startDnsVpc(instanceNo);
                } else {
                    // VPC????
                    log.debug("DnsProcess:startDnsNormalEc2[internal=true, vpc=false]");
                    startDnsNormalEc2(instanceNo);
                }
            }
        } else {
            // ???
            // Windows???VPN???
            Image image = imageDao.read(instance.getImageNo());
            if (StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) {
                // VPN??????
                log.debug("DnsProcess:startDnsNormalEc2[internal=false, os=windows]");
                startDnsNormalEc2(instanceNo);
            } else {
                // VPN????(VPC+VPN?????VPN)
                log.debug("DnsProcess:startDnsVpn[internal=false, os=linux]VPC+VPN");
                startDnsVpn(instanceNo);
            }
        }
    }

    // 
    instance = instanceDao.read(instanceNo);
    processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "DnsRegist",
            new Object[] { instance.getFqdn(), instance.getPublicIp() });
}

From source file:com.egt.core.db.util.InterpreteSqlOracle.java

@Override
public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) {
    String command = StringUtils.stripToNull(comando);
    if (command != null) {
        String prefix;/*www.  j a va 2  s . co  m*/
        String suffix;
        switch (tipoResultado) {
        case COMPUESTO:
            prefix = COMANDO_EXECUTE_COMPUESTO;
            suffix = FIN_COMANDO_EXECUTE_COMPUESTO;
            break;
        case SIMPLE:
            prefix = COMANDO_EXECUTE_SIMPLE;
            suffix = FIN_COMANDO_EXECUTE_SIMPLE;
            break;
        default:
            prefix = COMANDO_EXECUTE;
            suffix = FIN_COMANDO_EXECUTE;
            break;
        }
        if (!StringUtils.startsWithIgnoreCase(command, prefix)) {
            command = prefix + " " + command;
        }
        String parametros = "";
        if (argumentos > 0) {
            for (int i = 0; i < argumentos; i++, parametros += ",?") {
            }
            parametros = "(" + parametros.substring(1) + ")";
        }
        if (!command.endsWith(";")) {
            if (!command.endsWith(parametros)) {
                command += parametros;
            }
            if (!command.endsWith(suffix)) {
                command += " " + suffix;
            }
        }
        command = StringUtils.removeEnd(command, ";");
        //          command = "{" + command + "}";
    }
    return command;
}

From source file:com.alibaba.otter.manager.web.home.module.action.CanalAction.java

/**
 * canal//from w  ww  . j ava 2 s .c  o  m
 */
public void doAdd(@FormGroup("canalInfo") Group canalInfo,
        @FormGroup("canalParameterInfo") Group canalParameterInfo,
        @FormField(name = "formCanalError", group = "canalInfo") CustomErrors err,
        @FormField(name = "formHeartBeatError", group = "canalParameterInfo") CustomErrors heartBeatErr,
        Navigator nav) throws Exception {
    Canal canal = new Canal();
    CanalParameter parameter = new CanalParameter();
    canalInfo.setProperties(canal);
    canalParameterInfo.setProperties(parameter);

    String zkClustersString = canalParameterInfo.getField("zkClusters").getStringValue();
    String[] zkClusters = StringUtils.split(zkClustersString, ";");
    parameter.setZkClusters(Arrays.asList(zkClusters));

    Long zkClusterId = canalParameterInfo.getField("autoKeeperClusterId").getLongValue();
    parameter.setZkClusterId(zkClusterId);
    canal.setCanalParameter(parameter);

    String dbAddressesString = canalParameterInfo.getField("groupDbAddresses").getStringValue();
    // ??
    // 127.0.0.1:3306:MYSQL,127.0.0.1:3306:ORACLE;127.0.0.1:3306,127.0.0.1:3306;
    // ?,?
    if (StringUtils.isNotEmpty(dbAddressesString)) {
        List<List<DataSourcing>> dbSocketAddress = new ArrayList<List<DataSourcing>>();
        String[] dbAddresses = StringUtils.split(dbAddressesString, ";");
        for (String dbAddressString : dbAddresses) {
            List<DataSourcing> groupDbSocketAddress = new ArrayList<DataSourcing>();
            String[] groupDbAddresses = StringUtils.split(dbAddressString, ",");
            for (String groupDbAddress : groupDbAddresses) {
                String strs[] = StringUtils.split(groupDbAddress, ":");
                InetSocketAddress address = new InetSocketAddress(strs[0].trim(), Integer.valueOf(strs[1]));
                SourcingType type = parameter.getSourcingType();
                if (strs.length > 2) {
                    type = SourcingType.valueOf(strs[2]);
                }
                groupDbSocketAddress.add(new DataSourcing(type, address));
            }
            dbSocketAddress.add(groupDbSocketAddress);
        }

        parameter.setGroupDbAddresses(dbSocketAddress);
    }

    String positionsString = canalParameterInfo.getField("positions").getStringValue();
    if (StringUtils.isNotEmpty(positionsString)) {
        String positions[] = StringUtils.split(positionsString, ";");
        parameter.setPositions(Arrays.asList(positions));
    }

    if (parameter.getDetectingEnable()
            && StringUtils.startsWithIgnoreCase(parameter.getDetectingSQL(), "select")) {
        heartBeatErr.setMessage("invaliedHeartBeat");
        return;
    }

    try {
        canalService.create(canal);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidCanal");
        return;
    }

    if (parameter.getSourcingType().isMysql() && parameter.getSlaveId() == null) {
        parameter.setSlaveId(10000 + canal.getId());
        // ?slaveId
        try {
            canalService.modify(canal);
        } catch (RepeatConfigureException rce) {
            err.setMessage("invalidCanal");
            return;
        }
    }

    nav.redirectTo(WebConstant.CANAL_LIST_LINK);
}

From source file:com.tesora.dve.dbc.ServerDBConnection.java

public int executeUpdate(byte[] sql) throws SQLException {
    initialize();//from w w  w .  j  ava 2s. c om

    final MysqlTextResultCollector resultConsumer = new MysqlTextResultCollector();
    try {
        executeInContext(resultConsumer, sql);

        // Not the most optimal but it's the quickest way to use rows affected vs rows changed settings
        int ret = (int) resultConsumer.getNumRowsAffected();
        if (ret == 0 && resultConsumer.getInfoString() != null
                && !StringUtils.startsWithIgnoreCase(resultConsumer.getInfoString(), "Rows matched: 0")) {
            int start = StringUtils.indexOf(resultConsumer.getInfoString(), "Rows matched: ")
                    + "Rows matched: ".length();
            int end = StringUtils.indexOf(resultConsumer.getInfoString(), "Changed:");
            try {
                ret = Integer.valueOf(StringUtils.substring(resultConsumer.getInfoString(), start, end).trim());
            } catch (Exception e) {
                // do nothing take original value
            }
        }

        return ret;
    } catch (SchemaException se) {
        throw ErrorMapper.makeException(se);
    } catch (Throwable t) {
        throw new SQLException(t);
    } finally {
        ssCon.releaseNonTxnLocks();
    }
}

From source file:com.enonic.cms.upgrade.task.datasource.DataSourceConverterUpgradeModel206.java

private boolean isElExpression(final String right) {
    return StringUtils.startsWithIgnoreCase(right, "${") && StringUtils.endsWith(right, "}");
}

From source file:adalid.util.io.FileWrapper.java

/**
 * @return true if the file is a text file; false otherwise
 *///w w w  .  j av  a2  s  .  co  m
public boolean isText() {
    return StringUtils.startsWithIgnoreCase(type, "text");
}

From source file:hudson.model.AutoCompletionCandidates.java

private static boolean startsWithImpl(String str, String prefix, boolean ignoreCase) {
    return ignoreCase ? StringUtils.startsWithIgnoreCase(str, prefix) : str.startsWith(prefix);
}