List of usage examples for org.apache.commons.lang3 StringUtils replace
public static String replace(final String text, final String searchString, final String replacement)
Replaces all occurrences of a String within another String.
A null reference passed to this method is a no-op.
StringUtils.replace(null, *, *) = null StringUtils.replace("", *, *) = "" StringUtils.replace("any", null, *) = "any" StringUtils.replace("any", *, null) = "any" StringUtils.replace("any", "", *) = "any" StringUtils.replace("aba", "a", null) = "aba" StringUtils.replace("aba", "a", "") = "b" StringUtils.replace("aba", "a", "z") = "zbz"
From source file:net.ontopia.topicmaps.nav2.utils.DynamicTreeWidget.java
protected String escapeName(String name) { return StringUtils.replace(name, "-", "_"); }
From source file:com.google.dart.java2dart.util.ToFormattedSourceVisitor.java
@Override public Void visitComment(Comment node) { Token token = node.getBeginToken();//from w ww .j av a 2 s.c om while (token != null) { boolean firstLine = true; for (String line : StringUtils.split(token.getLexeme(), "\n")) { if (firstLine) { firstLine = false; // TODO (danrubel): clean this up if isDocumentation() is modified to include /// if (node.isDocumentation()) { nl2(); } } else { line = " " + line.trim(); line = StringUtils.replace(line, "/*", "/ *"); } writer.print(line); nl2(); } if (token == node.getEndToken()) { break; } } return null; }
From source file:de.micromata.tpsb.doc.parser.JavaDocUtil.java
public static List<String> getScenarioFileNames(String projectRoot, AnnotationInfo ai) { List<String> ret = new ArrayList<String>(); String pattern = (String) ai.getParams().get("filePattern"); if (StringUtils.isBlank(pattern) == true) { return ret; }/*from w w w . j a va 2 s.c om*/ // TODO only support one argument pattern = StringUtils.replace(pattern, "${0}", "*"); int idx = pattern.lastIndexOf('/'); if (idx == -1) { return ret; } String dirpart = pattern.substring(0, idx); String filepart = pattern.substring(idx + 1); idx = filepart.indexOf('*'); if (idx == -1) { return ret; } String fileprefix = filepart.substring(0, idx); String filepostfix = filepart.substring(idx + 1); File root = new File(projectRoot); File parent = new File(root, dirpart); for (File f : parent.listFiles()) { if (f.getName().startsWith(fileprefix) == false) { continue; } if (f.getName().endsWith(filepostfix) == false) { continue; } String scenid = f.getName().substring(fileprefix.length()); scenid = scenid.substring(0, scenid.length() - filepostfix.length()); ret.add(scenid); } return ret; }
From source file:de.micromata.genome.gwiki.page.search.expr.SearchUtils.java
@Deprecated public static String sampleToHtmlNew(String text, List<String> words) { String ap = Pattern.quote("<!--KW:XXX-->"); String ep = Pattern.quote("<!--KW-->"); // TODO gwiki geht nicht mit umlauten, da words normalisiert sind. // StringBuilder sb = new StringBuilder(); for (String w : words) { String nw = NormalizeUtils.normalize(w); String app = StringUtils.replace(ap, "XXX", nw); String reg = app + "(.+?)" + ep; Pattern p = Pattern.compile(reg); Matcher m = p.matcher(text); while (m.find() == true) { int start = m.start(1); int end = m.end(1); String t = m.group(1); text = text.substring(0, start) + "<b><strong><big>" + t + "</big></strong></b>" + text.substring(end); }// w ww .j av a 2 s . c o m // text = StringUtils.replace(text, w, "<b><strong><big>" + w + "</big></strong></b>"); } return text; }
From source file:io.hawkcd.agent.services.FileManagementService.java
@Override public String normalizePath(String filePath) { return StringUtils.replace(filePath, "\\", "/"); }
From source file:de.micromata.genome.junittools.wicket.TpsbWicketTools.java
/** * Normalize wicket id.//from w ww .ja v a 2 s. c o m * * @param wicketId the wicket id * @return the string */ public static String normalizeWicketId(String wicketId) { return StringUtils.replace(wicketId, ":", "_"); }
From source file:goja.initialize.ctxbox.ClassSearcher.java
/** * jarclass/*from w w w.ja va2 s . c o m*/ */ private List<String> findjarFiles(String baseDirName) { List<String> classFiles = Lists.newArrayList(); File baseDir = new File(baseDirName); if (!baseDir.exists() || !baseDir.isDirectory()) { LOG.error("file search error:" + baseDirName + " is not a dir?"); } else { File[] files = baseDir.listFiles(); if (files == null) { return Collections.EMPTY_LIST; } for (File file : files) { if (file.isDirectory()) { classFiles.addAll(findjarFiles(file.getAbsolutePath())); } else { if (includeAllJarsInLib || includeJars.contains(file.getName())) { JarFile localJarFile = null; try { localJarFile = new JarFile(new File(baseDirName + File.separator + file.getName())); Enumeration<JarEntry> entries = localJarFile.entries(); while (entries.hasMoreElements()) { JarEntry jarEntry = entries.nextElement(); String entryName = jarEntry.getName(); if (scanPackages.isEmpty()) { if (!jarEntry.isDirectory() && entryName.endsWith(".class")) { String className = StringUtils.replace(entryName, StringPool.SLASH, ".") .substring(0, entryName.length() - 6); classFiles.add(className); } } else { for (String scanPackage : scanPackages) { scanPackage = scanPackage.replaceAll("\\.", "\\" + File.separator); if (!jarEntry.isDirectory() && entryName.endsWith(".class") && entryName.startsWith(scanPackage)) { String className = StringUtils.replace(entryName, File.separator, ".") .substring(0, entryName.length() - 6); classFiles.add(className); } } } } } catch (IOException e) { e.printStackTrace(); } finally { try { if (localJarFile != null) { localJarFile.close(); } } catch (IOException e) { LOG.error("close jar file has error!", e); } } } } } } return classFiles; }
From source file:com.sonicle.webtop.core.app.sdk.BaseJOOQVisitor.java
protected String valueToLikePattern(String value) { value = StringUtils.replace(value, "*", "%"); value = StringUtils.replace(value, "\\*", "*"); return value; }
From source file:annis.administration.DefaultAdministrationDao.java
protected void createSchema() { log.info("creating ANNIS database schema (" + dbLayout + ")"); executeSqlFromScript(dbLayout + "/schema.sql"); // update schema version jdbcTemplate.execute("DELETE FROM repository_metadata WHERE \"name\"='schema-version'"); jdbcTemplate.execute("INSERT INTO repository_metadata " + "VALUES ('schema-version', '" + StringUtils.replace(getSchemaVersion(), "'", "''") + "');"); }
From source file:info.magnolia.ui.framework.command.ImportZipCommand.java
private String extractEntryPath(ZipArchiveEntry entry) { String entryName = entry.getName(); String path = (StringUtils.contains(entryName, "/")) ? StringUtils.substringBeforeLast(entryName, "/") : "/"; if (!path.startsWith("/")) { path = "/" + path; }/*from w ww . ja v a2 s . c om*/ // make proper name, the path was already created path = StringUtils.replace(path, "/", BACKSLASH_DUMMY); path = Path.getValidatedLabel(path); path = StringUtils.replace(path, BACKSLASH_DUMMY, "/"); return path; }