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

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

Introduction

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

Prototype

public static String remove(String str, char remove) 

Source Link

Document

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

Usage

From source file:raptor.util.CreateBugButtonActions.java

public static void main(String args[]) throws Exception {
    File file = new File(Raptor.RESOURCES_DIR + "sounds/bughouse");
    String[] bugSounds = file.list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".wav");
        }// www.jav a2  s.c om
    });

    for (String sound : bugSounds) {
        sound = StringUtils.remove(sound, ".wav");
        String name = WordUtils.capitalizeFully(sound.toLowerCase());
        File scriptFile = new File(Raptor.RESOURCES_DIR + "/actions/" + name + ".properties");
        if (!scriptFile.exists()) {
            ScriptedAction scriptedAction = new ScriptedAction();
            scriptedAction.setCategory(Category.PartnerTells);
            scriptedAction.setName(name);
            scriptedAction.setDescription("Sends the command: ptell " + sound);
            scriptedAction.setScript("context.send(\"ptell " + sound + "\");");
            Properties properties = RaptorActionFactory.save(scriptedAction);
            properties.store(new FileOutputStream(scriptFile), "Raptor System Action");
            System.err.println("Created " + scriptFile.getAbsolutePath());
        }
    }
}

From source file:raptor.util.RaptorUtils.java

/**
 * Returns a String[] containing all of the icon names.
 *///from   w w  w . j a va 2  s.  c  om
public static String[] getAllIconNames() {
    File file = new File(Raptor.RESOURCES_DIR + "icons/medium");

    String[] names = file.list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".png");
        }
    });

    Arrays.sort(names);

    String[] result = new String[names.length + 1];
    result[0] = "<None>";
    for (int i = 0; i < names.length; i++) {
        String name = StringUtils.remove(names[i], ".png");
        result[i + 1] = name;
    }
    return result;

}

From source file:se.inera.axel.riv.internal.RepositoryRivShsMappingService.java

@Override
public String mapRivServiceToShsProduct(
        @Header(RivShsMappingService.HEADER_SOAP_ACTION) String rivServiceNamespace) {

    log.debug("mapRivServiceToShsProduct({})", rivServiceNamespace);

    RivShsServiceMapping mapping = findByRivServiceNamespace(StringUtils.remove(rivServiceNamespace, '"'));

    if (mapping == null) {
        throw new RuntimeException("No SHS ProductId found for RIV Service " + rivServiceNamespace);
    }/*www.j  ava  2 s.  co  m*/

    return mapping.getShsProductId();
}

From source file:se.inera.axel.riv.internal.RepositoryRivShsMappingService.java

@Override
public String mapRivServiceToRivEndpoint(
        @Header(RivShsMappingService.HEADER_SOAP_ACTION) String rivServiceNamespace) {

    log.debug("mapRivServiceToRivEndpoint({})", rivServiceNamespace);

    RivShsServiceMapping mapping = findByRivServiceNamespace(StringUtils.remove(rivServiceNamespace, '"'));

    if (mapping == null) {
        throw new RuntimeException("No RIV Endpoint found for RIV Service " + rivServiceNamespace);
    }//w ww . j  av  a2  s  . co m

    return mapping.getRivServiceEndpoint();
}

From source file:se.nrm.dina.dina.inventory.logic.InventoryLogic.java

public List<TaxonVO> validateTaxon(String json) {

    List<TaxonVO> taxons = new ArrayList();
    try {/*from w  w  w.  j a  va 2  s  . c om*/
        JSONObject jsonObj = new JSONObject(json);
        String strTaxons = jsonObj.getString("taxonList");
        strTaxons = StringUtils.remove(strTaxons, "[\"");
        strTaxons = StringUtils.remove(strTaxons, "\"]");

        List<String> taxonList = Arrays.asList(StringUtils.split(strTaxons, "\",\""));
        taxonList.stream().forEach(t -> {
            taxon = getTaxonFromDB(t);
            if (taxon != null) {
                taxons.add(new TaxonVO(taxon.getTaxonID(), t));
            } else {
                taxons.add(new TaxonVO(0, t));
            }
        });
    } catch (JSONException ex) {
        logger.error(ex.getMessage());
    }
    //        return JsonBuilder.getInstance().buildTaxonJson(taxons);
    return taxons;
}

