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

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

Introduction

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

Prototype

public static String substringBeforeLast(final String str, final String separator) 

Source Link

Document

Gets the substring before the last occurrence of a separator.

Usage

From source file:tw.edu.chit.service.impl.AdminManagerImpl.java

public Map<String, Object> txRegisterUpdate(List<DynaBean> beans, FEE_TYPE feeType) throws DataAccessException {

    String sql = "";
    switch (feeType) {
    case TUITION:
        /*//w  w w. ja  va2  s  . c om
         * (?)
         * ??
         * ?
         * ??
         * ???
         */
        sql = "UPDATE Register SET TuitionAccountNo = ?, TuitionAmount = ?, TuitionDate = ? "
                + "WHERE SchoolYear = ? AND SchoolTerm = ? AND (Idno = ? Or ((SerialNo=? Or RealStudentNo=?) And Type='N'))";
        break;

    case AGENCY:
        sql = "UPDATE Register SET AgencyAccountNo = ?, AgencyAmount = ?, AgencyDate = ? "
                + "WHERE SchoolYear = ? AND SchoolTerm = ? AND (Idno = ? Or ((SerialNo=? Or RealStudentNo=?) And Type='N'))";
        break;

    case RELIEFTUITION:
        sql = "UPDATE Register SET ReliefTuitionAmount = ? "
                + "WHERE SchoolYear = ? AND SchoolTerm = ? AND Idno = ?";
        break;

    case LOAN:
        sql = "UPDATE Register SET LoanAmount = ? " + "WHERE SchoolYear = ? AND SchoolTerm = ? AND Idno = ?";
        break;

    case VULNERABLE:
        sql = "UPDATE Register SET VulnerableAmount = ? "
                + "WHERE SchoolYear = ? AND SchoolTerm = ? AND Idno = ?";
        break;

    default:
        break;
    }

    int counts = 0;
    StringBuilder builder = new StringBuilder();
    Map<String, Object> ret = new HashMap<String, Object>();
    for (DynaBean bean : beans) {
        switch (feeType) {
        case TUITION:
        case AGENCY:
            if (dao.sqlUpdate(sql,
                    new Object[] { (String) bean.get("accountNo"), (Integer) bean.get("amount"),
                            (Date) bean.get("payDate"), (String) bean.get("year"), (String) bean.get("term"),
                            (String) bean.get("idno"), (String) bean.get("studentNo"),
                            (String) bean.get("studentNo") }) == 0) {
                builder.append((String) bean.get("studentNo")).append(",");
                System.out.println((String) bean.get("idno"));
            } else
                counts++;
            //               counts += dao.sqlUpdate(sql, new Object[] {
            //                     (String) bean.get("accountNo"),
            //                     (Integer) bean.get("amount"),
            //                     (Date) bean.get("payDate"),
            //                     (String) bean.get("year"),
            //                     (String) bean.get("term"),
            //                     (String) bean.get("idno") });
            break;

        case RELIEFTUITION:
        case LOAN:
        case VULNERABLE:
            if (dao.sqlUpdate(sql, new Object[] { (Integer) bean.get("amount"), (String) bean.get("year"),
                    (String) bean.get("term"), (String) bean.get("idno") }) == 0) {
                builder.append((String) bean.get("studentNo")).append(",");
                System.out.println((String) bean.get("idno"));
            } else
                counts++;
            //               counts += dao.sqlUpdate(sql, new Object[] {
            //                     (Integer) bean.get("amount"),
            //                     (String) bean.get("year"),
            //                     (String) bean.get("term"),
            //                     (String) bean.get("idno") });
            break;
        }
    }

    ret.put("counts", counts);
    ret.put("idnos", StringUtils.substringBeforeLast(builder.toString(), ","));
    return ret;
}

From source file:uk.co.techblue.alfresco.resteasy.providers.DocumentContentProvider.java

/**
 * Gets the file prefix./*ww  w  .  ja  v a2s  .co  m*/
 * 
 * @param contentDisposition the content disposition
 * @return the file prefix
 */
private String getFilePrefix(final ContentDisposition contentDisposition) {
    final String fileName = contentDisposition.getParameter(PARAM_FILENAME);
    return StringUtils.substringBeforeLast(fileName, ".");
}

From source file:uk.co.techblue.docusign.resteasy.providers.DocumentFileProvider.java

private String getFilePrefix(ContentDisposition contentDisposition) {
    String fileName = contentDisposition.getParameter(PARAM_FILENAME);
    return StringUtils.substringBeforeLast(fileName, ".");
}