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

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

Introduction

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

Prototype

public static String replaceChars(String str, String searchChars, String replaceChars) 

Source Link

Document

Replaces multiple characters in a String in one go.

Usage

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

/**
 * Normalized URL to java recognizable form. It replace ":", "-" ... to "_".
 * //from   w  w w .  j a v  a 2  s. c o  m
 * @param scheme
 *            schema
 * @param host
 *            host name
 * @return normalized URL
 */
public static String toNormalize(BaseURIType.Scheme.Enum scheme, String host) {
    if (scheme.toString() != "http") {
        return StringUtils.replaceChars(scheme.toString() + "_" + host, "-.", "__");
    } else {
        return StringUtils.replaceChars(host, "-.", "__");
    }
}

From source file:massbank.svn.SVNUtils.java

/**
 * //w w  w.j  a  v a  2 s  .co m
 */
public static String escapeDirName(String dirName) {
    String name1 = StringUtils.replaceChars(dirName, ",.", "  ");
    String name2 = name1.trim().replaceAll(" {2,}", " ");
    String name3 = name2.replaceAll(" ", "_");
    return name3;
}

From source file:dk.dma.msinm.lucene.LuceneUtils.java

/**
 * Normalizes the string by replacing all accented chars
 * with non-accented versions/*  w ww .  j  a v  a 2 s.  co  m*/
 *
 * @param txt the text to update
 * @return the normalized text
 */
public static String normalize(String txt) {
    return StringUtils.replaceChars(txt, ACCENTED_CHARS, REPLACED_CHARS);
}

From source file:net.poemerchant.entity.Buyout.java

public Buyout(String raw) {
    this.raw = raw;
    String[] split = raw.split(" ");
    this.buyoutMode = BuyoutMode.parse(split[0]);
    String amountRaw = split[1];/*from w  w  w .j  a  v  a2s .com*/
    // for typos e.g. ~b/o 0,5 exa
    amountRaw = StringUtils.replaceChars(amountRaw, ',', '.');
    this.amount = Double.parseDouble(amountRaw);
    this.currency = Currency.parse(split[2]);
}

From source file:com.bstek.dorado.web.resolver.WebContextSupportedController.java

/**
 * URI?ContentPathURI/*  w w w  . jav a2  s. c o m*/
 */
protected String getRelativeRequestURI(HttpServletRequest request) throws UnsupportedEncodingException {
    String uri = (String) request.getAttribute("originalUrlPath");
    if (uri == null) {
        uri = request.getRequestURI().substring(getContextPath(request).length());
    }
    uri = StringUtils.replaceChars(URLDecoder.decode(uri, Configure.getString("view.uriEncoding")),
            ESCAPED_PATH_DELIM, PathUtils.PATH_DELIM);
    if (uri.length() > 1 && uri.charAt(0) == PathUtils.PATH_DELIM) {
        uri = uri.substring(1);
    }
    return uri;
}

From source file:com.hangum.tadpole.util.tables.SQLHistoryLabelProvider.java

@Override
public String getColumnText(Object element, int columnIndex) {
    if (element instanceof SQLHistoryDAO) {
        SQLHistoryDAO historyDAO = (SQLHistoryDAO) element;

        switch (columnIndex) {
        case 0:/*  w  w w.j av a 2s  . c  o m*/
            return dateToStr(historyDAO.getDateExecute());
        // ?  ?  ??  ? ?  ?     ? .
        case 1:
            return StringUtils.replaceChars(historyDAO.getStrSQLText(), "\n", " ");
        }
    } else if (element instanceof TadpoleMessageDAO) {
        TadpoleMessageDAO messageDAO = (TadpoleMessageDAO) element;

        switch (columnIndex) {
        case 0:
            return dateToStr(messageDAO.getDateExecute());
        case 1:
            return messageDAO.getStrMessage();
        }
    }

    return "### not set column ###"; //$NON-NLS-1$
}

From source file:com.hangum.tadpole.sql.util.tables.SQLHistoryLabelProvider.java

