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:com.constellio.app.modules.es.connectors.http.utils.HtmlAnchorUtils.java

public static boolean isJavascript(HtmlAnchor htmlAnchor) {
    String href = htmlAnchor.getHrefAttribute();
    if (href.length() > 0 && !href.startsWith("#")) {
        if (StringUtils.startsWithIgnoreCase(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
            // Javascript anchor
            return true;
        }//from  w w  w. j  a  va  2s . c o m
    }
    return false;
}

From source file:edu.mayo.cts2.framework.plugin.service.lexevs.uri.UriUtils.java

/**
 * Combine a URI and another token/string.
 *
 * @param uri the uri//from  w  w  w .j a  va 2s.c o  m
 * @param tokenToAppend the token to append
 * @return the string
 */
public static String combine(String uri, String tokenToAppend) {
    char lastChar = uri.charAt(uri.length() - 1);
    if (SEPARATORS.contains(lastChar)) {
        return uri + tokenToAppend;
    } else {
        if (StringUtils.startsWithIgnoreCase(uri, URN_PREFIX)) {
            return uri + URN_SEPARATOR + tokenToAppend;
        } else {
            return uri + DEFAULT_SEPARATOR + tokenToAppend;
        }
    }
}

From source file:net.sf.click.jquery.examples.services.PostCodeService.java

public List<String> getPostCodeLocations(String location) {
    List<String> list = new ArrayList<String>();

    for (PostCode postCode : getPostCodes()) {
        if (StringUtils.startsWithIgnoreCase(postCode.getLocality(), location)) {
            String value = postCode.getLocality() + ", " + postCode.getState() + " " + postCode.getPostCode();
            list.add(value);/*from  w w w .  j ava2 s. com*/
        }
    }

    Collections.sort(list);
    return list;
}

From source file:com.adaptris.core.services.metadata.compare.StartsWithIgnoreCase.java

@Override
public MetadataElement compare(MetadataElement firstItem, MetadataElement secondItem) {
    return new MetadataElement(getResultKey(),
            String.valueOf(StringUtils.startsWithIgnoreCase(firstItem.getValue(), secondItem.getValue())));
}

From source file:net.grinder.util.VersionNumber.java

/**
 * Parses a string like "1.0.2" into the version number.
 *
 * @param num parameter string/*from   ww  w  . ja  va2s.  c  om*/
 */
public VersionNumber(String num) {
    StringTokenizer tokens = new StringTokenizer(num, ".-_");
    this.digits = new int[tokens.countTokens()];
    if (this.digits.length < 2) {
        throw new IllegalArgumentException("Failed to parse " + num + " as version number");
    }

    int i = 0;
    while (tokens.hasMoreTokens()) {
        String token = tokens.nextToken().toLowerCase();
        if (token.equals("*")) {
            this.digits[i++] = 1000;
        } else if (StringUtils.startsWithIgnoreCase(token, "snapshot")) {
            this.digits[i - 1]--;
            //noinspection UnusedAssignment
            this.digits[i++] = 1000;
            break;
        } else {
            if (NumberUtils.isNumber(token)) {
                this.digits[i++] = Integer.parseInt(token);
            }
        }
    }
}

From source file:meta.paquete.base.PaqueteBase.java

@Override
public void setAlias(String alias) {
    String apodo = StringUtils.isBlank(alias) ? getClass().getSimpleName() : StringUtils.capitalize(alias);
    TipoModuloBase tipo = getTipo();/*w  ww  .j a  va  2  s .  c  o m*/
    String prefijo = tipo == null ? null : StringUtils.capitalize(tipo.name().toLowerCase());
    String mote = tipo == null || StringUtils.startsWithIgnoreCase(apodo, prefijo) ? apodo : prefijo + apodo;
    super.setAlias(mote);
}

From source file:com.alibaba.otter.node.etl.common.db.dialect.DbDialectGenerator.java

protected DbDialect generate(JdbcTemplate jdbcTemplate, String databaseName, int databaseMajorVersion,
        int databaseMinorVersion, DataMediaType dataMediaType) {
    DbDialect dialect = null;/*  w ww .  j  av a 2  s. c  o m*/

    if (StringUtils.startsWithIgnoreCase(databaseName, ORACLE)) { // for
                                                                  // oracle
        dialect = new OracleDialect(jdbcTemplate, oracleLobHandler, databaseName, databaseMajorVersion,
                databaseMinorVersion);
    } else if (StringUtils.startsWithIgnoreCase(databaseName, MYSQL)) { // for
                                                                        // mysql
        dialect = new MysqlDialect(jdbcTemplate, defaultLobHandler, databaseName, databaseMajorVersion,
                databaseMinorVersion);
    } else if (StringUtils.startsWithIgnoreCase(databaseName, TDDL_GROUP)) { // for
                                                                             // tddl
                                                                             // group
        throw new RuntimeException(databaseName + " type is not support!");
    } else if (StringUtils.startsWithIgnoreCase(databaseName, TDDL_CLIENT)) {
        throw new RuntimeException(databaseName + " type is not support!");
    }

    // diamond is delegated to mysql/oracle, so don't need to extend here

    return dialect;
}

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

@Override
public String getComandoSelect(String comando, int limite) {
    String select = StringUtils.stripToNull(comando);
    if (select != null && limite > 0) {
        boolean b1 = StringUtils.startsWithIgnoreCase(select, COMANDO_SELECT_1);
        boolean b2 = StringUtils.startsWithIgnoreCase(select, COMANDO_SELECT_2);
        if (b1 && !b2) {
            select = StringUtils.replaceOnce(select, COMANDO_SELECT_1, COMANDO_SELECT_2 + " " + limite);
        }/*from   w  ww. ja  va  2 s .  c  o m*/
    }
    return select;
}

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

@Override
public String getComandoSelect(String comando, int limite) {
    String select = super.getComandoSelect(comando, limite);
    if (select != null && limite > 0) {
        boolean b1 = StringUtils.startsWithIgnoreCase(select, COMANDO_SELECT_1);
        boolean b2 = StringUtils.startsWithIgnoreCase(select, COMANDO_SELECT_2);
        if (b1 && !b2) {
            select = StringUtils.replaceOnce(select, COMANDO_SELECT_1, COMANDO_SELECT_2 + " " + limite);
        }//from w  w w . j a  v  a2 s .c om
    }
    return select;
}

From source file:com.microsoft.alm.plugin.external.commands.InfoCommand.java

/**
 * Example of output//from  www  .  j av  a 2s .c  om
 * Local information:
 * Local path:  D:\tmp\TFVC_1\build.xml
 * Server path: $/TFVC_1/build.xml
 * Changeset:   18
 * Change:      none
 * Type:        file
 * Server information:
 * Server path:   $/TFVC_1/build.xml
 * Changeset:     18
 * Deletion ID:   0
 * Lock:          none
 * Lock owner:
 * Last modified: Nov 18, 2016 11:10:20 AM
 * Type:          file
 * File type:     windows-1252
 * Size:          1385
 */
@Override
public List<ItemInfo> parseOutput(final String stdout, final String stderr) {
    super.throwIfError(stderr);

    final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>(itemPaths.size());

    final Map<String, String> propertyMap = new HashMap<String, String>(15);
    final String[] output = getLines(stdout);

    String prefix = "";
    for (final String line : output) {
        if (StringUtils.startsWithIgnoreCase(line, "local information:")) {
            // switch to local mode
            prefix = "";
            if (!propertyMap.isEmpty()) {
                itemInfos.add(getItemInfo(propertyMap));
            }
            propertyMap.clear();
        } else if (StringUtils.startsWithIgnoreCase(line, "server information:")) {
            // switch to server mode
            prefix = "server ";
        } else if (StringUtils.isNotBlank(line)) {
            // add property
            final int colonPos = line.indexOf(":");
            if (colonPos > 0) {
                final String key = prefix + line.substring(0, colonPos).trim().toLowerCase();
                final String value = colonPos + 1 < line.length() ? line.substring(colonPos + 1).trim()
                        : StringUtils.EMPTY;
                propertyMap.put(key, value);
            }
        }
    }
    if (!propertyMap.isEmpty()) {
        itemInfos.add(getItemInfo(propertyMap));
    }
    return itemInfos;
}