From source file:sv1djg.hamutils.dxcc.DXCCEntitiesReader.java

private void updateDXCCEntitiesWithMostWanted() {

    int dxccListCount = _dxccList.size();
    int wantedDxccCount = _mostWantedList.size();
    int matchedWantedDxccCount = 0;

    //System.out.println("Matching DXCC list to most wanted...PASS 1");

    // iterate once and match the most common ones
    for (DXCCEntity dxccEntity : _dxccList) {
        boolean foundMatch = false;
        for (DXCCEntity wantedEntity : _mostWantedList) {
            if (wantedEntity.prefix.equalsIgnoreCase(dxccEntity.prefix)) {
                dxccEntity.rankingInMostWanted = wantedEntity.rankingInMostWanted;

                matchedWantedDxccCount++;
                foundMatch = true;//w w  w .  j ava  2s. co m
                break;
            }
        }

        //  if (!foundMatch)
        //   System.out.println("-- prefix "+dxccEntity.prefix+" not found in most wanted list");
    }

    // iterate a second time and resolve the very specific ones
    // usually we don't get a match on the first iteration because of small differences like
    // DXCC -> 5V , most wanted -> 5V7
    //
    // so in this iteration we check all the unresolved and check sub-prefixes

    //System.out.println("Matching DXCC list to most wanted...PASS 2");
    for (DXCCEntity dxccEntity : _dxccList) {
        if (dxccEntity.rankingInMostWanted != 0)
            continue;

        boolean foundMatch = false;
        for (DXCCEntity wantedEntity : _mostWantedList) {
            if (StringUtils.startsWithIgnoreCase(StringUtils.remove(wantedEntity.prefix, '/'),
                    StringUtils.remove(dxccEntity.prefix, '/'))) {
                dxccEntity.rankingInMostWanted = wantedEntity.rankingInMostWanted;

                matchedWantedDxccCount++;
                foundMatch = true;
                break;
            }
        }

        // if (!foundMatch)
        //   System.out.println("-- prefix "+dxccEntity.prefix+" not found in most wanted list");
    }

    //System.out.println("* Checked "+dxccListCount+" DXCC entities across "+wantedDxccCount+" most wanted and found "+matchedWantedDxccCount+" matches");
}

From source file:ubic.gemma.analysis.expression.diff.GeneDifferentialExpressionServiceImpl.java

@Override
public ExperimentalFactorValueObject configExperimentalFactorValueObject(ExperimentalFactor ef) {
    ExperimentalFactorValueObject efvo = new ExperimentalFactorValueObject();
    efvo.setId(ef.getId());/*w  w  w  . java2  s .  c om*/
    efvo.setName(ef.getName());
    efvo.setDescription(ef.getDescription());
    Characteristic category = ef.getCategory();
    if (category != null) {
        efvo.setCategory(category.getCategory());
        if (category instanceof VocabCharacteristic) {
            efvo.setCategoryUri(((VocabCharacteristic) category).getCategoryUri());
        }
    }
    Collection<FactorValue> fvs = ef.getFactorValues();
    String factorValuesAsString = StringUtils.EMPTY;

    for (FactorValue fv : fvs) {
        String fvName = fv.toString();
        if (StringUtils.isNotBlank(fvName)) {
            factorValuesAsString += fvName + FV_SEP;
        }
    }

    /* clean up the start and end of the string */
    factorValuesAsString = StringUtils.remove(factorValuesAsString, ef.getName() + ":");
    factorValuesAsString = StringUtils.removeEnd(factorValuesAsString, FV_SEP);

    /*
     * Preformat the factor name; due to Ext PropertyGrid limitations we can't do this on the client.
     */
    efvo.setName(ef.getName() + " (" + StringUtils.abbreviate(factorValuesAsString, 50) + ")");

    efvo.setFactorValues(factorValuesAsString);
    return efvo;
}

From source file:ubic.gemma.web.taglib.common.description.BibliographicReferenceTag.java

