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:hydrograph.ui.graph.schema.propagation.SchemaPropagation.java

private String getPortIndex(Link link) {
    if (StringUtils.startsWithIgnoreCase(link.getSourceTerminal(), Constants.INPUT_SOCKET_TYPE)) {
        return StringUtils.remove(link.getSourceTerminal(), Constants.INPUT_SOCKET_TYPE);
    } else {//from   w  w  w. java 2  s  .c o  m
        return StringUtils.remove(link.getSourceTerminal(), Constants.OUTPUT_SOCKET_TYPE);
    }

}

From source file:eionet.cr.web.action.admin.harvestscripts.HarvestScriptParser.java

/**
 *
 * @param str// w w  w .  j ava  2s.c om
 * @param tokenToReplace
 * @param replacement
 * @return
 */
private static String replaceToken(String str, String tokenToReplace, String replacement) {

    if (str == null || str.trim().length() == 0 || tokenToReplace == null
            || tokenToReplace.trim().length() == 0) {
        return str;
    }

    StringTokenizer st = new StringTokenizer(str, " \t\n\r\f", true);
    ArrayList<String> originalTokens = new ArrayList<String>();
    ArrayList<String> upperCaseTokens = new ArrayList<String>();
    while (st.hasMoreTokens()) {
        String nextToken = st.nextToken();
        originalTokens.add(nextToken);
        upperCaseTokens.add(nextToken.toUpperCase());
    }

    StringBuilder buf = new StringBuilder();
    for (String token : originalTokens) {

        if (token.equalsIgnoreCase(tokenToReplace)) {
            buf.append(replacement);
        } else if (StringUtils.startsWithIgnoreCase(token, tokenToReplace)) {
            if (!Character.isLetterOrDigit(token.charAt(tokenToReplace.length()))) {
                buf.append(replacement).append(StringUtils.substringAfter(token, tokenToReplace));
            } else {
                buf.append(token);
            }
        } else {
            buf.append(token);
        }
    }
    return buf.toString();
}

From source file:mitm.djigzo.web.pages.portal.pdf.PDFReply.java

public String getSubject() {
    String result = replyState.getSubject();

    String replyPrefix = messages.get("subject-reply-prefix");

    /*//from   w  ww  .ja v a 2s.com
     * Add a Re: prefix to the subject if it does not already contain the prefix.
     */
    if (!StringUtils.startsWithIgnoreCase(result, replyPrefix)) {
        result = replyPrefix + " " + result;
    }

    return result;
}

From source file:com.hangum.tadpole.rdb.core.dialog.job.CreateJobDialog.java

private void initMainObject(String type) {

    try {/*w w  w.  j a v a  2s. c  om*/
        SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);

        if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PROCEDURES.name(), type)) {
            comboSubObject.setEnabled(false);
            comboSubObject.removeAll();
            showObjects = sqlClient.queryForList("procedureList", userDB.getSchema()); //$NON-NLS-1$
        } else if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PACKAGES.name(), type)) {
            showObjects = sqlClient.queryForList("packageList", userDB.getSchema()); //$NON-NLS-1$
        } else {
            comboSubObject.setEnabled(false);
            comboSubObject.removeAll();
            showObjects = new ArrayList<ProcedureFunctionDAO>();
        }

        comboObject.removeAll();
        for (ProcedureFunctionDAO dao : showObjects) {
            if (dao.getOverload() > 0) {
                comboObject.add(dao.getName() + ";" + dao.getOverload());
            } else {
                comboObject.add(dao.getName());
            }
        }
    } catch (Exception e) {
        logger.error("Initialize object", e);
    }

}

From source file:edu.monash.merc.system.parser.nextprot.NXHandler.java

private void countPeAntiEvidences(String database, String category, String accession) {
    if (StringUtils.isNotBlank(database) && StringUtils.isNotBlank(category)
            && StringUtils.isNotBlank(accession)) {
        if (StringUtils.equalsIgnoreCase(database, NXFields.XREF_DB_HPA)
                && StringUtils.equalsIgnoreCase(category, NXFields.XREF_CA_ANTIBODY_DATABASES)) {
            //ony hpa and cab accession will be taken into account
            if (StringUtils.startsWithIgnoreCase(accession, NXFields.XREF_AC_PREFIX_HPA)
                    || StringUtils.startsWithIgnoreCase(accession, NXFields.XREF_AC_PREFIX_CAB)) {
                peAntiAnnCounter++;// w  w w  .j  a  v a 2 s . c  om
            }
            peAntiAnnEvExisted = true;
        }
    }
}

