List of usage examples for org.apache.commons.lang3 StringUtils remove
public static String remove(final String str, final char remove)
Removes all occurrences of a character from within the source string.
A null source string will return null .
From source file:nz.net.orcon.kanban.tools.ComplexDateConverter.java
protected String removeSymbol(String stringIn, String symbol) { return StringUtils.remove(stringIn, symbol); }
From source file:org.apache.cassandra.cql3.FrozenCollectionsTest.java
private static String clean(String classname) { return StringUtils.remove(classname, "org.apache.cassandra.db.marshal."); }
From source file:org.apache.cassandra.cql3.validation.entities.SecondaryIndexTest.java
/** * Removes the quotes from the specified index name. * * @param indexName the index name from which the quotes must be removed. * @return the unquoted index name.//from w w w .j a v a 2s .c o m */ private static String removeQuotes(String indexName) { return StringUtils.remove(indexName, '\"'); }
From source file:org.apache.cassandra.locator.PropertyFileSnitch.java
public void reloadConfiguration(boolean isUpdate) throws ConfigurationException { HashMap<InetAddress, String[]> reloadedMap = new HashMap<>(); String[] reloadedDefaultDCRack = null; Properties properties = new Properties(); try (InputStream stream = getClass().getClassLoader().getResourceAsStream(SNITCH_PROPERTIES_FILENAME)) { properties.load(stream);//from w ww . jav a2 s . c om } catch (Exception e) { throw new ConfigurationException("Unable to read " + SNITCH_PROPERTIES_FILENAME, e); } for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); if ("default".equals(key)) { String[] newDefault = value.split(":"); if (newDefault.length < 2) reloadedDefaultDCRack = new String[] { "default", "default" }; else reloadedDefaultDCRack = new String[] { newDefault[0].trim(), newDefault[1].trim() }; } else { InetAddress host; String hostString = StringUtils.remove(key, '/'); try { host = InetAddress.getByName(hostString); } catch (UnknownHostException e) { throw new ConfigurationException("Unknown host " + hostString, e); } String[] token = value.split(":"); if (token.length < 2) token = new String[] { "default", "default" }; else token = new String[] { token[0].trim(), token[1].trim() }; reloadedMap.put(host, token); } } if (reloadedDefaultDCRack == null && !reloadedMap.containsKey(FBUtilities.getBroadcastAddress())) throw new ConfigurationException(String.format( "Snitch definitions at %s do not define a location for " + "this node's broadcast address %s, nor does it provides a default", SNITCH_PROPERTIES_FILENAME, FBUtilities.getBroadcastAddress())); if (isUpdate && !livenessCheck(reloadedMap, reloadedDefaultDCRack)) return; if (logger.isTraceEnabled()) { StringBuilder sb = new StringBuilder(); for (Map.Entry<InetAddress, String[]> entry : reloadedMap.entrySet()) sb.append(entry.getKey()).append(':').append(Arrays.toString(entry.getValue())).append(", "); logger.trace("Loaded network topology from property file: {}", StringUtils.removeEnd(sb.toString(), ", ")); } defaultDCRack = reloadedDefaultDCRack; endpointMap = reloadedMap; if (StorageService.instance != null) // null check tolerates circular dependency; see CASSANDRA-4145 { if (isUpdate) StorageService.instance.updateTopology(); else StorageService.instance.getTokenMetadata().invalidateCachedRings(); } if (gossipStarted) StorageService.instance.gossipSnitchInfo(); }
From source file:org.apache.olingo.fit.V3Services.java
@GET @Path("/Login({entityId})") public Response getLogin(@Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @PathParam("entityId") final String entityId, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand, @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) { return super.getEntityInternal(uriInfo.getRequestUri().toASCIIString(), accept, "Login", StringUtils.remove(entityId, "'"), format, expand, select); }
From source file:org.apache.olingo.fit.V3Services.java
@DELETE @Path("/Login({entityId})") public Response removeLogin(@PathParam("entityId") final String entityId) { return super.removeEntity("Login", StringUtils.remove(entityId, "'")); }
From source file:org.asqatasun.rules.domelement.DomElement.java
private float getAlpha(String color) { String lColor = StringUtils.remove(StringUtils.remove(StringUtils.remove(color, ALPHA_COLOR_KEY), "("), ")"); String[] components = lColor.split(";"); if (components.length != 4) { return -1; } else {/*from ww w.j av a 2 s . c om*/ return Float.valueOf(components[3].trim()); } }
From source file:org.assertj.assertions.generator.util.ClassUtil.java
/** * Get <b>public</b> classes in given directory (recursively). * <p/>//from ww w . jav a 2 s . c o m * Note that <b>anonymous</b> and <b>local</b> classes are excluded from the resulting set. * * @param directory directory where to look for classes * @param packageName package name corresponding to directory * @param classLoader used classloader * @return * @throws UnsupportedEncodingException */ private static Set<Class<?>> getClassesInDirectory(File directory, String packageName, ClassLoader classLoader) throws UnsupportedEncodingException { Set<Class<?>> classes = newLinkedHashSet(); // Capture all the .class files in this directory // Get the list of the files contained in the package File[] files = directory.listFiles(); for (File currentFile : files) { String currentFileName = currentFile.getName(); if (isClass(currentFileName)) { // CHECKSTYLE:OFF try { // removes the .class extension String className = packageName + '.' + StringUtils.remove(currentFileName, CLASS_SUFFIX); Class<?> loadedClass = loadClass(className, classLoader); // we are only interested in public classes that are neither anonymous nor local if (isClassCandidateToAssertionsGeneration(loadedClass)) { classes.add(loadedClass); } } catch (Throwable e) { // do nothing. this class hasn't been found by the loader, and we don't care. } // CHECKSTYLE:ON } else if (currentFile.isDirectory()) { // It's another package String subPackageName = packageName + ClassUtils.PACKAGE_SEPARATOR + currentFileName; // Ask for all resources for the path URL resource = classLoader.getResource(subPackageName.replace('.', File.separatorChar)); File subDirectory = new File(URLDecoder.decode(resource.getPath(), "UTF-8")); Set<Class<?>> classesForSubPackage = getClassesInDirectory(subDirectory, subPackageName, classLoader); classes.addAll(classesForSubPackage); } } return classes; }
From source file:org.assertj.assertions.generator.util.ClassUtil.java
/** * Gets the simple name of the class but, unlike {@link Class#getSimpleName()}, it includes the name of the outer * class when <code>clazz</code> is an inner class, both class names are concatenated. * <p>//from w ww . ja v a 2s . c o m * Example: * * <pre> * Outer.Inner -> OuterInner * </pre> * * @param clazz * @return */ public static String getSimpleNameWithOuterClassNotSeparatedByDots(Class<?> clazz) { if (isNotNestedClass(clazz)) { return clazz.getSimpleName(); } String nestedClassName = null; nestedClassName = clazz.getName(); nestedClassName = nestedClassName.substring(clazz.getPackage().getName().length() + 1); nestedClassName = StringUtils.remove(nestedClassName, '$'); return nestedClassName; }
From source file:org.broadleafcommerce.core.web.api.jaxrs.JaxrsRestExceptionMapper.java
protected String resolveClientMessageKey(String key) { if (messageKeyPrefix != null) { return StringUtils.remove(key, messageKeyPrefix); }//w ww .j a v a 2 s. co m return key; }