List of usage examples for org.apache.commons.lang StringUtils replace
public static String replace(String text, String searchString, String replacement)
Replaces all occurrences of a String within another String.
From source file:edu.ku.brc.specify.toycode.mexconabio.FMPCreateTable.java
/** * @param str// w w w.jav a2 s . c o m * @return */ public static String convertFromTwoByteUTF8(final String str) { String s = str; //while (s.indexOf('') > -1) { for (int ii = 0; ii < twoByteSyms.length; ii++) { s = StringUtils.replace(s, twoByteSyms[ii], chars[ii]); } } return s; }
From source file:com.google.gdt.eclipse.designer.core.wizards.ProjectWizardTest.java
/** * It was requested to make "web" folder name configurable. * <p>/* w w w .j a v a 2s . co m*/ * http://fogbugz.instantiations.com/fogbugz/default.php?41284 */ public void test_for20_differentWebFolder_inPreferences() throws Exception { Activator.getStore().setValue(Constants.P_GWT_LOCATION, GTestUtils.getLocation_20()); Activator.getStore().setValue(Constants.P_WEB_FOLDER, "myWar"); ProjectWizard.configureProjectAsGWTProject(m_javaProject); assertTrue(Utils.isGWTProject(m_javaProject)); { String classPath = getFileContent(".classpath"); classPath = StringUtils.replace(classPath, "\r\n", "\n"); assertEquals( getSourceDQ(new String[] { "<?xml version='1.0' encoding='UTF-8'?>", "<classpath>", " <classpathentry kind='con' path='org.eclipse.jdt.launching.JRE_CONTAINER'/>", " <classpathentry kind='src' path='src'/>", " <classpathentry kind='var' path='GWT_HOME/gwt-user.jar'/>", " <classpathentry kind='output' path='myWar/WEB-INF/classes'/>", "</classpath>" }), classPath); } assertFalse(getFolder0("war").exists()); assertTrue(getFolder0("myWar").exists()); assertTrue(getFolder0("myWar/WEB-INF").exists()); assertTrue(getFolder0("myWar/WEB-INF/classes").exists()); assertTrue(getFolder0("myWar/WEB-INF/lib").exists()); assertTrue(getFile("myWar/WEB-INF/lib/gwt-servlet.jar").exists()); }
From source file:hydrograph.ui.perspective.dialog.PreStartActivity.java
/** * Checks whether given JDK-PATH is valid or not. * //w ww.jav a 2 s.c o m * @param javaHome * input jdk path * @param showPopUp * true if user wants to show pop for invalid path. * @return * true if input string is valid JDK path. */ public static boolean isValidJDKPath(String javaHome, boolean showPopUp) { try { if (javaHome != null && isValidDirectory(javaHome, showPopUp)) { if (StringUtils.endsWith(javaHome, SLASH_BIN)) { javaHome = StringUtils.replace(javaHome, SLASH_BIN, ""); } if (StringUtils.isNotBlank(javaHome)) { StringBuffer jdkPath = new StringBuffer(javaHome); jdkPath = jdkPath.delete(0, jdkPath.lastIndexOf("\\") + 1); return checkJDKVersion(jdkPath.toString(), showPopUp); } } } catch (Exception exception) { logger.warn("Exception occurred while validating javaHome path", exception); } return false; }
From source file:com.reizes.shiva.net.mail.Mail.java
private InternetAddress[] parseAddresses(String input) throws AddressException { return InternetAddress.parse(StringUtils.replace(input, ";", ",")); }
From source file:com.reizes.shiva.utils.CommonUtil.java
/** * StringEscapeUtils.escapeHtml wrapping * @param str -//from ww w . java 2 s . c o m * @return - */ public static String escapeHtml(String str) { if (str == null) { return null; } return StringUtils.replace(StringEscapeUtils.escapeHtml(str), "\n", "<br/>"); }
From source file:com.qualitesys.sonarqcr4pblplugin.pbl.PblFile.java
/** * Creates a {@link PblFile} from a file in the source directories. * * @param unitTest whether it is a unit test file or a source file * @return the {@link PblFile} created if exists, null otherwise *//*from w w w. ja v a2 s .c o m*/ public static PblFile fromIOFile(File file, List<File> sourceDirs, boolean unitTest) { if (file == null) { return null; } //System.out.println("PblFile fromIOFile file "+file+" sourceDirs "+sourceDirs.toString()); String relativePath = DefaultProjectFileSystem.getRelativePath(file, sourceDirs); if (relativePath != null) { String pacname = null; String classname = relativePath; if (relativePath.indexOf('/') >= 0) { pacname = StringUtils.substringBeforeLast(relativePath, "/"); pacname = StringUtils.replace(pacname, "/", "."); classname = StringUtils.substringAfterLast(relativePath, "/"); } // Modif D.C. 01 11 2010 en Pb deux fichiers peuvent avoir le meme nom // et des extensions differentes. On garde l'extension //classname = StringUtils.substringBeforeLast(classname, "."); return new PblFile(pacname, classname, unitTest); } return null; }
From source file:com.flexive.tests.embedded.jsf.bean.MessageBeanTest.java
@Test public void getMessageArgsElString() { String message = (String) messageBean.get(KEY_1 + ",#{'some string value'}"); String expected = StringUtils.replace(MSG_1, "{0}", "some string value"); Assert.assertTrue(expected.equals(message), "Expected: " + expected + ", got: " + message); }
From source file:com.google.gdt.eclipse.designer.model.widgets.support.CssSupport.java
/** * Adds DIVs for CSS "apply wait", see {@link #waitFor()} JavaDoc. *//* ww w.j ava 2s. com*/ String addReloadingFeature(String html) { StringBuilder declarations = new StringBuilder(); for (String resource : resources) { String name = getWaitRequestName(resource); declarations.append("<div class='"); declarations.append(name); declarations.append("'></div>\n"); } return StringUtils.replace(html, "%CSS_WAIT_DECLARATIONS%", declarations.toString()); }
From source file:fr.paris.lutece.plugins.extend.modules.comment.web.action.ManageCommentsPluginAction.java
/** * {@inheritDoc}//from w w w .ja v a 2 s.com */ @Override public IPluginActionResult process(HttpServletRequest request, HttpServletResponse response, AdminUser adminUser, IExtendableResource sessionFields) throws AccessDeniedException { UrlItem url = new UrlItem(AppPathService.getBaseUrl(request) + JSP_URL); url.addParameter(CommentConstants.PARAMETER_EXTENDER_TYPE, CommentResourceExtender.EXTENDER_TYPE_COMMENT); url.addParameter(CommentConstants.PARAMETER_ID_EXTENDABLE_RESOURCE, request.getParameter(CommentConstants.PARAMETER_ID_EXTENDABLE_RESOURCE)); url.addParameter(CommentConstants.PARAMETER_EXTENDABLE_RESOURCE_TYPE, request.getParameter(CommentConstants.PARAMETER_EXTENDABLE_RESOURCE_TYPE)); url.addParameter(CommentConstants.PARAMETER_FROM_URL, StringUtils.replace(request.getHeader(CommentConstants.PARAMETER_REFERER), CommentConstants.CONSTANT_AND, CommentConstants.CONSTANT_AND_HTML)); DefaultPluginActionResult result = new DefaultPluginActionResult(); result.setRedirect(url.getUrl()); return result; }
From source file:com.prowidesoftware.swift.model.field.Field335Test.java
@Test public void testGetValue2() { Field335 f = new Field335(); String v = EXAMPLE2_FIELD_335; f = new Field335(v); assertEquals(StringUtils.replace(v, "\n", FINWriterVisitor.SWIFT_EOL), f.getValue()); }