From source file:adalid.util.velocity.BaseBuilder.java

private String replaceAliasWithRootFolderName(String path) {
    String p = path + "/";
    if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ALIAS)) {
        p = SOURCE_PROJECT_ROOT_FOLDER_NAME + StringUtils.removeStartIgnoreCase(p, SOURCE_PROJECT_ALIAS);
        p = StringUtils.removeEnd(p, "/");
        return p;
    }//  w  ww  . j a  va  2 s  . co  m
    return path;
}

From source file:edu.monash.merc.system.parser.nextprot.NXHandler.java

private void findPeAnTiAnnURL(String xdatabase, String xcategory, String xaccession, String xrefUrl) {

    if (StringUtils.isNotBlank(xdatabase) && StringUtils.isNotBlank(xcategory)
            && StringUtils.isNotBlank(xaccession)) {
        if (StringUtils.equalsIgnoreCase(xdatabase, NXFields.XREF_DB_HPA)
                && StringUtils.equalsIgnoreCase(xcategory, NXFields.XREF_CA_ANTIBODY_DATABASES)) {
            //using the ENSG accession as perfer hyperlink
            if (StringUtils.startsWithIgnoreCase(xaccession, NXConts.XREF_AC_PREFIX_ENSG)) {
                if (StringUtils.isNotBlank(xrefUrl)) {
                    peAntiURL = StringUtils.removeEndIgnoreCase(xrefUrl, NXFields.XREF_AC_ENSG_URL_END_PART);
                }//from  www  .  ja va  2 s . c o  m
            }
            //if no hyperlink for ensg then we have to use others
            if (StringUtils.startsWithIgnoreCase(xrefAccession, NXFields.XREF_AC_PREFIX_HPA)
                    || StringUtils.startsWithIgnoreCase(xrefAccession, NXFields.XREF_AC_PREFIX_CAB)) {
                if (StringUtils.isBlank(peAntiURL)) {
                    peAntiURL = xrefUrl;
                }
            }
        }
    }
}

From source file:com.sfs.whichdoctor.dao.AddressVerificationDAOImpl.java

/**
 * Deletes the address verification bean.
 *
 * @param addressVerification the address verification
 * @return the boolean/*w w w . j  a  va2s  . c  om*/
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final boolean delete(final AddressVerificationBean addressVerification) throws WhichDoctorDaoException {

    if (addressVerification == null) {
        throw new WhichDoctorDaoException("The address verification cannot be null");
    }
    if (addressVerification.getAddressVerificationId() < 1) {
        throw new WhichDoctorDaoException("A valid ID is required");
    }

    boolean success = false;
    int deleteCount = 0;

    try {
        deleteCount = this.getJdbcTemplateWriter().update(this.getSQL().getValue("addressVerification/delete"),
                new Object[] { addressVerification.getAddressVerificationId() });

    } catch (DataAccessException de) {
        dataLogger.error("Error deleting address verification record: " + de.getMessage());
        throw new WhichDoctorDaoException(
                "Error deleting address verification " + "record: " + de.getMessage());
    }

    if (deleteCount > 0) {
        success = true;

        // Check the verification status of the address compared to
        // what is waiting to be verified
        try {
            AddressBean address = this.addressDAO.loadGUID(addressVerification.getAddressGUID());

            Collection<AddressVerificationBean> pending = loadPendingForGUID(
                    addressVerification.getAddressGUID());

            if (StringUtils.startsWithIgnoreCase(address.getVerificationStatus(), PENDING)) {
                if (pending.size() == 0) {
                    // There are no pending records, set status to unverified
                    this.addressDAO.updateVerificationStatus("Unverified address",
                            addressVerification.getAddressGUID());
                }
            }
        } catch (WhichDoctorDaoException wde) {
            dataLogger.error("Error checking current verification of the address: " + wde.getMessage());
        }
    }
    return success;
}

From source file:adalid.util.velocity.BaseBuilder.java