@Override
public int doStartTag() throws JspException {

    StringBuilder buf = new StringBuilder();

    if (this.bibliographicReference == null) {
        buf.append("No publication");
    }//  w  ww  . java 2s .  c  o  m

    else {

        buf.append("<table><tr><td valign=\"top\"><b>Pubmed</B></td><td>&nbsp;</td><td valign=\"top\">");
        buf.append("<a target=\"_blank\" href=\"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?"
                + "cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids="
                + bibliographicReference.getPubAccession().getAccession() + "&query_hl=3\">"
                + bibliographicReference.getPubAccession().getAccession() + "</a>");

        buf.append("</td> </tr> <tr><td valign=\"top\"><b>Authors</B></td><td>&nbsp;</td><td valign=\"top\">");
        buf.append(bibliographicReference.getAuthorList());

        buf.append("</td> </tr> <tr> <td valign=\"top\"><b>Year</B></td><td>&nbsp;</td><td valign=\"top\">");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        Date publicationDate = bibliographicReference.getPublicationDate();

        if (publicationDate != null) {
            buf.append(sdf.format(publicationDate));
        } else {
            buf.append("Publication date is null. ");
        }

        buf.append("</td> </tr> <tr> <td valign=\"top\"><b>Title</B></td><td>&nbsp;</td><td valign=\"top\">");
        buf.append(bibliographicReference.getTitle());

        buf.append("</td></tr><tr><td valign=\"top\"><b>Citation</B></td><td>&nbsp;</td><td valign=\"top\">");
        buf.append(bibliographicReference.getPublication() + " ");

        if (bibliographicReference.getVolume() != null) {
            buf.append("<em>" + bibliographicReference.getVolume() + "</em>: ");
        }
        buf.append(bibliographicReference.getPages());

        buf.append("</td></tr><tr><td valign=\"top\"><b>Abstract</B></td><td>&nbsp;</td><td valign=\"top\">");
        if (bibliographicReference.getAbstractText() != null) {
            buf.append(bibliographicReference.getAbstractText());
        } else {
            buf.append("(No abstract available)");
        }

        if (bibliographicReference.getFullTextPdf() != null) {

            String baseUrl = ConfigUtils.getString("local.userfile.baseurl");
            String basePath = ConfigUtils.getString("local.userfile.basepath");
            String localUriPath = bibliographicReference.getFullTextPdf().getLocalURL().toString();
            String relativeUrl = StringUtils.remove(localUriPath, "file:/" + basePath);
            String absoluteUrl = baseUrl + relativeUrl;

            buf.append("</td></tr><tr><td valign=\"top\"><b>PDF</B></td><td>&nbsp;</td><td valign=\"top\">");
            buf.append("<a href=\"" + absoluteUrl + "\">" + absoluteUrl + "</a>");
            buf.append("&nbsp;(" + bibliographicReference.getFullTextPdf().getSize() + " bytes)");
        }

        if (bibliographicReference.getKeywords().size() > 0) {
            buf.append(
                    "</td></tr><tr><td valign=\"top\"><b>Keywords</B></td><td>&nbsp;</td><td valign=\"top\">");
            for (Keyword o : bibliographicReference.getKeywords()) {
                buf.append(o.getTerm() + "<br />");
            }
        }

        if (bibliographicReference.getMeshTerms().size() > 0) {
            buf.append("</td></tr><tr><td valign=\"top\"><b>MESH</B></td><td>&nbsp;</td><td valign=\"top\">");
            for (MedicalSubjectHeading o : bibliographicReference.getMeshTerms()) {
                buf.append(o.getTerm() + "<br />");
            }
        }

        if (bibliographicReference.getChemicals().size() > 0) {
            buf.append(
                    "</td></tr><tr><td valign=\"top\"><b>Chemicals</B></td><td>&nbsp;</td><td valign=\"top\">");
            for (Compound o : bibliographicReference.getChemicals()) {
                buf.append(o.getName() + "<br />");
            }
        }

        buf.append("</td></tr></table>");
    }
    try {
        pageContext.getOut().print(buf.toString());
    } catch (Exception ex) {
        throw new JspException("BibliographicReferenceTag: " + ex.getMessage());
    }

    return SKIP_BODY;
}

From source file:uk.ac.ebi.atlas.web.ApplicationProperties.java

