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:com.jgui.ttscrape.Show.java

/**
 * Return a ToStringBuilder.reflectionToString representation of this show.
 *///from  w  w  w  . j a  v  a  2  s . c  o m
public String toString() {
    String tmpSubtitle = subtitle;
    String tmpTitle = title;

    if (subtitle != null) {
        subtitle = StringUtils.replaceChars(subtitle, ',', ' ');
    }
    if (title != null) {
        title = StringUtils.replaceChars(title, ',', ' ');
    }
    String rv = ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    subtitle = tmpSubtitle;
    title = tmpTitle;
    return rv;
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.AbstractSonarMavenConfig.java

/**
 * Constructor/*from  w w w. j a  v a2  s.  c  o  m*/
 *
 * @param taskContext the {@link TaskContext} of the current executing taks
 * @param capabilityContext the {@link CapabilityContext}
 * @param environmentVariableAccessor the {@link EnvironmentVariableAccessor} implementation
 * @param capabilityPrefix the capability prefix of the Maven executable
 * @param executableName the executable name
 */
public AbstractSonarMavenConfig(@NotNull TaskContext taskContext, @NotNull CapabilityContext capabilityContext,
        @NotNull EnvironmentVariableAccessor environmentVariableAccessor, @NotNull String capabilityPrefix,
        @NotNull String executableName) {
    this.executableName = executableName;
    String builderLabel = (String) Preconditions.checkNotNull(taskContext.getConfigurationMap().get("label"),
            "Builder label is not defined");
    this.builderPath = ((String) Preconditions.checkNotNull(
            capabilityContext.getCapabilityValue(capabilityPrefix + "." + builderLabel),
            "Builder path is not defined"));
    String environmentVariables = taskContext.getConfigurationMap().get(CFG_ENVIRONMENT_VARIABLES);
    StringBuilder rawGoals = new StringBuilder();
    if (taskContext.getConfigurationMap().getAsBoolean(CFG_SONAR_PLUGIN_PREINSTALLED)) {
        rawGoals.append(SONAR_PLUGIN_GOAL);
    } else {
        rawGoals.append(SONAR_PLUGIN_GROUPID).append(":").append(SONAR_PLUGIN_ARTIFACTID).append(":")
                .append(getSonarMavenPluginVersion());
    }
    rawGoals.append(":").append(SONAR_PLUGIN_GOAL);
    if (StringUtils.isNotBlank(taskContext.getConfigurationMap().get(CFG_SONAR_EXTRA_CUSTOM_PARAMETERS))) {
        rawGoals.append(" ")
                .append(StringUtils.replaceChars(
                        (String) taskContext.getConfigurationMap().get(CFG_SONAR_EXTRA_CUSTOM_PARAMETERS),
                        "\r\n", "  "));
    }
    List<String> goals = CommandlineStringUtils.tokeniseCommandline(rawGoals.toString());
    this.hasTests = taskContext.getConfigurationMap().getAsBoolean(CFG_HAS_TESTS);
    String projectFilename = taskContext.getConfigurationMap().get(CFG_PROJECT_FILENAME);
    this.testResultsFilePattern = taskContext.getConfigurationMap().get(CFG_TEST_RESULTS_FILE_PATTERN);
    this.workingDirectory = taskContext.getWorkingDirectory();
    this.commandline.add(getMavenExecutablePath(this.builderPath));
    if (StringUtils.isNotEmpty(projectFilename)) {
        this.commandline.addAll(Arrays.asList(new String[] { "-f", projectFilename }));
    }
    this.commandline.addAll(goals);
    this.extraEnvironment
            .putAll(environmentVariableAccessor.splitEnvironmentAssignments(environmentVariables, false));
}

From source file:br.com.nordestefomento.jrimum.vallia.digitoverificador.BoletoLinhaDigitavelDV.java

/**
 * @see br.com.nordestefomento.jrimum.vallia.digitoverificador.AbstractDigitoVerificador#calcule(java.lang.String)
 * @since 0.2// w  w  w.  j  av  a 2 s  . c o  m
 */
@Override
public int calcule(String numero) throws IllegalArgumentException {

    int dv = 0;
    int resto = 0;

    if (StringUtils.isNotBlank(numero) && Pattern.matches(REGEX_CAMPO, numero)) {

        numero = StringUtils.replaceChars(numero, ".", "");

        resto = modulo10.calcule(numero);

        if (resto != 0)
            dv = modulo10.valor() - resto;
    } else
        throw new IllegalArgumentException("O campo [ " + numero
                + " ] da linha digitvel deve conter apenas nmeros com 9 ou 10 dgitos !");

    return dv;
}

From source file:lambda.MarketplaceToMailChimp.java

private Either<Exception, String> registerNewEvaluation(License license) {
    License.ContactDetails contactDetails = license.getContactDetails();

    Option<License.Contact> contact = contactDetails.getTechnicalContact()
            .orElse(contactDetails.getBillingContact());

    for (License.Contact c : contact) {
        for (String email : c.getEmail()) {
            EditMemberMethod.CreateOrUpdate createOrUpdate = new EditMemberMethod.CreateOrUpdate(
                    getenv("MAILCHIMP_LIST_ID"), email);
            createOrUpdate.status = "subscribed";

            createOrUpdate.merge_fields = new MailchimpObject();
            createOrUpdate.merge_fields.mapping.put("COMPANY", contactDetails.getCompany());
            for (String name : c.getName()) {
                createOrUpdate.merge_fields.mapping.put("NAME", name);
            }/*from   w  w  w. j ava  2 s.com*/

            String addonKeyEnv = StringUtils.replaceChars(license.getAddonKey(), "-.", "__");
            String mailChimpInterest = getenv("MAILCHIMP_INTEREST_" + addonKeyEnv);
            if (isNotBlank(mailChimpInterest)) {
                createOrUpdate.interests = new MailchimpObject();
                createOrUpdate.interests.mapping.put(mailChimpInterest, true);
            }

            try {
                mailchimpClient.get().execute(createOrUpdate);
                return Either.right(email);
            } catch (Exception e) {
                return Either.left(e);
            }
        }
    }

    return Either.left(new RuntimeException("No contact was found"));
}

From source file:br.com.nordestefomento.jrimum.vallia.digitoverificador.CPFDV.java

/**
 * @see br.com.nordestefomento.jrimum.vallia.digitoverificador.AbstractDigitoVerificador#calcule(java.lang.String)
 * @since 0.2/*w ww.  ja v a  2  s . c om*/
 */
@Override
public int calcule(String numero) throws IllegalArgumentException {

    int dv1 = 0;
    int dv2 = 0;
    boolean isFormatoValido = false;

    validacao: {

        if (StringUtils.isNotBlank(numero)) {

            isFormatoValido = (Pattern.matches(REGEX_CPF_DV, numero)
                    || Pattern.matches(REGEX_CPF_DV_FORMATTED, numero));

            if (isFormatoValido) {

                numero = StringUtils.replaceChars(numero, ".", "");

                dv1 = calcule(numero, 10);
                dv2 = calcule(numero + dv1, 11);

                break validacao;
            }
        }

        throw new IllegalArgumentException("O CPF [ " + numero
                + " ] deve conter apenas nmeros, sendo eles no formato ###.###.### ou ######### !");

    }

    return Integer.parseInt(dv1 + "" + dv2);

}

From source file:br.com.nordestefomento.jrimum.vallia.digitoverificador.CNPJDV.java

/**
 * @see br.com.nordestefomento.jrimum.vallia.digitoverificador.AbstractDigitoVerificador#calcule(java.lang.String)
 * @since 0.2//  w w w .ja  va 2 s . c  om
 */
@Override
public int calcule(String numero) throws IllegalArgumentException {

    int dv1 = 0;
    int dv2 = 0;

    boolean isFormatoValido = false;

    validacao: {

        if (StringUtils.isNotBlank(numero)) {

            isFormatoValido = (Pattern.matches(REGEX_CNPJ_DV, numero)
                    || Pattern.matches(REGEX_CNPJ_DV_FORMATTED, numero));

            if (isFormatoValido) {

                numero = StringUtils.replaceChars(numero, ".", "");
                numero = StringUtils.replaceChars(numero, "/", "");

                dv1 = calculeDigito(numero);
                dv2 = calculeDigito(numero + dv1);

                break validacao;
            }
        }

        throw new IllegalArgumentException("O CNPJ [ " + numero
                + " ] deve conter apenas nmeros, sendo eles no formato ##.###.###/#### ou ############ !");

    }

    return Integer.parseInt(dv1 + "" + dv2);

}

From source file:com.googlecode.gmaps4jsf.jsfplugin.mojo.BaseFacesMojo.java

protected String createPackageDirectory(String outputPath, Component component) {
    String basePackage = StringUtils.replaceChars(component.getPackage(), '.', File.separatorChar);
    String packagePath = outputPath + File.separator + basePackage;
    File packageDirectory = new File(packagePath);
    if (!packageDirectory.exists())
        packageDirectory.mkdirs();/*w ww  .  j  a  v  a  2s  . co  m*/

    return packagePath;
}

From source file:edu.ku.brc.specify.conversion.SynonymCleanup.java

/**
 * @param doCleanup//from  w w w. ja va  2s.c o m
 * @param progressFrame
 */
public SynonymCleanup(final boolean doCleanup) {
    super();

    this.doCleanup = doCleanup;
    this.conn = DBConnection.getInstance().getConnection();

    this.collectionName = AppContextMgr.getInstance().getClassObject(Collection.class).getCollectionName();

    SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMddhhmmss"); //$NON-NLS-1$
    String dateStr = dateFormatter.format(Calendar.getInstance().getTime());
    String dirPath = getAppDataDir() + File.separator;
    String colNm = StringUtils.replaceChars(this.collectionName, ' ', '_');
    tmpReportName = dirPath + String.format(tmpReportName, colNm, dateStr);
    reportName = dirPath + String.format(reportName, colNm, dateStr);

    String msg = String.format("Synonym Cleanup for %s", collectionName);
    UIRegistry.writeSimpleGlassPaneMsg(msg, 24);

    progressFrame = new ProgressFrame(msg);
    progressFrame.turnOffOverAll();
    progressFrame.setDesc(doCleanup ? "Cleaning up Synonyms..." : "Creating Synonym Report...");
    progressFrame.adjustProgressFrame();
    progressFrame.getProcessProgress().setIndeterminate(true);
    progressFrame.getCloseBtn().setVisible(false);
    UIHelper.centerAndShow(progressFrame);
    progressFrame.toFront();
    progressFrame.setAlwaysOnTop(true);

    UIRegistry.pushWindow(progressFrame);
}

From source file:com.jaspersoft.studio.community.utils.CommunityAPIUtils.java

/**
 * @return software and hardware info./*  ww w.j a  va  2 s  . com*/
 */
public static String getHardwareSoftwareInfo() {
    BrandingInfo currBranding = JaspersoftStudioPlugin.getInstance().getBrandingInformation();
    String c = ""; //$NON-NLS-1$
    c += "Product Name: " + currBranding.getProductName() + CR; //$NON-NLS-1$
    c += "Product Version: " + currBranding.getProductVersion() + CR; //$NON-NLS-1$
    c += "Installation Path: " + getInstallationPath(currBranding.getProductMainBundleID()) + CR; //$NON-NLS-1$
    c += "Eclipse Version: " + PlatformInfo.getEclipseVersion().toString() //$NON-NLS-1$
            + CR;
    c += "Eclipse Build Name: " + PlatformInfo.getEclipseBuildName() + CR; //$NON-NLS-1$
    c += "Eclipse Build ID: " + PlatformInfo.getEclipseBuildId() + CR; //$NON-NLS-1$
    c += "IDE Name: " + PlatformInfo.getIDEName() + CR; //$NON-NLS-1$
    c += "IDE Version: " + PlatformInfo.getIDEVersionString() + CR; //$NON-NLS-1$
    c += "IDE NL: " + PlatformInfo.getIDENL() + CR; //$NON-NLS-1$
    c += "Eclipse Commands: " //$NON-NLS-1$
            + StringUtils.replaceChars(getSystemProperty("eclipse.commands"), "\n\r", " ") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            + CR;
    c += "Eclipse VM: " + getSystemProperty("eclipse.vm") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    c += "Eclipse VM Args: " + getSystemProperty("eclipse.vmargs") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    c += "OS Name: " + getSystemProperty("os.name") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    c += "OS Arch: " + getSystemProperty("os.arch") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    c += "OS Version: " + getSystemProperty("os.version") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    String linuxDescription = getLinuxDescription();
    if (!StringUtils.isEmpty(linuxDescription)) {
        c += "Linux Description: " + linuxDescription + CR; //$NON-NLS-1$
    }
    String m_mozillaResult = tryCreateMozilla();
    if (!StringUtils.isEmpty(m_mozillaResult)) {
        c += "Browser Creation Result: " + m_mozillaResult + CR; //$NON-NLS-1$
    }
    Runtime runtime = Runtime.getRuntime();
    c += "Available Processors: " + runtime.availableProcessors() + CR; //$NON-NLS-1$
    c += "Memory Max: " + runtime.maxMemory() + CR; //$NON-NLS-1$
    c += "Memory Total: " + runtime.totalMemory() + CR; //$NON-NLS-1$
    c += "Memory Free: " + runtime.freeMemory() + CR; //$NON-NLS-1$
    c += "Java Vendor: " + getSystemProperty("java.vendor") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    c += "Java Version: " + getSystemProperty("java.version") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    c += "Java Library Path: " + getSystemProperty("java.library.path") + CR; //$NON-NLS-1$ //$NON-NLS-2$
    return c;
}

From source file:com.bibisco.manager.TextEditorManager.java

private static void parseTextNode(HtmlParsingResult pHtmlParsingResult, Node pNode) {

    List<String> lListWords = new ArrayList<String>();

    mLog.debug("Start parseTextNode(HtmlParsingResult, Node): ", pNode.toString());

    // character count
    String lStrNodeText = StringUtils.replace(pNode.toString(), "&nbsp;", " ");
    lStrNodeText = StringUtils.replace(lStrNodeText, "\n", "");
    lStrNodeText = StringEscapeUtils.unescapeHtml(lStrNodeText);
    pHtmlParsingResult.characterCount += lStrNodeText.length();

    // extract words
    lStrNodeText = pNode.toString();/*w w w.j a v  a 2s .  com*/
    lStrNodeText = StringUtils.replace(lStrNodeText, "&nbsp;", "");
    lStrNodeText = StringUtils.replace(lStrNodeText, "&laquo;", "");
    lStrNodeText = StringUtils.replace(lStrNodeText, "&raquo;", "");
    lStrNodeText = StringUtils.replace(lStrNodeText, "&mdash;", "");
    lStrNodeText = StringEscapeUtils.unescapeHtml(lStrNodeText);
    lStrNodeText = replaceCharIntervalWithWhiteSpace(lStrNodeText, 33, 38);
    lStrNodeText = replaceCharIntervalWithWhiteSpace(lStrNodeText, 40, 47);
    lStrNodeText = replaceCharIntervalWithWhiteSpace(lStrNodeText, 58, 64);
    lStrNodeText = replaceCharIntervalWithWhiteSpace(lStrNodeText, 91, 96);
    lStrNodeText = replaceCharIntervalWithWhiteSpace(lStrNodeText, 123, 126);
    lStrNodeText = replaceCharIntervalWithWhiteSpace(lStrNodeText, 161, 191);
    lStrNodeText = StringUtils.replaceChars(lStrNodeText, '', ' ');
    lStrNodeText = StringUtils.replaceChars(lStrNodeText, '', ' ');
    lStrNodeText = StringUtils.replaceChars(lStrNodeText, '', ' ');
    lStrNodeText = lStrNodeText.trim();

    if (StringUtils.isNotBlank(lStrNodeText)) {
        StringTokenizer lStringTokenizer = new StringTokenizer(lStrNodeText);
        while (lStringTokenizer.hasMoreTokens()) {
            lListWords.add(lStringTokenizer.nextToken());
        }
    }
    pHtmlParsingResult.words.addAll(lListWords);

    mLog.debug("End parseTextNode(HtmlParsingResult, Node)");
}