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:org.alfresco.po.share.site.document.ManagePermissionsPage.java
/** * Check if user is already added for permission. * * @param name - First name or last name or full name <fName><space><lName> * @return UserRole/*from ww w .j a va2s .com*/ */ public UserRole getExistingPermissionForInheritPermission(String name) { try { List<WebElement> userList = findAndWaitForElements(userListInhrtPerm); for (WebElement webElement : userList) { if (webElement.findElement(userNameLocator).getText().contains(name)) { String currentRole = webElement.findElement(userRoleLocator).getText().toUpperCase(); if (currentRole.split("").length > 1) { currentRole = StringUtils.replace(currentRole.trim(), " ", ""); } return UserRole.valueOf(currentRole); } } } catch (TimeoutException toe) { logger.error("User name elementis not found!!", toe); } throw new PageOperationException("User name is not found!!"); }
From source file:org.alfresco.po.share.site.document.ManagePermissionsPage.java
/** * Get existing permission for user/group * * @param name - First name or last name or full name <fName><space><lName> * @return UserRole/*from ww w . j a v a 2 s . co m*/ */ public UserRole getExistingPermission(String name) { try { List<WebElement> userList = findAndWaitForElements(userListLocator); for (WebElement webElement : userList) { if (webElement.findElement(userNameLocator).getText().contains(name)) { String currentRole = webElement.findElement(userRoleLocator).getText().toUpperCase(); return UserRole.valueOf(StringUtils.replace(currentRole, " ", "")); } } } catch (TimeoutException toe) { logger.error("User name elementis not found!!", toe); } throw new PageOperationException("User name is not found!!"); }
From source file:org.alfresco.po.share.site.document.ManagePermissionsPage.java
/** * @param name String//from w w w .jav a2 s . c o m * @param role UserRole * @return WebElement */ private WebElement getDeleteAction(String name, UserRole role) { try { List<WebElement> userList = findAndWaitForElements(userListLocator); for (WebElement webElement : userList) if (webElement.findElement(userNameLocator).getText().contains(name)) { String currentRole = StringUtils .replace(webElement.findElement(userRoleLocator).getText().toUpperCase(), " ", ""); if (role.equals(UserRole.valueOf(currentRole))) { mouseOver(webElement); return webElement.findElement(userPermissionDeleteAction); } } } catch (NoSuchElementException toe) { logger.error("User name elementis not found!!", toe); return null; } throw new PageOperationException("User name is not found!!"); }
From source file:org.alfresco.po.share.site.document.ManagePermissionsTest.java
@Test(dependsOnMethods = "updateRoleTest") public void getInheritedPermissions() { pageUnderTest = ((DocumentDetailsPage) resolvePage(driver)).selectManagePermissions().render(); String role = pageUnderTest.getInheritedPermissions().get("site_" + siteName.toLowerCase() + "_" + StringUtils.replace(UserRole.SITEMANAGER.getRoleName().trim(), " ", "")); Assert.assertEquals(role, UserRole.SITEMANAGER.getRoleName()); }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadFileAction.java
License:asdf
/** * /*from w ww. ja v a2 s . c o m*/ */ @Override public String doAction(Map<String, Object> result, String remoteFile) throws DownLoadException { // String path = getDownDir(result); URL url; try { url = new URL(remoteFile); } catch (MalformedURLException e) { e.printStackTrace(); throw new DownLoadException("" + e.getMessage()); } String fileName = ""; if (md5File) { try { fileName = MD5Utils.createMD5(remoteFile); fileName = fileName + "." + StringUtils.substringAfterLast(url.getPath(), "."); } catch (Exception e) { } } else { fileName = StringUtils.substringAfterLast(url.getPath(), "/"); } MultiThreadDownload download = new MultiThreadDownload(1024 * 1024L); if (asynchronous) { download.downFile(url, path, fileName, false); } else { download.downLoad(url, path, fileName); } // return StringUtils.replace(path + fileName, "\\", "/"); }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadImageResizeAction.java
/** * //from w ww.j av a2 s . c o m */ @Override public String doAction(Map<String, Object> result, String remoteFile) throws DownLoadException { String path = getDownDir(result); URL url; try { url = new URL(remoteFile); } catch (MalformedURLException e) { e.printStackTrace(); throw new DownLoadException("" + e.getMessage()); } String fileName = ""; if (md5File) { try { fileName = MD5Utils.createMD5(remoteFile); String suffix = StringUtils.substringAfterLast(url.getPath(), "."); if (StringUtils.isBlank(suffix)) { suffix = "jpg"; } fileName = fileName + "." + suffix; } catch (Exception e) { } } else { fileName = StringUtils.substringAfterLast(url.getPath(), "/"); } MultiThreadDownload download = new MultiThreadDownload(1024 * 1024L); if (asynchronous) { download.downImageThenResizeAsyn(url, path, fileName, w, quality); } else { download.downImageThenResizeSyn(url, path, fileName, w, quality); } // return StringUtils.replace(path + fileName, "\\", "/"); }
From source file:org.aliuge.crawler.extractor.selector.action.string.StringReplaceAction.java
/** * ?????? */ @Override public String doAction(String content) { return StringUtils.replace(content, searchString, replacement); }
From source file:org.apache.cassandra.auth.Auth.java
private static String escape(String name) { return StringUtils.replace(name, "'", "''"); }
From source file:org.apache.cassandra.auth.CassandraAuthorizer.java
private String escape(String name) { return StringUtils.replace(name, "'", "''"); }
From source file:org.apache.cassandra.serializers.AbstractTextSerializer.java
/** * Generates CQL literal for TEXT/VARCHAR/ASCII types. * Caveat: it does only generate literals with single quotes and not pg-style literals. *///from w w w . j ava2s.c om @Override public String toCQLLiteral(ByteBuffer buffer) { return buffer == null ? "null" : '\'' + StringUtils.replace(deserialize(buffer), "'", "''") + '\''; }