protected XmlEntity getXmlEntity(String indexName, String regionPath) { String regionName = StringUtils.stripStart(regionPath, "/"); return new XmlEntity(CacheXml.REGION, "name", regionName, LuceneXmlConstants.PREFIX, LuceneXmlConstants.NAMESPACE, LuceneXmlConstants.INDEX, "name", indexName); } }
protected XmlEntity getXmlEntity(String regionPath) { String regionName = StringUtils.stripStart(regionPath, "/"); return new XmlEntity(CacheXml.REGION, "name", regionName); }
return str; str = stripStart(str, stripChars); return stripEnd(str, stripChars);
private static String stripIndentation(String description) { if (description == null || description.isEmpty()) { return ""; } String stripped = StringUtils.stripStart(description, "\n\r"); stripped = StringUtils.stripEnd(stripped, "\n\r "); int indentation = 0; int strLen = stripped.length(); while (Character.isWhitespace(stripped.charAt(indentation)) && indentation < strLen) { indentation++; } String[] lines = stripped.split("\\n"); String prefix = StringUtils.repeat(' ', indentation); StringBuilder result = new StringBuilder(stripped.length()); if (StringUtils.isNotEmpty(prefix)) { for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (i > 0) { result.append(StringUtils.LF); } result.append(StringUtils.removeStart(line, prefix)); } } else { result.append(stripped); } return result.toString(); }
@Test public void testStripStart_StringString() { // null stripStart assertNull(StringUtils.stripStart(null, null)); assertEquals("", StringUtils.stripStart("", null)); assertEquals("", StringUtils.stripStart(" ", null)); assertEquals("abc ", StringUtils.stripStart(" abc ", null)); assertEquals(StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" stripStart assertNull(StringUtils.stripStart(null, "")); assertEquals("", StringUtils.stripStart("", "")); assertEquals(" ", StringUtils.stripStart(" ", "")); assertEquals(" abc ", StringUtils.stripStart(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE, "")); // " " stripStart assertNull(StringUtils.stripStart(null, " ")); assertEquals("", StringUtils.stripStart("", " ")); assertEquals("", StringUtils.stripStart(" ", " ")); assertEquals("abc ", StringUtils.stripStart(" abc ", " ")); // "ab" stripStart assertNull(StringUtils.stripStart(null, "ab")); assertEquals("", StringUtils.stripStart("", "ab")); assertEquals(" ", StringUtils.stripStart(" ", "ab")); assertEquals(" abc ", StringUtils.stripStart(" abc ", "ab")); assertEquals("cabab", StringUtils.stripStart("abcabab", "ab")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE, "")); }
public ResourcePermission(String resource, String operation, String target, String key) { // what's eventually stored are either "*", "NULL" or a valid enum except ALL. // Fields are never null. this.resource = parsePart(resource, r -> Resource.valueOf(r).getName()); this.operation = parsePart(operation, o -> Operation.valueOf(o).getName()); if (target != null) { this.target = StringUtils.stripStart(target, Region.SEPARATOR); } if (key != null) { this.key = key; } setParts(this.resource + ":" + this.operation + ":" + this.target + ":" + this.key, true); }
@Override public Object postProcess(Object principal, final String regionPath, final Object key, final Object value, final boolean valueIsSerialized) { if (!needPostProcess()) { return value; } if (principal == null) { principal = getSubject().getPrincipal(); } String regionName = StringUtils.stripStart(regionPath, "/"); Object newValue; // if the data is a byte array, but the data itself is supposed to be an object, we need to // deserialize it before we pass it to the callback. if (valueIsSerialized && value instanceof byte[]) { try { Object oldObj = EntryEventImpl.deserialize((byte[]) value); Object newObj = this.postProcessor.processRegionValue(principal, regionName, key, oldObj); newValue = BlobHelper.serializeToBlob(newObj); } catch (IOException | SerializationException e) { throw new GemFireIOException("Exception de/serializing entry value", e); } } else { newValue = this.postProcessor.processRegionValue(principal, regionName, key, value); } return newValue; }
String val = firstText.getValue(); if (val!=null) { firstText.setValue(StringUtils.stripStart(val, null));
@Override public String valueOf(String sqlSnippet) { return StringUtils.stripStart(sqlSnippet, "\r\n \t"); } });
public FileResourceOutputProvider(final Path basePath, final String sourceBasePath) { this.basePath = basePath; this.sourceBasePath = StringUtils.stripStart(sourceBasePath, "/"); }
private static String content(Map<String, List<String>> contentAndMetadataMap) { List<String> content = contentAndMetadataMap.get(CONTENT_METADATA_HEADER_NAME); if (content == null) { return null; } String onlySpaces = null; return StringUtils.stripStart(content.get(0), onlySpaces); }
private String parseValue(String line, int i) { String value = stripStart(line.substring(i + 1), null); int quoteStart = value.indexOf(stringQuote); int quoteEnd = value.lastIndexOf(stringQuote); if (quoteStart == 0 && quoteEnd > quoteStart) { value = value.substring(quoteStart + 1, quoteEnd); } return value; }
private void splitQuery(String params) { params = StringUtils.stripStart(params, "?"); if (StringUtils.isEmpty(params)) { return; } // TODO: encoding final String[] parts = StringUtils.split(params, '&'); for (int i = 0; i < parts.length; i++) { params_.add(splitQueryParameter(parts[i])); } }
@Override public List<String> getBuildNames() { JsonNode node = jsonClient.get("/api/build"); List<String> names = new ArrayList<>(); node.path("builds").forEach((JsonNode numberNode) -> { String name = StringUtils.stripStart(numberNode.path("uri").asText(), "/"); if (StringUtils.isNotBlank(name)) { names.add(name); } }); return names; }
private String prefixedWithDefaultUrl(String url) { Optional<String> declaredDefaultUrl = getDeclaredDefaultUrl(); if (declaredDefaultUrl.isPresent() && isARelativeUrl(url)) { return StringUtils.stripEnd(declaredDefaultUrl.get(),"/") + "/" + StringUtils.stripStart(url,"/"); } else { return url; } }
private String prefixedWithDefaultUrl(String url) { Optional<String> declaredDefaultUrl = getDeclaredDefaultUrl(); if (declaredDefaultUrl.isPresent() && isARelativeUrl(url)) { return StringUtils.stripEnd(declaredDefaultUrl.get(), "/") + "/" + StringUtils.stripStart(url, "/"); } else { return url; } }
private String prefixedWithDefaultUrl(String url) { Optional<String> declaredDefaultUrl = getDeclaredDefaultUrl(); if (declaredDefaultUrl.isPresent() && isARelativeUrl(url)) { return StringUtils.stripEnd(declaredDefaultUrl.get(),"/") + "/" + StringUtils.stripStart(url,"/"); } else { return url; } }
protected YContentFile getContentFile(Link link) { String name = link.getHref(); name = StringUtils.removeStart(name, WileyComponentConstants.CONENT_LINK_PREFIX); name = StringUtils.stripStart(name, "/\\"); YContentFile contentFile = new YContentFile(name, FileTypes.FT_FULL_TEXT, "application/pdf", null); contentFile.getLocations().add(name); return contentFile; } }
@Override public String buildURL(String baseURL, String contextPath, String path) { String base = StringUtils.strip(baseURL, "/"); String cp = "/" + StringUtils.strip(contextPath, "/"); String rest = cp + "/" + StringUtils.stripStart(path, "/"); return ResponseUtils.buildURL(base, rest, null, URLType.RESOURCE); } }
public String output() { if (isLeftTrim() && isRightTrim()) { return trim(); } else if (isLeftTrim()) { return StringUtils.stripStart(content, null); } else if (isRightTrim()) { return StringUtils.stripEnd(content, null); } return content; }