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:com.thoughtworks.go.domain.Matcher.java
private List<String> escapeMatchers() { List<String> escapedMatchers = new ArrayList<>(); for (String matcher : matchers) { for (String specialChar : SPECIAL_CHARS) { matcher = StringUtils.replace(matcher, specialChar, "\\" + specialChar); }/*from w ww . ja va2 s .c om*/ escapedMatchers.add(matcher); } return escapedMatchers; }
From source file:com.haulmont.cuba.web.sys.WebJarResourceResolver.java
/** * Converts /VAADIN/webjars/... path to WebJAR path. * * @param fullVaadinPath Vaadin path/* w w w.j av a2 s. c o m*/ * @return WebJAR path */ public String translateToWebJarPath(String fullVaadinPath) { String path = fullVaadinPath; if (path.startsWith("/")) path = path.substring(1); return StringUtils.replace(path, VAADIN_PREFIX, ""); }
From source file:ch.cyberduck.core.shared.DefaultHomeFinderService.java
protected String normalize(final String input, final boolean absolute) { return PathNormalizer.normalize( StringUtils.replace(input, String.valueOf("\\"), String.valueOf(Path.DELIMITER)), absolute); }
From source file:com.thinkbiganalytics.nifi.feedmgr.ConfigurationPropertyReplacer.java
/** * Replace the $nifi{} with ${}/* w w w. j a v a 2s. c o m*/ * @param value the property value * @return the replaced value */ public static String fixNiFiExpressionPropertyValue(String value) { if (StringUtils.isNotBlank(value)) { return StringUtils.replace(value, ConfigurationPropertyReplacer.NIF_EL_PROPERTY_REPLACEMENT_PREFIX, "${"); } return value; }
From source file:de.vandermeer.skb.datatool.entries.encodings.Htmlentry.java
@Override public void loadEntry(String keyStart, Map<String, Object> data, CoreSettings cs) throws URISyntaxException { this.entryMap = DataUtilities.loadEntry(this.getSchema(), keyStart, data, cs); this.entryMap.put(CommonKeys.KEY, this.getHtmlEntity()); this.entryMap.put(HtmlentryKeys.LOCAL_HTML_REPLACEMENT, StringUtils.replace(StringUtils.replace(this.getHtmlEntity(), "<", REPLACEMENT_PATTERN_START), ">", REPLACEMENT_PATTERN_END)); // this.htmlEntityRepl = StringUtils.replace(StringUtils.replace(this.getHtmlEntity(), "<", REPLACEMENT_PATTERN_START), ">", REPLACEMENT_PATTERN_END); if (this.getLatex() != null) { this.entryMap.put(EntryKeys.LATEX, StringUtils.replaceEach(this.getLatex(), new String[] { "\"", "\\" }, new String[] { "\\\"", "\\\\" })); }/*from w ww. j av a 2 s .c om*/ // if(this.latex!=null){ // this.latex = StringUtils.replaceEach( // (String)this.latex, // new String[]{"\"", "\\"}, // new String[]{"\\\"", "\\\\"} // ); // } }
From source file:com.impetus.ankush.common.scripting.impl.ReplaceText.java
/** * Instantiates a new ReplaceText object. * /*from w w w .j a v a 2 s. co m*/ * @param targetText * the targetText * @param replacementText * the replacementText * @param filePath * the file path * @param createBackUpFile * the createBackUpFile * @param password * the password * @param addSudoOption * the addSudoOption */ public ReplaceText(String targetText, String replacementText, String filePath, boolean createBackUpFile, String password, boolean addSudoOption) { this.targetText = StringUtils.replace(targetText, "/", "\\/"); this.replacementText = StringUtils.replace(replacementText, "/", "\\/"); this.filePath = filePath; this.createBackUpFile = createBackUpFile; this.password = password; this.addSudoOption = addSudoOption; }
From source file:com.quinsoft.zeidon.dbhandler.StandardJdbcTranslator.java
protected boolean appendString(SqlStatement stmt, StringBuilder buffer, Object value) { String str = value.toString(); if (str.length() > MAX_INLINE_STRING_LENGTH || bindAllValues) { if (getTask().dblog().isTraceEnabled()) getTask().dblog().trace("Bound string: length = %d, value = %s...", str.length(), StringUtils.substring(str, 0, 50)); stmt.addBoundAttribute(buffer, value); } else {/*from w ww .j a va 2s . c o m*/ buffer.append("'").append(StringUtils.replace(str, "'", "''")).append("'"); } return true; }
From source file:io.wcm.handler.url.suffix.impl.UrlSuffixUtil.java
/** * Decode resource path part//from www . ja va 2 s . c om * @param suffixPart Suffix part * @return Decoded path part */ public static String decodeResourcePathPart(String suffixPart) { String unencodedPath = suffixPart; // un-escape special chars for (Map.Entry<String, String> entry : SPECIAL_CHARS_ESCAPEMAP.entrySet()) { unencodedPath = StringUtils.replace(unencodedPath, entry.getValue(), entry.getKey()); } return unencodedPath; }
From source file:de.blizzy.documentr.markdown.MarkdownProcessorTest.java
@Test public void markdownToHtml() { when(descriptor.isCacheable()).thenReturn(true); when(macro.getDescriptor()).thenReturn(descriptor); when(macro.createRunnable()).thenReturn(runnable); String macroHtml = "<div>macroHtml</div>"; //$NON-NLS-1$ when(runnable.getHtml(any(IMacroContext.class))).thenReturn(macroHtml); String cleanedMacroHtml = "<div>cleanedMacroHtml</div>"; //$NON-NLS-1$ when(runnable.cleanupHtml(anyString())).thenAnswer(new Answer<String>() { @Override//from w ww . j a v a 2s .c om public String answer(InvocationOnMock invocation) { String html = (String) invocation.getArguments()[0]; return StringUtils.replace(html, "macroHtml", "cleanedMacroHtml"); //$NON-NLS-1$ //$NON-NLS-2$ } }); when(macroFactory.get(MACRO)).thenReturn(macro); String markdown = "{{:header:}}*header*{{:/header:}}**foo**\n\n{{" + MACRO + "/}}\n\nbar\n"; //$NON-NLS-1$ //$NON-NLS-2$ String result = markdownProcessor.markdownToHtml(markdown, "project", "branch", //$NON-NLS-1$ //$NON-NLS-2$ DocumentrConstants.HOME_PAGE_NAME + "/bar", authentication, CONTEXT); //$NON-NLS-1$ String expectedHtml = "<p><strong>foo</strong></p>" + cleanedMacroHtml + "<p>bar</p>"; //$NON-NLS-1$ //$NON-NLS-2$ assertEquals(expectedHtml, removeTextRange(result)); }
From source file:com.hesine.manager.generate.Generate.java
public static void execute(File curProjectPath) { // ========== ?? ==================== // ??????//from w ww . j a v a2 s. c o m // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.hesine.manager"; // String moduleName = "function"; // ???sys String moduleName = ""; // ???sys String tableName = "tb_product"; // ???sys String subModuleName = ""; // ????? String className = "product"; // ??product String classAuthor = "Jason"; // ThinkGem String functionName = "?"; // ?? List<Map<String, String>> fileds = new ArrayList<Map<String, String>>(); // map Map<String, String> dataName = new HashMap<String, String>(); dataName.put("dataType", "String"); dataName.put("name", "name"); dataName.put("methodName", "Name"); dataName.put("comment", "??"); dataName.put("dbName", "name"); Map<String, String> dataDesc = new HashMap<String, String>(); dataDesc.put("dataType", "String"); dataDesc.put("name", "description"); dataDesc.put("methodName", "Description"); dataDesc.put("comment", "??"); dataDesc.put("dbName", "description"); fileds.add(dataName); fileds.add(dataDesc); // ??? Boolean isEnable = true; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } // StringUtils.isBlank(moduleName) || if (StringUtils.isBlank(packageName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; // ? File projectPath = curProjectPath; while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) { projectPath = projectPath.getParentFile(); } logger.info("Project Path: {}", projectPath); // ? String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/hesine/manager/generate/template", "/", separator); logger.info("Template Path: {}", tplPath); // Java String javaPath = StringUtils.replaceEach( projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." }, new String[] { separator, separator }); logger.info("Java Path: {}", javaPath); // Xml String xmlPath = StringUtils.replace(projectPath + "/src/main/resources/mybatis", "/", separator); logger.info("Xml Path: {}", xmlPath); // String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator); logger.info("View Path: {}", viewPath); // ??? Map<String, Object> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); // model.put("tableName", model.get("moduleName")+(StringUtils.isNotBlank(subModuleName) // ?"_"+StringUtils.lowerCase(subModuleName):"")+"_"+model.get("className")); model.put("tableName", tableName); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+ model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); model.put("fileds", fileds); // // ? Entity // FileGenUtils.generateEntity(tplPath, javaPath, model); // // // ? sqlMap // FileGenUtils.generateSqlMap(tplPath, xmlPath, model); // // // ? Model // FileGenUtils.generateModel(tplPath, javaPath, model); // // // ? Dao // FileGenUtils.generateDao(tplPath, javaPath, model); // // // ? Service // FileGenUtils.generateService(tplPath, javaPath, model); // // // ? ServiceImpl // FileGenUtils.generateServiceImpl(tplPath, javaPath, model); // // // ? Controller // FileGenUtils.generateController(tplPath, javaPath, model); // ? add.ftl FileGenUtils.generateAddFtl(tplPath, viewPath, model); // ? edit.ftl FileGenUtils.generateEditFtl(tplPath, viewPath, model); // ? list.ftl FileGenUtils.generateListFtl(tplPath, viewPath, model); logger.info("Generate Success."); }