private String finalisePath(String path) {
    String p = path + "/";
    if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ROOT_FOLDER_NAME)) {
        if (StringUtils.startsWithIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME)) {
            p = "${resourcesProjectFolderPath}/"
                    + StringUtils.removeStartIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${resourcesConfigurationFilesFolder}/");
            p = p.replace("/src/code/", "/${resourcesJavaMainFolder}/");
            p = p.replace("/src/copy/", "/${resourcesPacketsFolder}/");
            p = p.replace("/src/crop/", "/${resourcesBundlesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, LIB_PROJECT_FOLDER_NAME)) {
            p = "${libProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, LIB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${libConfigurationFilesFolder}/");
            p = p.replace("/src/java/code/", "/${libJavaMainFolder}/");
            p = p.replace("/src/java/copy/", "/${libJavaCopyFolder}/");
            p = p.replace("/src/java/crop/", "/${libJavaSourcesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, WAR_PROJECT_FOLDER_NAME)) {
            p = "${warProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, WAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${warConfigurationFilesFolder}/");
            p = p.replace("/src/java/code/", "/${webJavaMainFolder}/");
            p = p.replace("/src/java/copy/", "/${webJavaCopyFolder}/");
            p = p.replace("/src/java/copy-1/", "/${webJavaCopy1Folder}/");
            p = p.replace("/src/java/copy-2/", "/${webJavaCopy2Folder}/");
            p = p.replace("/src/java/crop/", "/${webJavaSourcesFolder}/");
            p = p.replace("/web/WEB-INF/", "/${webConfigurationFilesFolder}/");
            p = p.replace("/web/code/", "/${webPagesMainFolder}/");
            p = p.replace("/web/copy/", "/${webPagesCopyFolder}/");
            p = p.replace("/web/crop/", "/${webPagesSourcesFolder}/");
            p = p.replace("/web/", "/${webPagesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EJB_PROJECT_FOLDER_NAME)) {
            p = "${ejbProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EJB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${ejbConfigurationFilesFolder}/");
            p = p.replace("/src/java/code/", "/${ejbJavaMainFolder}/");
            p = p.replace("/src/java/copy/", "/${ejbJavaCopyFolder}/");
            p = p.replace("/src/java/crop/", "/${ejbJavaSourcesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EAR_PROJECT_FOLDER_NAME)) {
            p = "${earProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${earConfigurationFilesFolder}/");
        } else {//from  w  w w  .j  a  va 2s.c  o m
            p = ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + p;
        }
        p = StringUtils.removeEnd(p, "/");
        return p;
    }
    return ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + path;
}

From source file:adalid.util.velocity.SecondBaseBuilder.java

private String finalisePath(String path) {
    String p = path + "/";
    if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ROOT_FOLDER_NAME)) {
        if (StringUtils.startsWithIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME)) {
            p = "${resourcesProjectFolderPath}/"
                    + StringUtils.removeStartIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${resourcesConfigurationFilesFolder}/");
            p = p.replace("/src/main/resources/", "/${resourcesBundlesFolder}/");
            p = p.replace("/src/main/java/", "/${resourcesJavaMoreFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, LIB_PROJECT_FOLDER_NAME)) {
            p = "${libProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, LIB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${libConfigurationFilesFolder}/");
            p = p.replace("/src/main/java/", "/${libJavaMoreFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, WAR_PROJECT_FOLDER_NAME)) {
            p = "${webProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, WAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${warConfigurationFilesFolder}/");
            p = p.replace("/src/main/java/", "/${webJavaMoreFolder}/");
            p = p.replace("/src/main/webapp/WEB-INF/", "/${webConfigurationFilesFolder}/");
            p = p.replace("/src/main/webapp/", "/${webPagesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EJB_PROJECT_FOLDER_NAME)) {
            p = "${ejbProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EJB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${ejbConfigurationFilesFolder}/");
            p = p.replace("/src/main/java/", "/${ejbJavaMoreFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EAR_PROJECT_FOLDER_NAME)) {
            p = "${earProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/application/META-INF/", "/${earConfigurationFilesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, POM_PROJECT_FOLDER_NAME)) {
            p = "${rootProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, POM_PROJECT_FOLDER_NAME);
        } else {//from www  .j a  v a 2 s.c om
            p = ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + p;
        }
        p = StringUtils.removeEnd(p, "/");
        return p;
    }
    return ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + path;
}