public String buildDownloadURL(HttpServletRequest request) {
    // get original query string, not the one modified by ExperimentDispatcher
    String queryString = (String) request.getAttribute("javax.servlet.forward.query_string");
    String requestUri = (String) request.getAttribute("javax.servlet.forward.request_uri");
    String uri = StringUtils.remove(requestUri, request.getContextPath());

    return Joiner.on("?").skipNulls().join(new String[] { uri + TSV_FILE_EXTENSION, queryString }).toString();
}

From source file:uk.ac.ebi.embl.api.validation.fixer.feature.EC_numberfromProductValueFix.java

public ValidationResult check(Feature feature) {
    result = new ValidationResult();

    if (feature == null) {
        return result;
    }//from  w  ww . j  a v a  2  s  .  co m
    List<Qualifier> productQualifiers = feature.getQualifiers(Qualifier.PRODUCT_QUALIFIER_NAME);
    for (Qualifier productQualifier : productQualifiers) {
        String productValue = productQualifier.getValue();
        String non_EC_Value = productValue.replaceAll(EC_NUMBER_PATTERN, "");
        if (non_EC_Value != null && non_EC_Value.equals(productValue)) {
            if (productValue.toLowerCase().contains("hypothetical protein")
                    || productValue.toLowerCase().contains("unknown")) {
                ArrayList<Qualifier> ec_numberQualifiers = (ArrayList<Qualifier>) feature
                        .getQualifiers(Qualifier.EC_NUMBER_QUALIFIER_NAME);
                for (Qualifier ec_qualifier : ec_numberQualifiers) {
                    feature.removeQualifier(ec_qualifier);
                    reportMessage(Severity.FIX, feature.getOrigin(), EC_numberfromProductValueFix_ID_3,
                            feature.getName());
                }
            }
            continue;
        }
        String[] productValues = productValue.split(EC_NUMBER_PATTERN);
        non_EC_Value.replaceAll("  ", " ");
        String ec_numberValue = null;
        String tempValue = productValue;
        if (productValues.length == 0) {
            return result;
        }
        if (productValues.length == 1) {
            ec_numberValue = StringUtils.remove(tempValue, productValues[0]);

        } else {
            for (String productvalue : productValues) {
                ec_numberValue = StringUtils.remove(tempValue, productvalue);
                tempValue = ec_numberValue;
            }
        }
        if (ec_numberValue != null) {
            Matcher matcher = PATTERN.matcher(ec_numberValue);
            if (matcher.find()) {
                ec_numberValue = (matcher.group(9) == null ? "-" : matcher.group(9)) + "."
                        + (matcher.group(10) == null ? "-" : matcher.group(10)) + "."
                        + (matcher.group(12) == null ? "-" : matcher.group(12)) + "."
                        + (matcher.group(14) == null ? "-" : matcher.group(14));

            }

            productQualifier.setValue(StringUtils.trim((non_EC_Value)));
            reportMessage(Severity.FIX, feature.getOrigin(), EC_numberfromProductValueFix_ID_1, productValue,
                    productQualifier.getValue());

            if (!non_EC_Value.toLowerCase().contains("hypothetical protein")
                    && !non_EC_Value.toLowerCase().contains("unknown")) {
                feature.addQualifier(Qualifier.EC_NUMBER_QUALIFIER_NAME, ec_numberValue);
                if (!SequenceEntryUtils.deleteDuplicatedQualfiier(feature, Qualifier.EC_NUMBER_QUALIFIER_NAME))
                    reportMessage(Severity.FIX, feature.getOrigin(), EC_numberfromProductValueFix_ID_2,
                            productValue);
            } else {
                reportMessage(Severity.FIX, feature.getOrigin(), EC_numberfromProductValueFix_ID_4,
                        productValue, productQualifier.getValue());
                ArrayList<Qualifier> ec_numberQualifiers = (ArrayList<Qualifier>) feature
                        .getQualifiers(Qualifier.EC_NUMBER_QUALIFIER_NAME);
                for (Qualifier ec_qualifier : ec_numberQualifiers) {
                    feature.removeQualifier(ec_qualifier);
                    reportMessage(Severity.FIX, feature.getOrigin(), EC_numberfromProductValueFix_ID_3,
                            feature.getName());
                }
            }

        }

    }
    return result;
}