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

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

Introduction

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

Prototype

public static String stripEnd(String str, String stripChars) 

Source Link

Document

Strips any of a set of characters from the end of a String.

Usage

From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java

static void printConstructorSchema(ConstructorDoc constr, PrintWriter out) throws Exception {
    if (constr.modifierSpecifier() == Modifier.PUBLIC) {
        String affix = constr.annotations()[0].elementValues()[1].value().toString();
        affix = StringUtils.stripEnd(StringUtils.stripStart(affix, "\""), "\"");

        out.println("<!-- " + constr.qualifiedName() + constr.signature() + " -->");
        out.println("       <xs:element name=\"" + constr.qualifiedName() + "-" + affix
                + "\" substitutionGroup=\"ABSTRACT-RULE\" >");
        out.println("        <xs:complexType> ");
        out.println("         <xs:sequence>");

        findType(constr, new Formatter(out) {

            @Override/*ww w  .j  ava2  s  . c  om*/
            public void formatElementStart(String name, String type, boolean array) {
                writer.print("           <xs:element name=\"" + name + "\" type=\"" + type + "\""
                        + (array ? " minOccurs=\"0\" maxOccurs=\"unbounded\" " : "") + ">");
            }

            @Override
            public void formatDocumentation(String doc) {
                writer.print("\n         <xs:annotation><xs:documentation xml:lang=\"en\">"
                        + StringEscapeUtils.escapeXml(doc) + "</xs:documentation></xs:annotation>");
            }

            @Override
            public void formatElementEnd(String name) {
                writer.print(" \n            </xs:element>");
            }

        });
    }
    out.println(ruleListenerDef);
    out.println("      </xs:sequence>");
    out.println("     </xs:complexType> ");
    out.println("    </xs:element>");
}

From source file:edu.ku.brc.specify.tasks.subpane.images.CollectionDataFetcher.java

/**
 * @param rs/*w w  w. j av a  2  s  . co  m*/
 * @param tableId
 * @return
 * @throws SQLException 
 */
private List<Triple<String, String, Object>> readDataIntoMap(final ResultSet rs, final int tableId)
        throws SQLException {
    List<BubbleDisplayInfo> displayInfos = bciHash.get(tableId);
    List<Triple<String, String, Object>> dataList = new ArrayList<Triple<String, String, Object>>();
    if (rs != null) {
        if (rs.next()) {
            ResultSetMetaData rsmd = rs.getMetaData();

            for (int i = 1; i < rsmd.getColumnCount(); i++) {
                BubbleDisplayInfo bdi = displayInfos.get(i - 1);
                Object val = rs.getObject(i);

                if (bdi.getColTblId() == Attachment.getClassTableId()
                        && bdi.getColumnName().equals("OrigFilename")) {
                    val = FilenameUtils.getName(val.toString());
                }

                if (bdi.getFormatter() != null) {
                    val = bdi.getFormatter().formatToUI(val);

                } else if (val instanceof Calendar) {
                    val = scrDateFormat.format((Calendar) val);

                } else if (val instanceof Date) {
                    val = scrDateFormat.format((Date) val);

                } else if (val instanceof BigDecimal) {
                    val = StringUtils.stripEnd(val.toString(), "0");

                } else if (bdi.getFieldInfo().getPickListName() != null) {
                    PickListIFace pl = PickListDBAdapterFactory.getInstance()
                            .getPickList(bdi.getFieldInfo().getPickListName());
                    if (pl != null) {
                        for (PickListItemIFace pli : pl.getItems()) {
                            if (pli.getValue() != null && pli.getValue().equals(val)) {
                                val = pli.getTitle();
                                break;
                            }
                        }
                    }
                }
                String title = getColumnTitle(bdi, tableId) + ": ";
                dataList.add(new Triple<String, String, Object>(bdi.getFieldInfo().getColumn(), title, val));
            }
            //System.out.println(rs.getObject(rsmd.getColumnCount()));
            dataList.add(new Triple<String, String, Object>("Id", "Id", rs.getObject(rsmd.getColumnCount())));
        }
        rs.close();
    }
    return dataList;
}

From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java

static void printConstructorDoc(ConstructorDoc constr, PrintWriter out) throws Exception {
    if (constr.modifierSpecifier() == Modifier.PUBLIC) {
        String affix = constr.annotations()[0].elementValues()[1].value().toString();
        affix = StringUtils.stripEnd(StringUtils.stripStart(affix, "\""), "\"");
        out.println("  <h2 id=\"Constructor " + constr.name() + "-" + affix + "\">Constructor <code>" + affix
                + "</code></h2>");
        out.println();//from   w  ww.j a va 2s. c o  m
        out.println(" <p>" + constr.commentText() + "</p>");
        out.println();
        out.println(" <p>Sample use:</p>");
        out.println("<div class=\"source\"><pre>");

        out.println(StringEscapeUtils.escapeHtml("<ac:" + constr.qualifiedName() + "-" + affix + ">"));
        findType(constr, new Formatter(out) {

            @Override
            public void formatElementStart(String name, String type, boolean array) {
                writer.print(StringEscapeUtils.escapeHtml("  <ac:" + name + " rdf:datatype=\"" + type + "\">"));
            }

            @Override
            public void formatDocumentation(String doc) {
                writer.print(" <i style=\"font-family: Times\">" + StringEscapeUtils.escapeHtml(doc) + "</i> ");
            }

            @Override
            public void formatElementEnd(String name) {
                writer.println(StringEscapeUtils.escapeHtml("</ac:" + name + ">"));
            }

        });

        out.println(StringEscapeUtils.escapeHtml("</ac:" + constr.qualifiedName() + "-" + affix + ">"));
        out.println("</pre></div>");
    }
    out.println();
    out.flush();
}

