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

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

Introduction

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

Prototype

public static String remove(final String str, final char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

A null source string will return null .

Usage

From source file:de.micromata.genome.util.types.Converter.java

/**
 * String to array./*from   w w  w .ja  va 2 s . c  o  m*/
 *
 * @param str the str
 * @return the string[]
 */
public static String[] stringToArray(String str) {
    return StringUtils.split(StringUtils.remove(str, ' '), ',');
}

From source file:mfi.filejuggler.responsibles.BasicApplication.java

@Responsible(conditions = { Condition.VIEW_LICENCE_ATTRIBUTION })
public void fjLizenzbedingungenAnzeigen(StringBuilder sb, Map<String, String> parameters, Model model)
        throws Exception {

    Condition back;/* w w  w .  j a va 2s  . c  om*/
    if (model.lookupConversation().getStepBackCondition() != null) {
        back = model.lookupConversation().getStepBackCondition();
    } else {
        if (model.getUser() != null) {
            back = Condition.FS_NAVIGATE;
        } else {
            back = Condition.LOGIN;
        }
    }

    sb.append(HTMLUtils.buildMenuNar(model, "Lizenzen anzeigen / View Licence Attribution", back, null, true));

    List<String> lines = null;
    try {
        String licence = "";
        URL url = this.getClass().getClassLoader().getResource("licenseattribution.txt");
        URLConnection resConn = url.openConnection();
        resConn.setUseCaches(false);
        InputStream in = resConn.getInputStream();
        StringWriter writer = new StringWriter();
        IOUtils.copy(in, writer, "UTF-8");
        licence = writer.toString();
        licence = StringUtils.remove(licence, "\r");
        lines = Arrays.asList(StringUtils.split(licence, "\n"));

    } catch (IOException e) {
        logger.error("Error loading Resource licenseattribution.txt: ", e);
    }

    buildTextviewTable("Lizenzen anzeigen / View Licence Attribution", sb, model, lines,
            model.lookupConversation().isTextViewNumbers(), true, true);

}

From source file:com.google.dart.engine.services.internal.correction.CorrectionUtils.java

/**
 * @return the source to reference the given {@link Type} in this {@link CompilationUnit}.
 *///from  w  w w. ja  v a 2s  .  c o m
public String getTypeSource(Type type) {
    String typeSource = type.toString();
    typeSource = StringUtils.remove(typeSource, "<dynamic>");
    typeSource = StringUtils.remove(typeSource, "<dynamic, dynamic>");
    // find prefix
    {
        Element element = type.getElement();
        ImportElement imp = getImportElement(element);
        if (imp != null && imp.getPrefix() != null) {
            return imp.getPrefix().getDisplayName() + "." + typeSource;
        }
    }
    // no prefix
    return typeSource;
}

From source file:net.trustie.model.OpenHubProject_Model.java

public void afterProcess(Page page) {

    this.urlMd5 = DigestUtils.md5Hex(page.getPageUrl());
    SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    this.collectTime = bartDateFormat.format(new Date());

    Document doc = page.getHtml().getDocument();

    // use_count/*www . j  a  v  a2s.c  o m*/
    Elements useCountLabel = doc
            .select("div#widgets div[itemprop=interactionCount] div.float_right div.use_count a");
    if (useCountLabel.size() > 0) {
        String strUseCount = useCountLabel.get(0).text();
        this.useCount = Integer.parseInt(StringUtils.remove(strUseCount, ','));
    }

    // tags
    Elements tags = doc.select("div#project_tags p a");
    String tag = null;
    List<String> listTags = new ArrayList<String>();
    for (Element e : tags) {
        tag = e.text();
        listTags.add(tag);
    }
    this.tags = StringHandler.combineTags(listTags);

    // quick reference
    // Elements quickRefs = doc.select("div.span6 div.well dl.");
    Elements quickRefs = doc.select("div.span6 div.well dl");
    if (quickRefs.size() > 0) {
        Element quickRef = quickRefs.get(0);
        handleQuickRef(quickRef);
    }

    // nutshell
    //      if (codeInfos.size() > 0) {
    //         String nutShell0 = codeInfos.get(0);
    //         handleNutShell0(nutShell0);
    //         String nutShell1 = codeInfos.get(1);
    //         handleNutShell1(nutShell1);
    //         String nutShell2 = codeInfos.get(2);
    //         handleNutShell2(nutShell2);
    //         String nutShell3 = codeInfos.get(3);
    //         handleNutShell3(nutShell3, page.getTime());
    //      }

    int tmplength = codeInfos.size();
    if (tmplength > 0) {
        if (tmplength == 1) {
            String nutShell0 = codeInfos.get(0);
            handleNutShell0(nutShell0);
        } else if (tmplength == 2) {
            String nutShell0 = codeInfos.get(0);
            handleNutShell0(nutShell0);
            String nutShell1 = codeInfos.get(1);
            handleNutShell1(nutShell1);
        } else if (tmplength == 3) {
            String nutShell0 = codeInfos.get(0);
            handleNutShell0(nutShell0);
            String nutShell1 = codeInfos.get(1);
            handleNutShell1(nutShell1);
            String nutShell2 = codeInfos.get(2);
            handleNutShell2(nutShell2);
        } else {
            String nutShell0 = codeInfos.get(0);
            handleNutShell0(nutShell0);
            String nutShell1 = codeInfos.get(1);
            handleNutShell1(nutShell1);
            String nutShell2 = codeInfos.get(2);
            handleNutShell2(nutShell2);
            String nutShell3 = codeInfos.get(3);
            handleNutShell3(nutShell3, page.getTime());
        }
    }

    List<String> eList = new ArrayList<String>();
    List<String> valueList = new ArrayList<String>();
    // language
    for (int i = 0; i < languages.size(); i++) {
        Element e = Jsoup.parse(languages.get(i));
        Element eValue = Jsoup.parse(percentages.get(i));
        // String strE = e.text();
        eList.add(e.text());
        // String strValue = eValue.text();
        valueList.add(eValue.text());
    }
    this.languagePercentages = StringHandler.assemblyOSSEANMap(eList, valueList);

    // activity
    String strtmp1 = "";
    String strtmp2 = "";
    String strtmp3 = "";
    String strtmp4 = "";
    // this.dCommitNumber = Integer.parseInt(dayActivityInfos.get(0));
    // this.dContributorNumber = Integer.parseInt(dayActivityInfos.get(1));
    //      if (dayActivityInfos.size() > 0) {
    //         strtmp1 = dayActivityInfos.get(0);
    //         this.daysCommitNumber = getInt(strtmp1);
    //         strtmp2 = dayActivityInfos.get(1);
    //         this.daysContributorNumber = getInt(strtmp2);
    //         strtmp3 = monthActivityInfos.get(0);
    //         this.monthsCommitNumber = getInt(strtmp3);
    //         strtmp4 = monthActivityInfos.get(1);
    //         this.monthsContributorNumber = getInt(strtmp4);
    //
    //      }

    int length = dayActivityInfos.size();
    if (length > 0) {
        if (length == 1) {
            strtmp1 = dayActivityInfos.get(0);
            this.daysCommitNumber = getInt(strtmp1);
        } else {
            strtmp1 = dayActivityInfos.get(0);
            this.daysCommitNumber = getInt(strtmp1);
            strtmp2 = dayActivityInfos.get(1);
            this.daysContributorNumber = getInt(strtmp2);
        }
    }

    int length1 = monthActivityInfos.size();
    if (length1 > 0) {
        if (length1 == 1) {
            strtmp3 = monthActivityInfos.get(0);
            this.monthsCommitNumber = getInt(strtmp3);
        } else {
            strtmp3 = monthActivityInfos.get(0);
            this.monthsCommitNumber = getInt(strtmp3);
            strtmp4 = monthActivityInfos.get(1);
            this.monthsContributorNumber = getInt(strtmp4);
        }
    }

    this.newContriNum = getInt(this.newContributor);
    //      this.theCommitTrend = allTrend.get(0);
    //      this.theContriTrend = allTrend.get(1);

    if (allTrend.size() > 0) {
        if (allTrend.size() == 1) {
            this.theCommitTrend = allTrend.get(0);
        } else {
            this.theCommitTrend = allTrend.get(0);
            this.theContriTrend = allTrend.get(1);
        }
    }

    // community
    // this.rateNum = getInt(this.rateInfo);
    this.ReContributor = StringHandler.combineTags(this.RecenctContributors);
    // button informations
    //      String headHref = "https://www.openhub.net";
    //      Document docTmp = Jsoup.parse(this.linkInfos.get(0));
    //      this.links = docTmp.getElementsByTag("a");
    //      
    //      for(Element link : links){
    //         String url = headHref + link.attr("href");
    //         ansTmp += url +"**";
    //      }
    //      

    //      if (this.firstLinks.size() > 0) {
    //
    //         this.newsLink = tmphref + this.firstLinks.get(0);
    //         this.langLink = tmphref + this.firstLinks.get(1);
    //
    //         this.commitsLink = tmphref + this.firstLinks.get(2);
    //         this.settingLink = tmphref + this.otherLinks.get(0);
    //         
    //         this.sharingwidgetsLink = tmphref + this.otherLinks.get(1);
    //         this.relatedprojectsLink = tmphref + this.otherLinks.get(2);
    //         this.costestLink = tmphref + this.otherLinks.get(3);
    //         this.contributorLink = tmphref + this.otherLinks.get(4);
    //      }

    this.rateInfo = this.rateInfo.trim();
    this.rateLevel = this.rateLevel.trim();
    //?projectlinks??
    this.projectLinks = this.projectLinks.trim();
    if (this.projectLinks.contains("")) {
        this.projectLinks = this.projectLinks.replace("", " ");
        this.projectLinks = this.projectLinks.trim();
    }
    this.activity = this.activity.trim();

    SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    this.crawlerTime = s.format(page.getTime());
    this.projectUrl = page.getPageUrl();

}

From source file:nl.vpro.jcr.criteria.query.criterion.ConjunctionTest.java

/**
 * @throws Exception/*w  ww .j  a  va  2s  .co  m*/
 */
@Test
public void testImplicitConjunction() throws Exception {
    Criteria criteria = JCRCriteriaFactory.createCriteria().setBasePath("/")
            .add(Restrictions.eq("MetaData/@mgnl:template", "t-photogallery-sheet"))
            .add(Restrictions.isNotNull("@playlist")).addOrder(Order.desc("@photogalleryDate"));

    String expectedStmt = "//*" + "[((MetaData/@mgnl:template='t-photogallery-sheet') and @playlist)]"
            + " order by @photogalleryDate descending";
    String actualStmt = criteria.toXpathExpression();
    Assert.assertEquals(StringUtils.remove(actualStmt, ' '), StringUtils.remove(expectedStmt, ' '));
}

From source file:nl.vpro.jcr.criteria.query.criterion.ConjunctionTest.java

/**
 * @throws Exception/*  w  w  w  . j av a  2s. c om*/
 */
@Test
public void testExplicitConjunction() throws Exception {
    Junction conjunction = Restrictions.conjunction()
            .add(Restrictions.eq("MetaData/@mgnl:template", "t-photogallery-sheet"))
            .add(Restrictions.isNotNull("@playlist"));
    Criteria criteria = JCRCriteriaFactory.createCriteria().setBasePath("/").add(conjunction)
            .addOrder(Order.desc("@photogalleryDate"));

    String expectedStmt = "//*" + "[(((MetaData/@mgnl:template='t-photogallery-sheet') and @playlist))]"
            + " order by @photogalleryDate descending";
    String actualStmt = criteria.toXpathExpression();
    Assert.assertEquals(StringUtils.remove(actualStmt, ' '), StringUtils.remove(expectedStmt, ' '));
}

From source file:no.kantega.publishing.common.ContentIdHelperImpl.java

/**
 * Check url for whether it starts with a site alias. If it does, remove site alias.
 * Eg site with alias /sitealias and url /sitealias results in url /, url /sitealias/alias gived /alias
 * @param site to check url against. May be null, then all sites are tested.
 * @param url Url to test// w  w  w .  j av a  2  s.co  m
 * @return pair with siteId and adjusted url. If site given is null and no site alias match, the resulting siteId
 * is -1 and the same url as given is returned.
 */
private Pair<Integer, String> getUrlAdjustedBySiteAlias(Site site, String url) {
    String ajustedUrl = url.endsWith("/") ? url : url + "/";
    int siteId = -1;
    if (site == null) {
        List<Site> sites = siteCache.getSites();
        for (Site s : sites) {
            String siteAliasWithTrailingSlash = s.getAlias().endsWith("/") ? s.getAlias() : s.getAlias() + "/";
            if (ajustedUrl.startsWith(siteAliasWithTrailingSlash)) {
                url = "/" + StringUtils.removeStart(ajustedUrl, siteAliasWithTrailingSlash);
                siteId = s.getId();
                break;
            }
        }
    } else {
        String siteAliasWithTrailingSlash = site.getAlias().endsWith("/") ? site.getAlias()
                : site.getAlias() + "/";
        if (ajustedUrl.startsWith(siteAliasWithTrailingSlash)) {
            url = "/" + StringUtils.remove(ajustedUrl, siteAliasWithTrailingSlash);
        }
        siteId = site.getId();
    }

    return Pair.of(siteId, url);
}

From source file:nz.co.fortytwo.freeboard.zk.ConfigViewModel.java

private void saveLayers(boolean useHomeChoice) throws Exception {

    File layersFile = new File(
            Util.getConfig(null).getProperty(Constants.FREEBOARD_RESOURCE) + "/js/layers.js");
    StringBuffer layers = new StringBuffer();
    layers.append("function addLayers(map) {\n\tvar host = window.location.hostname;\n");
    for (String chart : selectedChartsModel) {
        layers.append(allListMap.get(chart));
        layers.append("\n");
    }//from  w ww .  jav  a  2  s . c o m
    // layers.append("}\n");
    // now add the layers data
    layers.append("\tbaseLayers = {\n" + "\t\t\"World\": WORLD,\n" + "\t};\n" + "\toverlays = {\n");
    // add the overlays
    for (String chart : selectedChartsModel) {
        String snippet = allListMap.get(chart);
        if (StringUtils.isBlank(snippet)) {
            continue;
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Processing :" + chart);
        }
        if (logger.isDebugEnabled()) {
            logger.debug(snippet);
        }

        String chartVar = snippet.substring(0, snippet.indexOf("="));
        chartVar = chartVar.substring(chartVar.indexOf("var") + 3).trim();
        snippet = getChartName(snippet, chart);
        layers.append("\t\t\"" + snippet + "\": " + chartVar + ",\n");
    }
    layers.append("\t};\n");
    layers.append("\tlayers = L.control.layers(baseLayers, overlays).addTo(map);\n");
    layers.append("\t};\n");
    String layersStr = layers.toString();
    if (useHomeChoice) {
        // we parse out all refs to the subdomains
        // remove {s}.
        layersStr = StringUtils.remove(layersStr, "{s}.");
        layersStr = StringUtils.remove(layersStr, "subdomains: 'abcd',");
    }
    if (logger.isDebugEnabled()) {
        logger.debug(layersStr);
    }
    FileUtils.writeStringToFile(layersFile, layersStr);
}

From source file:nz.net.orcon.kanban.tools.ComplexDateConverter.java

public boolean matches(String formulaIn) {
    final String formula = StringUtils.remove(formulaIn, " ");
    return doMatches(formula);
}

From source file:nz.net.orcon.kanban.tools.ComplexDateConverter.java

public Date convert(String formulaIn) {
    final String formula = StringUtils.remove(formulaIn, " ");
    return doConvert(formula);
}