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:io.wcm.handler.url.suffix.impl.UrlSuffixUtil.java
/** * Encode resource path part// ww w .j av a2 s . c o m * @param relativePath Relative path * @return Encodes path part */ public static String encodeResourcePathPart(String relativePath) { String encodedPath = relativePath; // escape special chars for (Map.Entry<String, String> entry : SPECIAL_CHARS_ESCAPEMAP.entrySet()) { encodedPath = StringUtils.replace(encodedPath, entry.getKey(), entry.getValue()); } return encodedPath; }
From source file:com.glaf.jbpm.web.springmvc.MxJbpmProcessTreeController.java
@RequestMapping("/json") public ModelAndView json(HttpServletRequest request) { RequestUtils.setRequestParameterToAttribute(request); String node = request.getParameter("node"); String process_name = null;/* ww w .j ava 2 s. c o m*/ String processDefinitionId = null; if (StringUtils.isNotEmpty(node)) { if (StringUtils.startsWith(node, "x_pdid:")) { processDefinitionId = StringUtils.replace(node, "x_pdid:", ""); } else if (StringUtils.startsWith(node, "x_pdname:")) { process_name = StringUtils.replace(node, "x_pdname:", ""); } } logger.debug("process_name:" + process_name); logger.debug("processDefinitionId:" + processDefinitionId); List<ProcessDefinition> result = null; GraphSession graphSession = null; JbpmContext jbpmContext = null; try { jbpmContext = ProcessContainer.getContainer().createJbpmContext(); graphSession = jbpmContext.getGraphSession(); if (StringUtils.isNotEmpty(process_name)) { result = graphSession.findAllProcessDefinitionVersions(process_name); } else { result = graphSession.findAllProcessDefinitions(); } if (StringUtils.isNotEmpty(processDefinitionId) && StringUtils.isNumeric(processDefinitionId)) { ProcessDefinition pd = graphSession.getProcessDefinition(Long.parseLong(processDefinitionId)); if (pd != null) { Map<String, Task> tasks = pd.getTaskMgmtDefinition().getTasks(); if (tasks != null) { List<Task> rows = new java.util.ArrayList<Task>(); Iterator<Task> iterator = tasks.values().iterator(); while (iterator.hasNext()) { Task task = iterator.next(); rows.add(task); } request.setAttribute("tasks", rows); request.setAttribute("processDefinition", pd); } } } request.setAttribute("rows", result); } catch (Exception ex) { logger.debug(ex); } finally { Context.close(jbpmContext); } String jx_view = request.getParameter("jx_view"); if (StringUtils.isNotEmpty(jx_view)) { return new ModelAndView(jx_view); } String x_view = ViewProperties.getString("jbpm_tree.json"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view); } return new ModelAndView("/jbpm/tree/json"); }
From source file:com.sonicle.webtop.vfs.VfsServiceSettings.java
public String getMyDocumentsUri(MyDocumentsUriTemplateValues tpl) { String value = getString(MYDOCUMENTS_URI, null); value = StringUtils.replace(value, "{SERVICE_ID}", tpl.SERVICE_ID); value = StringUtils.replace(value, "{DOMAIN_ID}", tpl.DOMAIN_ID); value = StringUtils.replace(value, "{USER_ID}", tpl.USER_ID); return PathUtils.ensureTrailingSeparator(value); }
From source file:net.ontopia.topicmaps.webed.impl.actions.tmobject.EvaluateLTM.java
@Override public void perform(ActionParametersIF params, ActionResponseIF response) { // test params ActionSignature paramsType = ActionSignature.getSignature("m! s!"); paramsType.validateArguments(params, this); TopicMapIF topicmap = (TopicMapIF) params.get(0); String template = (String) params.get(1); WebEdRequestIF request = params.getRequest(); Collection values = null;//w w w . ja va 2s. c o m TMObjectIF object = params.getTMObjectValue(); if (object == null) { String strval = params.getStringValue(); if (strval != null) { // escape quotes so LTM will parse correctly String value = StringUtils.replace(strval, "\"", "\"\""); values = Collections.singleton(value); } } else values = params.getTMObjectValues(); String lastid = null; if (values == null) // no object value; just do it anyway importFragment(template, topicmap); else { // repeat once for each object value Iterator it = values.iterator(); while (it.hasNext()) { lastid = makeRandomId(topicmap); Map map = new RequestMapWrapper(request, it.next(), lastid, topicmap); String tmp = StringTemplateUtils.replace(template, map); importFragment(tmp, topicmap); } } // register new topic in response TopicIF topic = getTopicById(topicmap, lastid); if (lastid != null && topic != null) response.addParameter(Constants.RP_TOPIC_ID, topic.getObjectId()); }
From source file:brut.androlib.res.data.ResResSpec.java
public String getName() { return StringUtils.replace(mName, "\"", "q"); }
From source file:gobblin.util.test.RetentionTestHelper.java
/** * * Does gobblin retention for test data. {@link DatasetCleaner} which does retention in production can not be directly called as we need to resolve some * runtime properties like ${testNameTempPath}. This directory contains all the setup data created for a test by {@link RetentionTestDataGenerator#setup()}. * It is unique for each test./*from w w w . j a v a 2 s.c om*/ * The default {@link ConfigClient} used by {@link DatasetCleaner} connects to config store configs. We need to provide a * mock {@link ConfigClient} since the configs are in classpath and not on config store. * * @param retentionConfigClasspathResource this is the same jobProps/config files used while running a real retention job * @param testNameTempPath temp path for this test where test data is generated */ public static void clean(FileSystem fs, Path retentionConfigClasspathResource, Optional<Path> additionalJobPropsClasspathResource, Path testNameTempPath) throws Exception { Properties additionalJobProps = new Properties(); if (additionalJobPropsClasspathResource.isPresent()) { try (final InputStream stream = RetentionTestHelper.class.getClassLoader() .getResourceAsStream(additionalJobPropsClasspathResource.get().toString())) { additionalJobProps.load(stream); } } if (retentionConfigClasspathResource.getName().endsWith(".job")) { Properties jobProps = new Properties(); try (final InputStream stream = RetentionTestHelper.class.getClassLoader() .getResourceAsStream(retentionConfigClasspathResource.toString())) { jobProps.load(stream); for (Entry<Object, Object> entry : jobProps.entrySet()) { jobProps.put(entry.getKey(), StringUtils.replace((String) entry.getValue(), "${testNameTempPath}", testNameTempPath.toString())); } } MultiCleanableDatasetFinder finder = new MultiCleanableDatasetFinder(fs, jobProps); for (Dataset dataset : finder.findDatasets()) { ((CleanableDataset) dataset).clean(); } } else { Config testConfig = ConfigFactory.parseResources(retentionConfigClasspathResource.toString()) .withFallback(ConfigFactory.parseMap(ImmutableMap.of("testNameTempPath", PathUtils.getPathWithoutSchemeAndAuthority(testNameTempPath).toString()))) .resolve(); ConfigClient client = mock(ConfigClient.class); when(client.getConfig(any(String.class))).thenReturn(testConfig); Properties jobProps = new Properties(); jobProps.setProperty(CleanableDatasetBase.SKIP_TRASH_KEY, Boolean.toString(true)); jobProps.setProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI, "dummy"); jobProps.putAll(additionalJobProps); @SuppressWarnings("unchecked") DatasetsFinder<CleanableDataset> finder = (DatasetsFinder<CleanableDataset>) GobblinConstructorUtils .invokeFirstConstructor( Class.forName( testConfig.getString(MultiCleanableDatasetFinder.DATASET_FINDER_CLASS_KEY)), ImmutableList.of(fs, jobProps, testConfig, client), ImmutableList.of(fs, jobProps, client)); for (CleanableDataset dataset : finder.findDatasets()) { dataset.clean(); } } }
From source file:de.tuberlin.uebb.jbop.access.ClassDescriptor.java
/** * Get the Package of the class as folder * ('.' replaced by '/')./* w w w . j a v a 2 s .c om*/ * * @return the package dir */ public String getPackageDir() { return StringUtils.replace(getPackage(), ".", "/"); }
From source file:com.nridge.core.base.std.WebUtl.java
public static String urlEncodeValue(String aValue) { String encodedValue;//from ww w .j ava 2s . com try { encodedValue = URLEncoder.encode(aValue, StrUtl.CHARSET_UTF_8); int offset = encodedValue.indexOf(StrUtl.CHAR_PLUS); if (offset != -1) encodedValue = StringUtils.replace(encodedValue, "+", "%20"); } catch (UnsupportedEncodingException e) { encodedValue = aValue; } return encodedValue; }
From source file:com.brsanthu.dataexporter.model.json.JsonWriter.java
@Override public void writeRowCell(CellDetails cellDetails) { prettyPrint(3);/*from w ww. j a v a2 s . c o m*/ print("\"" + cellDetails.getColumn().getName() + "\":"); Object cellValue = cellDetails.getCellValue(); String cellValueString = cellValue.toString(); if (cellValue instanceof Number || cellValue instanceof Boolean) { print(cellValueString); } else { if (cellValueString.contains("\"")) { String replaceWith = null; if (getJsonExportOptions().isDoubleEscape()) { replaceWith = "\\\\\""; } else { replaceWith = "\\\""; } cellValueString = StringUtils.replace(cellValueString, "\"", replaceWith); } print("\"" + cellValueString + "\""); } if (cellDetails.getColumnIndex() != cellDetails.getTable().getColumns().size() - 1) { print(","); } }
From source file:com.sonicle.webtop.core.util.IdentifierUtils.java
/** * @deprecated use com.sonicle.commons.IdentifierUtils.getUUIDRandom instead * @return/* w w w.j a va 2 s . c om*/ */ @Deprecated public static synchronized String getUUIDRandom(boolean noDashes) { final String uuid = Generators.randomBasedGenerator().generate().toString(); return (noDashes) ? StringUtils.replace(uuid, "-", "") : uuid; }