Java Code Examples for org.apache.commons.lang.StringUtils#replaceChars()
The following examples show how to use
org.apache.commons.lang.StringUtils#replaceChars() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphDatabaseConfiguration.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
private static String computeUniqueInstanceId(Configuration config) { final String suffix; if (config.has(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX)) { suffix = LongEncoding.encode(config.get( GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX)); } else { suffix = ManagementFactory.getRuntimeMXBean().getName() + LongEncoding.encode(INSTANCE_COUNTER.incrementAndGet()); } byte[] addrBytes; try { addrBytes = Inet4Address.getLocalHost().getAddress(); } catch (UnknownHostException e) { throw new TitanConfigurationException("Cannot determine local host", e); } String uid = new String(Hex.encodeHex(addrBytes)) + suffix; for (char c : ConfigElement.ILLEGAL_CHARS) { uid = StringUtils.replaceChars(uid,c,'-'); } return uid; }
Example 2
Source File: GamlEditorDragAndDropHandler.java From gama with GNU General Public License v3.0 | 5 votes |
private static String clean(final String name) { int i = 1; String rootName = name.substring(0, name.indexOf('.')); rootName = StringUtils.replaceChars(rootName, " .,;:-()'&@%*?!<>=+#", "_"); String result = rootName + "0"; while (usedNames.contains(result)) { result = rootName + String.valueOf(i++); } usedNames.add(result); return result; }
Example 3
Source File: TestUtils.java From sonar-clover with Apache License 2.0 | 5 votes |
/** * Search for a resource in the classpath. For example calling the method getResource(getClass(), "myTestName/foo.txt") from * the class org.sonar.Foo loads the file $basedir/src/test/resources/org/sonar/Foo/myTestName/foo.txt * * @return the resource. Null if resource not found */ public static File getResource(Class baseClass, String path) { String resourcePath = StringUtils.replaceChars(baseClass.getCanonicalName(), '.', '/'); if (!path.startsWith("/")) { resourcePath += "/"; } resourcePath += path; return getResource(resourcePath); }
Example 4
Source File: CloverXmlReportParserTest.java From sonar-clover with Apache License 2.0 | 5 votes |
private String extractFileName(String filename) { if (filename != null) { filename = StringUtils.replaceChars(filename, '\\', '/'); if (filename.indexOf('/') >= 0) { filename = StringUtils.substringAfterLast(filename, "/"); } } return filename; }
Example 5
Source File: RepomdWriter.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Removes all control characters from passed in String. * @param pkgId package id * @param input char input * @return sanitized string */ protected static String sanitize(Long pkgId, String input) { if (StringUtils.containsNone(input, CONTROL_CHARS)) { return input; } if (log.isDebugEnabled()) { log.debug("Package " + pkgId + " metadata contains control chars, cleanup required: " + input); } return StringUtils.replaceChars(input, CONTROL_CHARS, CONTROL_CHARS_REPLACEMENT); }
Example 6
Source File: DebarredVendorDaoJdbc.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * Gets the addressGeneratedId of the vendor address that matches best with the address of the * EPLS debarred vendor in the specified vendor exclude match. * If no address matches, returns the default address for IU campus. */ protected long getMatchAddressId(DebarredVendorMatch match) { long bestid = 0; long defaultId = 0; int maxPriority = 0; List<VendorAddress> addresses = vendorService.getVendorDetail(match.getVendorHeaderGeneratedIdentifier(), match.getVendorDetailAssignedIdentifier()).getVendorAddresses(); if (addresses == null ) { return bestid; } for (VendorAddress address : addresses) { if (address.isVendorDefaultAddressIndicator()) { defaultId = address.getVendorAddressGeneratedIdentifier(); } //each condition satisfied will increase the priority score for this address int priority = 0; String vendorAddr1 = StringUtils.replaceChars(address.getVendorLine1Address(), ".,# ", ""); String eplsAddr1 = StringUtils.replaceChars(match.getAddress1(), ".,# ", ""); if (StringUtils.equalsIgnoreCase(vendorAddr1, eplsAddr1)) { priority++; } String vendorCity = StringUtils.replaceChars(address.getVendorCityName(), "., ", ""); String eplsCity = StringUtils.replaceChars(match.getCity(), "., ", ""); if (StringUtils.equalsIgnoreCase(vendorCity, eplsCity)) { priority++; } if (StringUtils.equalsIgnoreCase(address.getVendorStateCode(), match.getState())) { priority++; } String vendorZip = StringUtils.substring(address.getVendorZipCode(), 0, 5); String eplsZip = StringUtils.substring(match.getZip(), 0, 5); if (StringUtils.equals(vendorZip, eplsZip)) { priority++; } if (priority >= maxPriority) { bestid = address.getVendorAddressGeneratedIdentifier(); maxPriority = priority; } } if (bestid == 0) { bestid = defaultId; } return bestid; }
Example 7
Source File: StringUtil.java From jeewx with Apache License 2.0 | 2 votes |
/** * 首字母大写 * @param realName * @return */ public static String firstUpperCase(String realName) { return StringUtils.replaceChars(realName, realName.substring(0, 1),realName.substring(0, 1).toUpperCase()); }
Example 8
Source File: StringUtil.java From jeewx with Apache License 2.0 | 2 votes |
/** * 首字母小写 * @param realName * @return */ public static String firstLowerCase(String realName) { return StringUtils.replaceChars(realName, realName.substring(0, 1),realName.substring(0, 1).toLowerCase()); }
Example 9
Source File: RhnHelper.java From spacewalk with GNU General Public License v2.0 | 2 votes |
/** * Use this for every textarea that we use in our UI. Otherwise you will get ^M * in your file showing up. * @param form to fetch from * @param name of value in form * @return String without CR in them. */ public static String getTextAreaValue(DynaActionForm form, String name) { String value = form.getString(name); return StringUtils.replaceChars(value, "\r", ""); }
Example 10
Source File: StrutsDelegate.java From spacewalk with GNU General Public License v2.0 | 2 votes |
/** * Use this for every textarea that we use in our UI. Otherwise you will get ^M * in your file showing up. * @param form to fetch from * @param name of value in form * @return String without CR in them. */ public String getTextAreaValue(DynaActionForm form, String name) { String value = form.getString(name); return StringUtils.replaceChars(value, "\r", ""); }
Example 11
Source File: StringUtil.java From jeecg with Apache License 2.0 | 2 votes |
/** * 首字母大写 * @param realName * @return */ public static String firstUpperCase(String realName) { return StringUtils.replaceChars(realName, realName.substring(0, 1),realName.substring(0, 1).toUpperCase()); }
Example 12
Source File: StringUtil.java From jeecg with Apache License 2.0 | 2 votes |
/** * 首字母小写 * @param realName * @return */ public static String firstLowerCase(String realName) { return StringUtils.replaceChars(realName, realName.substring(0, 1),realName.substring(0, 1).toLowerCase()); }