From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java

private static void setCellValueTagNumberFormat(HSSFWorkbook wb, Cell cell, Object oneCellValue,
        String vendor) {/*  www . j  a  v  a 2s. c  o  m*/
    if (oneCellValue == null) {
        cell.setCellValue(StringUtils.EMPTY);
        return;
    }

    String tagNum = StringUtils.trimToEmpty(oneCellValue.toString());
    tagNum = tagNum.replaceAll("\u00a0", StringUtils.EMPTY);
    tagNum = StringUtils.stripStart(tagNum, "0");

    if (StringUtils.contains(vendor, TOLL_COMPANY_SUN_PASS)) {
        if (StringUtils.startsWith(tagNum, "155")) {
            tagNum = StringUtils.stripEnd(tagNum, "0");
        }
    }

    cell.setCellValue(tagNum);
}

From source file:com.atlassian.jira.web.action.admin.EditApplicationProperties.java

public void setBaseURL(String baseURL) {
    //JRA-13435: Strip trailing slash if there is one.
    this.baseURL = StringUtils.stripEnd(StringUtils.strip(baseURL), " /");
}

From source file:com.lp.server.artikel.fastlanereader.ArtikellisteHandler.java

protected void prepareAbmessungen(Object[] source, Object[] target) {

    // PJ18155/*from  w  w w.j  av a2  s .c o m*/
    // String abmessungen = (String) source[19];

    String abmessungen = "";

    // Breitetext
    if (source[9] != null) {
        abmessungen += source[9];
    }

    // Breite
    if (source[10] != null) {
        abmessungen += source[10] + "x";
    }
    if (source[11] != null) {
        abmessungen += source[11] + "x";
    }
    if (source[12] != null) {
        abmessungen += source[12];
    }

    // TODO: Eigentlich falsch wenn es keine Abmessungen gibt, aber ein
    // Breitetext vom Anwender erfasst wurde der mit "x" endet (ghp)
    target[getTableColumnInformation().getViewIndex("lp.abmessungen")] = StringUtils.stripEnd(abmessungen, "x");

    // if (abmessungen.endsWith("x")) {
    // abmessungen = abmessungen.substring(0, abmessungen.length() - 1);
    // }

    // target[4] = abmessungen;
}

From source file:edu.ku.brc.specify.config.LatLonConverter.java

/**
 * Strinps any zeros at end of string, but will append a zero if string would end in a decimal.
 * @param str the string to be converted
 * @return the new string//from  w w w  .  j a va2  s. c  o m
 */
public static String stripZeroes(final String str) {
    if (str.indexOf('.') == -1) {
        return str;

    }
    // else
    String newStr = StringUtils.stripEnd(str, "0");
    if (newStr.endsWith(decimalSep)) {
        return newStr + "0";
    }
    return newStr;
}

From source file:com.haulmont.yarg.formatters.impl.XLSFormatter.java

protected String extractStyles(HSSFCell templateCell, HSSFCell resultCell, String templateCellValue,
        BandData bandData) {/*from  ww w .ja va2s  .  c  o  m*/
    for (XlsHint hint : hints) {
        XlsHint.CheckResult check = hint.check(templateCellValue);
        if (check.result) {
            templateCellValue = check.cellValue;
            hint.add(templateCell, resultCell, bandData);
        }
    }

    templateCellValue = StringUtils.stripEnd(templateCellValue, null);

    return templateCellValue;
}

From source file:com.mxhero.plugin.cloudstorage.onedrive.api.Items.java

/**
 * Clean and encode path./*from   w ww. j  av a2 s.  c  o m*/
 *
 * @param reservedCharactersType the reserved characters type
 * @param path the path
 * @return the string
 */
public static String cleanAndEncodePath(ReservedCharactersType reservedCharactersType, String path) {
    if (path != null) {
        String cleanPath = "";
        for (String segment : path.split("/")) {
            String segmentWithoutDot = segment;
            if (segmentWithoutDot.startsWith(".") || segmentWithoutDot.startsWith("~")) {
                segmentWithoutDot = segmentWithoutDot.substring(1);
            }
            String toEncode = segmentWithoutDot.replaceAll(reservedCharactersType.reservedCharacters(), " ")
                    .trim();
            try {
                cleanPath += new URIBuilder().setPath(toEncode).build().toString() + "/";
            } catch (URISyntaxException e) {
                cleanPath += toEncode + "/";
                logger.warn("onedrive_api_could_not_encode_url", toEncode);
            }
        }
        return StringUtils.stripEnd(cleanPath.substring(0, cleanPath.length() - 1), ".");
    }
    return null;
}

From source file:com.mxhero.plugin.cloudstorage.onedrive.api.Items.java

/**
 * Clean and short name.//  w  w  w  . j ava 2  s. com
 *
 * @param reservedCharactersType the reserved characters type
 * @param path the path
 * @return the string
 */
public static String cleanAndShortName(ReservedCharactersType reservedCharactersType, String path) {
    if (path != null) {
        String processedPath = path.replaceAll(reservedCharactersType.reservedCharacters(), " ").trim();
        if (processedPath.length() > Integer.parseInt(ApiEnviroment.maxFileAndFolderLenght.getValue())) {
            processedPath = processedPath.substring(0,
                    Integer.parseInt(ApiEnviroment.maxFileAndFolderLenght.getValue()));
        }
        return StringUtils.stripEnd(processedPath, ".");
    }
    return null;
}