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:com.liferay.ide.ui.snippets.AddModelEntitySnippetInsertion.java
protected String getPreparedText(AbstractModelWizard wizard) { String text = super.getPreparedText(wizard); StringBuffer fields = new StringBuffer(); String[] propColumns = wizard.getPropertyColumns(); String var = wizard.getVarName(); if (!CoreUtil.isNullOrEmpty(propColumns)) { for (String prop : propColumns) { fields.append(var + ".set" + StringUtils.capitalize(prop) + "(" + prop + ");\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }// w w w . ja va2s . c o m } String fieldsVal = fields.toString(); text = StringUtils.replace(text, "${fields}", //$NON-NLS-1$ CoreUtil.isNullOrEmpty(fieldsVal) ? StringPool.EMPTY : fieldsVal); return text; }
From source file:com.tlabs.eve.api.server.MessageOfTheDayParser.java
public MessageOfTheDayResponse parse(byte[] data) throws IOException { final int CACHE_IN_MN = /*60 * 8*/5; MessageOfTheDayResponse response = new MessageOfTheDayResponse(); long now = System.currentTimeMillis(); response.setCachedUntil(now - TimeZone.getDefault().getOffset(now) + CACHE_IN_MN * 60 * 1000); String message = new String(data); if (message.length() == 0) { //keep a content otherwise caching won't occur when the received data is empty message = "<br/>"; } else {/*from w ww . j a v a2 s .c o m*/ //The content is not great...we have a MOTD at start (sometimes) //or a <center>MOTD</center> or anything with such form //Also CCP found it funny to add shellexec: in front of <a> URLs. //A real XML would have been great. message = StringUtils.removeStart(message, "MOTD"); message = StringUtils.remove(message, "shellexec:"); message = StringUtils.replace(message, "<br>", "<br/>"); } response.setMessage(message); return response; }
From source file:net.servicefixture.fitnesse.TableWizardResponder.java
protected String createCommandLine(WikiPage wikipage, String fixtureClass) throws Exception { String classpath = (new ClassPathBuilder()).getClasspath(wikipage); String templateRunner = wikipage.getData().getVariable("TEMPLATE_COMMAND_PATTERN"); if (templateRunner == null) templateRunner = DEFAULT_TEMPLATE_COMMAND_PATTERN; String command = StringUtils.replace(templateRunner, "%p", classpath); command = StringUtils.replace(command, "%m", fixtureClass); return command; }
From source file:com.sfs.beans.UserBean.java
/** * Gets the dN./* w ww . j av a 2 s . co m*/ * * @return the dN */ public final String getDN() { if (this.dn != null) { /* Ensure there are no spaces after ',' */ this.dn = StringUtils.replace(this.dn, ", ", ","); } return this.dn; }
From source file:de.alpharogroup.crypto.keyrules.Obfuscator.java
/** * {@inheritDoc}//ww w . j a va2 s.c o m */ @Override public String obfuscate() { final Map<String, String> rules = rule.getRules(); String clonedKey = key; for (final Map.Entry<String, String> rule : rules.entrySet()) { clonedKey = StringUtils.replace(clonedKey, rule.getKey(), rule.getValue()); } return clonedKey; }
From source file:hydrograph.ui.datastructure.property.Schema.java
/** * Sets the external schema path.// www .ja v a 2s . c o m * * @param externalSchemaPath * the new external schema path */ public void setExternalSchemaPath(String externalSchemaPath) { if (StringUtils.startsWith(externalSchemaPath, RELATIVE_PATH_PREFIX)) externalSchemaPath = StringUtils.replace(externalSchemaPath, RELATIVE_PATH_PREFIX, ""); this.externalSchemaPath = externalSchemaPath; }
From source file:net.java.dev.openim.tools.XMLToString.java
private static final String convert(String s) { s = StringUtils.replace(s, "&", "&"); s = StringUtils.replace(s, "<", "<"); s = StringUtils.replace(s, ">", ">"); return s;// ww w. j a v a 2 s . c o m }
From source file:com.googlecode.jtiger.modules.ecside.util.ExportViewUtils.java
public static String replaceNonBreakingSpaces(String value) { if (StringUtils.isBlank(value)) return ""; if (StringUtils.contains(value, " ")) { value = StringUtils.replace(value, " ", ""); }/* w ww .j a v a 2s.c o m*/ return value; }
From source file:de.iritgo.nexim.tools.XMLToString.java
private static final String convert(String s) { s = StringUtils.replace(s, "&", "&"); s = StringUtils.replace(s, "<", "<"); s = StringUtils.replace(s, ">", ">"); return s;/*www . j a v a2 s.com*/ }
From source file:co.marcin.novaguilds.yaml.YamlEnumTest.java
@Test public void testConfig() throws Exception { System.out.println();/*from ww w .jav a2 s . c om*/ System.out.println("Testing config enums..."); YamlConfiguration config = getConfig(); List<String> configEnumNames = new ArrayList<>(); for (Config v : Config.values()) { configEnumNames.add(v.name()); } int missingCount = 0; for (String key : config.getKeys(true)) { boolean ig = config.isConfigurationSection(key); for (String ignore : ignoreConfig) { if (key.startsWith(ignore)) { ig = true; break; } } if (!ig) { String name = StringUtils.replace(key, ".", "_").toUpperCase(); if (!configEnumNames.contains(name)) { if (missingCount == 0) { System.out.println("Missing keys:"); } System.out.println(name + ","); missingCount++; } } } if (missingCount == 0) { System.out.println("All values are present in Config enum"); } else { throw new Exception("Found " + missingCount + " missing Config enums"); } }