List of usage examples for org.apache.commons.lang3 StringUtils replaceChars
public static String replaceChars(final String str, final String searchChars, String replaceChars)
Replaces multiple characters in a String in one go.
From source file:org.ligoj.app.plugin.prov.aws.NormalizeFormat.java
@Override public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) { toAppendTo.append(StringUtils.replaceChars( org.ligoj.app.api.Normalizer.normalize(obj.toString()).toLowerCase(Locale.ENGLISH), " ,./\\\"\';%+=^(){}&#@?`*$<>|", "_")); return toAppendTo; }
From source file:org.neo4art.sentiment.util.DictionaryUtils.java
/** * /* w w w . j a va2 s . co m*/ * @param text * @return */ public static String forNLP(String text) { String result = null; result = StringUtils.replaceChars(text, "", "'"); result = StringUtils.replaceChars(result, "", "'"); result = StringUtils.replaceChars(result, "", "\""); result = StringUtils.replaceChars(result, "?", "\""); return result; }
From source file:org.phenotips.configuration.internal.global.DefaultRecordElement.java
@Override public String getName() { String result = this.extension.getParameters().get("title"); if (StringUtils.isBlank(result)) { result = StringUtils.capitalize(StringUtils .replaceChars(StringUtils.substringAfterLast(this.extension.getId(), "."), "_-", " ")); }/*from w w w . j a v a2 s .co m*/ return result; }
From source file:org.polymap.p4.style.FeatureStyleDescriptionProvider.java
@Override public void update(ViewerCell cell) { Style elm = (Style) cell.getElement(); // default//from w w w . j a v a 2 s. c o m String description = ((Style) elm).description.get(); description = StringUtils.abbreviate(description, 55); description = StringUtils.replaceChars(description, '\n', ' '); description = sanitize(description); // description = tk.markdown( description, cell.getItem() ); cell.setText(description != null ? description : "[No description yet]"); // // Style images // if (elm instanceof StyleGroup) { // cell.setText( description != null ? description : "[No Description yet]" ); // } // else if (elm instanceof PolygonStyle) { // cell.setText( description != null ? description : "Polygon" ); // } // else if (elm instanceof PointStyle) { // cell.setText( description != null ? description : "Point/Mark" ); // } //// else if (cell.getElement() instanceof LineStyle) { //// cell.setImage( P4Plugin.images().svgImage( "vector-line.svg", P4Plugin.TOOLBAR_ICON_CONFIG ) ); //// } }
From source file:org.wrml.runtime.schema.DefaultSchemaLoader.java
@Override public final String getNativeTypeName(final URI typeUri) { final BiMap<URI, String> uriToNativeTypeNameBiMapView = _NativeTypeNameToUriBiMap.inverse(); if (!uriToNativeTypeNameBiMapView.containsKey(typeUri)) { final UniqueName uniqueName = getTypeUniqueName(typeUri); if (uniqueName == null) { throw new SchemaLoaderException("The type's uniqueName could not be determined from: " + typeUri, null, this); }//ww w .j av a 2s . co m String localName = uniqueName.getLocalName(); if (localName != null) { int indexOfLastDot = localName.lastIndexOf("."); if (indexOfLastDot > 0) { localName = localName.substring(0, indexOfLastDot); } else if (indexOfLastDot == 0) { localName = localName.substring(1); } } String namespace = uniqueName.getNamespace(); if (namespace != null) { namespace = StringUtils.replaceChars(namespace, ".", "_"); } String internalTypeName; if (namespace != null && localName != null) { String suffix = localName.trim(); if (!suffix.isEmpty()) { suffix = UniqueName.NAME_SEPARATOR + suffix; } internalTypeName = namespace + suffix; } else if (namespace == null && localName == null) { internalTypeName = "unnamed"; } else if (namespace == null && localName != null) { internalTypeName = localName; } else { internalTypeName = namespace; } internalTypeName = StringUtils.replaceChars(internalTypeName, ".", "_"); final String schemaInterfaceName = SchemaGenerator.internalTypeNameToExternalTypeName(internalTypeName); _NativeTypeNameToUriBiMap.put(schemaInterfaceName, typeUri); } return uriToNativeTypeNameBiMapView.get(typeUri); }
From source file:org.wrml.runtime.schema.SchemaBuilder.java
public static String ensureValidJavaIdentifier(final String identifier) { if (identifier == null || RESERVED_WORD_SET.contains(identifier)) { return null; }/*from w ww . j a va2 s . com*/ String validJavaIdentifier = identifier; int index = validJavaIdentifier.indexOf('-'); if (index > 0) { validJavaIdentifier = validJavaIdentifier.replace('-', '_'); } if (!Character.isJavaIdentifierStart(validJavaIdentifier.charAt(0))) { validJavaIdentifier = "_" + validJavaIdentifier; } final int validJavaIdentifierLength = validJavaIdentifier.length(); String replaceCharacters = ""; for (int i = 1; i < validJavaIdentifierLength; i++) { char c = validJavaIdentifier.charAt(i); if (!Character.isJavaIdentifierPart(c)) { replaceCharacters += c; } } if (!replaceCharacters.isEmpty()) { validJavaIdentifier = StringUtils.replaceChars(validJavaIdentifier, replaceCharacters, "$"); } return validJavaIdentifier; }
From source file:ste.xtest.envjs.BugFreeDocumentLocation.java
@Test public void load_url() throws Throwable { exec("window.location='src/test/resources/html/documentlocation.html';"); then(StringUtils.replaceChars((String) exec("document.innerHTML;"), "\r\n\t ", "")).isEqualTo(StringUtils .replaceChars(IOUtils.toString(new File("src/test/resources/html/documentlocation.html").toURI()), "\n\r\t ", "")); }
From source file:ubic.gemma.core.analysis.report.DatabaseViewGeneratorImpl.java
private void generateDatasetView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException { DatabaseViewGeneratorImpl.log.info("Generating dataset summary view"); /*//from w w w . j a v a2s . c om * Get handle to output file */ File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_SUMMARY_VIEW_BASENAME); DatabaseViewGeneratorImpl.log.info("Writing to " + file); try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) { writer.write("GemmaDsId\tSource\tSourceAccession\tShortName\tName\tDescription\ttaxon\tManufacturer\n"); /* * Print out their names etc. */ int i = 0; for (ExpressionExperiment ee : experiments) { ee = expressionExperimentService.thawLite(ee); DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName()); String acc = ""; String source = ""; if (ee.getAccession() != null && ee.getAccession().getAccession() != null) { acc = ee.getAccession().getAccession(); source = ee.getAccession().getExternalDatabase().getName(); } Long gemmaId = ee.getId(); String shortName = ee.getShortName(); String name = ee.getName(); String description = ee.getDescription(); description = StringUtils.replaceChars(description, '\t', ' '); description = StringUtils.replaceChars(description, '\n', ' '); description = StringUtils.replaceChars(description, '\r', ' '); Taxon taxon = expressionExperimentService.getTaxon(ee); if (taxon == null) continue; Collection<ArrayDesign> ads = expressionExperimentService.getArrayDesignsUsed(ee); StringBuilder manufacturers = new StringBuilder(); // TODO could cache the arrayDesigns to make faster, thawing ad is time consuming for (ArrayDesign ad : ads) { ad = arrayDesignService.thawLite(ad); if (ad.getDesignProvider() == null) { DatabaseViewGeneratorImpl.log.debug("Array Design: " + ad.getShortName() + " has no design provoider assoicated with it. Skipping"); continue; } manufacturers.append(ad.getDesignProvider().getName()).append(","); } writer.write(String.format("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", gemmaId, source, acc, shortName, name, description, taxon.getCommonName(), StringUtils.removeEnd(manufacturers.toString(), ","))); if (limit != null && (limit > 0 && ++i > limit)) break; } } }
From source file:ubic.gemma.core.datastructure.matrix.ExpressionDataWriterUtils.java
private static String constructRCompatibleBioAssayName(String colName) { String colNameMod = colName;//from w w w .j av a 2 s. co m colNameMod = StringUtils.replaceChars(colNameMod, ':', '.'); colNameMod = StringUtils.replaceChars(colNameMod, '\'', '.'); colNameMod = StringUtils.replaceChars(colNameMod, '|', '.'); colNameMod = StringUtils.replaceChars(colNameMod, '-', '.'); return colNameMod; }