@Override
public String getColumnText(Object element, int columnIndex) {
    if (element instanceof SQLHistoryDAO) {
        SQLHistoryDAO historyDAO = (SQLHistoryDAO) element;

        switch (columnIndex) {
        case 0://from   www  . j a va 2 s  . c o m
            return dateToStr(historyDAO.getStartDateExecute());
        // ?  ?  ??  ? ?  ?     ? .
        case 1:
            return StringUtils.replaceChars(historyDAO.getStrSQLText(), "\n", " ");
        case 2:
            return "" + ((historyDAO.getEndDateExecute().getTime() - historyDAO.getStartDateExecute().getTime())
                    / 1000f);
        case 3:
            return "" + historyDAO.getRows();
        case 4:
            return historyDAO.getResult();
        case 5:
            return historyDAO.getMesssage();
        case 6:
            return historyDAO.getUserName();
        case 7:
            return historyDAO.getDbName();
        case 8:
            return historyDAO.getIpAddress();
        }
    } else if (element instanceof TadpoleMessageDAO) {
        TadpoleMessageDAO messageDAO = (TadpoleMessageDAO) element;

        switch (columnIndex) {
        case 0:
            return dateToStr(messageDAO.getDateExecute());
        case 1:
            return messageDAO.getStrViewMessage();
        }
    }

    return "### not set column ###"; //$NON-NLS-1$
}

From source file:info.magnolia.cms.taglibs.util.ConvertNewLineTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from w w  w .  ja va 2 s .  c om*/
public int doEndTag() throws JspException {
    String bodyText = bodyContent.getString();

    if (StringUtils.isNotEmpty(bodyText)) {
        StringTokenizer bodyTk = new StringTokenizer(bodyText, "\n", false); //$NON-NLS-1$
        JspWriter out = pageContext.getOut();

        try {
            if (this.para) {
                // wrap text in p
                while (bodyTk.hasMoreTokens()) {
                    out.write("<p>"); //$NON-NLS-1$
                    out.write(StringUtils.replaceChars(bodyTk.nextToken(), (char) 63, '\''));
                    out.write("</p>"); //$NON-NLS-1$
                }
            } else {
                // add newlines
                while (bodyTk.hasMoreTokens()) {
                    out.write(StringUtils.replaceChars(bodyTk.nextToken(), (char) 63, '\''));
                    if (bodyTk.hasMoreTokens()) {
                        out.write("<br/>"); //$NON-NLS-1$
                    }
                }
            }
        } catch (IOException e) {
            throw new JspTagException(e.getMessage());
        }
    }
    return EVAL_PAGE;
}

From source file:edu.ku.brc.af.ui.ProcessListUtil.java

/**
 * @return/*  w  w  w . j  av a  2s .c  o  m*/
 */
public static List<List<String>> getRunningProcessesWin() {

    List<List<String>> processList = new ArrayList<List<String>>();
    try {
        boolean doDebug = true;
        Process process = Runtime.getRuntime().exec("tasklist.exe /v /nh /FO CSV");
        BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = input.readLine()) != null) {
            if (!line.trim().isEmpty()) {
                if (doDebug && StringUtils.contains(line, "mysql")) {
                    String lineStr = StringUtils.replaceChars(line, '\\', '/');
                    System.out.println("\n[" + lineStr + "]");
                    for (String tok : parse(lineStr)) {
                        System.out.print("[" + tok + "]");
                    }
                    System.out.println();

                }
                processList.add(parse(StringUtils.replaceChars(line, '\\', '/')));
            }
        }
        input.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return processList;
}

From source file:module.signature.domain.Signature.java

/**
 * /*  www . java 2s  .c om*/
 * @param signatureFormat
 * @param signatureContent
 *            the content of the signature
 * @throws SignatureException
 *             if the signature wasn't valid or if something else went wrong
 */
public Signature(SignatureFormat signatureFormat, byte[] signatureContent, SignatureData signatureData,
        User userWhoSigned) throws SignatureException {
    if (!signatureFormat.validateSignature(signatureContent)) {
        throw new SignatureException("could.not.create.signature.as.its.invalid");
    }
    setSignatureFormat(signatureFormat);
    setSignatureData(signatureData);
    setSignedUser(userWhoSigned);
    SignatureFile signatureFile = new SignatureFile();
    signatureFile.setContent(signatureContent);
    signatureFile.setContentType(signatureFormat.getContentType());
    signatureFile
            .setFilename(StringUtils.replaceChars(signatureData.getSignatureId(), "\\/", "-") + ".xades.xml");
    signatureFile.setDisplayName("Ficheiro de assinatura: " + getSignatureData().getSignatureDescription());

    setPersistedSignature(signatureFile);
    setCreatedDateTime(new DateTime());
    //remove it as a pending signature
    signatureData.removeUserToSignPendingSignature();

}