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

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

Introduction

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

Prototype

public static String replace(String text, String searchString, String replacement) 

Source Link

Document

Replaces all occurrences of a String within another String.

Usage

From source file:hydrograph.ui.propertywindow.widgets.filterproperty.TransformMappingOutputTableCellModifier.java

@Override
public boolean canModify(Object element, String property) {
    FilterProperties filterProperties = (FilterProperties) element;
    if (ParameterUtil.isParameter(filterProperties.getPropertyname())) {
        filterProperties.setPropertyname(StringUtils.replace(
                StringUtils.replace(filterProperties.getPropertyname(), Constants.PARAMETER_PREFIX, ""),
                Constants.PARAMETER_SUFFIX, ""));
        return true;
    }/*  w  w  w.  java 2  s. c o m*/
    if (StringUtils.isBlank(filterProperties.getPropertyname()))
        return true;
    return false;
}

From source file:com.sfs.whichdoctor.search.http.OrganisationBasicInputHandler.java

/**
 * Process the incoming HttpRequest for search parameters.
 *
 * @param request the request// w w w.  j av a2  s.  c o  m
 * @param user the user
 *
 * @return the search bean
 */
public final SearchBean process(final HttpServletRequest request, final UserBean user) {

    SearchBean search = organisationSqlHandler.initiate(user);
    String strBasicSearch = DataFilter.getHtml(request.getParameter("Search"));

    OrganisationBean searchCriteria = (OrganisationBean) search.getSearchCriteria();

    if (StringUtils.isNotBlank(strBasicSearch)) {
        // Replace ` with ' (` is given by dynamic searches in place of
        // ' due to Javascript issues
        searchCriteria.setBasicSearch(StringUtils.replace(strBasicSearch.trim(), "`", "'"));
    }
    search.setSearchCriteria(searchCriteria);

    return search;
}

From source file:com.sfs.whichdoctor.search.http.ReimbursementBasicInputHandler.java

/**
 * Process the incoming HttpRequest for search parameters.
 *
 * @param request the request/*from   w w  w  .j  a va 2 s. c  o  m*/
 * @param user the user
 *
 * @return the search bean
 */
public final SearchBean process(final HttpServletRequest request, final UserBean user) {

    SearchBean search = reimbursementSqlHandler.initiate(user);

    String strBasicSearch = DataFilter.getHtml(request.getParameter("Search"));

    ReimbursementBean searchCriteria = (ReimbursementBean) search.getSearchCriteria();

    if (StringUtils.isNotBlank(strBasicSearch)) {
        // Replace ` with ' (` is given by dynamic searches in place of
        // ' due to Javascript issues
        searchCriteria.setBasicSearch(StringUtils.replace(strBasicSearch.trim(), "`", "'"));
    }
    search.setSearchCriteria(searchCriteria);

    return search;
}

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

/**
 * @param term/*from w w w .  ja v  a  2s  . c  o m*/
 * @param options
 */
public SearchTermField(final String term) {
    super();
    this.term = StringUtils.replace(term, "'", "''");
    this.termLowerCase = this.term.toLowerCase();
    this.options = NO_OPTIONS;
}

From source file:com.google.gdt.eclipse.designer.core.wizards.ModuleWizardTest.java

private static void assertModule_20(ModuleContents contents) throws Exception {
    assertTrue(getFolder0("src/com/mycompany/myapp").exists());
    assertTrue(getFolder0("src/com/mycompany/myapp/client").exists());
    assertTrue(getFolder0("src/com/mycompany/myapp/server").exists());
    assertFalse(getFolder0("src/com/mycompany/myapp/public").exists());
    {/*from   w  ww .  ja  va  2s  .  co  m*/
        String module = getFileContent("src/com/mycompany/myapp/MyApp.gwt.xml");
        module = StringUtils.replace(module, "\r\n", "\n");
        assertEquals(getSourceDQ(contents.getGwtXmlContentExpected()), module);
    }
    assertTrue(getFile("src/com/mycompany/myapp/client/MyApp.java").exists());
    assertTrue(getFile(contents.getWebFolderName() + "/MyApp.css").exists());
    assertTrue(getFile(contents.getWebFolderName() + "/MyApp.html").exists());
    // WEB-INF/web.xml
    {
        IFile webXml = getFile(contents.getWebFolderName() + "/WEB-INF/web.xml");
        assertTrue(webXml.exists());
        String webXmlContent = StringUtils.replace(getFileContent(webXml), "\r\n", "\n");
        assertEquals(getSourceDQ(contents.getWebXmlContentExpected()), webXmlContent);
    }
}

From source file:com.enonic.cms.core.search.query.QueryValue.java

String getWildcardValue() {
    final String replacedWildcardsString = StringUtils.replace(this.stringValue, "%", "*");
    return StringUtils.lowerCase(replacedWildcardsString);
}

From source file:com.liferay.maven.plugins.util.ContextReplace.java

private String _replace(String s, String[] oldSubs, String[] newSubs) {
    if ((s == null) || (oldSubs == null) || (newSubs == null)) {
        return null;
    }//from   w w  w  .j  a va2s  . c  o m

    if (oldSubs.length != newSubs.length) {
        return s;
    }

    for (int i = 0; i < oldSubs.length; i++) {
        s = StringUtils.replace(s, oldSubs[i], newSubs[i]);
    }

    return s;
}

From source file:net.jforum.bbcode.Google_TestCase.java

private String html(BBCode bb, String input) {
    return StringUtils.replace(bb.getReplace(), "$1", input);
}

From source file:gool.generator.objc.ObjcCodePrinter.java

@Override
public List<File> print(ClassDef pclass) throws FileNotFoundException {
    if (pclass.getParentClass() != null) {
        pclass.setParentClass(pclass.getParentClass());
    }/* w  w  w  .  ja  v  a2  s.  co  m*/

    String headerFile = processTemplate("header.vm", pclass);
    PrintWriter writer;

    File dir = new File(getOutputDir().getAbsolutePath(),
            StringUtils.replace(pclass.getPackageName(), ".", File.separator));
    dir.mkdirs();
    File classFile = new File(dir, pclass.getName() + ".h");

    writer = new PrintWriter(classFile);
    writer.println(headerFile);
    writer.close();

    if (pclass.isEnum() || pclass.isInterface()) {
        List<File> r = new ArrayList<File>();
        r.add(classFile);
        return r;
    } else {
        return super.print(pclass);
    }

}

From source file:com.adobe.acs.tools.tag_maker.tagdataconverters.impl.LowercaseWithDashesConverterImpl.java

@Override
public final TagData convert(final String data) {
    String title = data;// ww  w . ja va2s .c  o  m

    String name = data;
    name = StringUtils.stripToEmpty(name);
    name = StringUtils.lowerCase(name);
    name = StringUtils.replace(name, "&", " and ");
    name = StringUtils.replace(name, "/", " or ");
    name = StringUtils.replace(name, "%", " percent ");
    name = name.replaceAll("[^a-z0-9-]+", "-");
    name = StringUtils.stripEnd(name, "-");
    name = StringUtils.stripStart(name, "-");

    final TagData tagData = new TagData(name);

    tagData.setTitle(title);

    return tagData;
}