/** * Sets the rule description */ public Rule setDescription(String description) { this.description = StringUtils.strip(description); return this; }
@Override protected String performOp(String val) { return StringUtils.strip(val, " "); }
/** * <p>Strips whitespace from the start and end of a String returning * an empty String if <code>null</code> input.</p> * * <p>This is similar to {@link #trimToEmpty(String)} but removes whitespace. * Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> * StringUtils.stripToEmpty(null) = "" * StringUtils.stripToEmpty("") = "" * StringUtils.stripToEmpty(" ") = "" * StringUtils.stripToEmpty("abc") = "abc" * StringUtils.stripToEmpty(" abc") = "abc" * StringUtils.stripToEmpty("abc ") = "abc" * StringUtils.stripToEmpty(" abc ") = "abc" * StringUtils.stripToEmpty(" ab c ") = "ab c" * </pre> * * @param str the String to be stripped, may be null * @return the trimmed String, or an empty String if <code>null</code> input * @since 2.0 */ public static String stripToEmpty(String str) { return str == null ? EMPTY : strip(str, null); }
/** * <p>Strips whitespace from the start and end of a String.</p> * * <p>This is similar to {@link #trim(String)} but removes whitespace. * Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <p>A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * StringUtils.strip(null) = null * StringUtils.strip("") = "" * StringUtils.strip(" ") = "" * StringUtils.strip("abc") = "abc" * StringUtils.strip(" abc") = "abc" * StringUtils.strip("abc ") = "abc" * StringUtils.strip(" abc ") = "abc" * StringUtils.strip(" ab c ") = "ab c" * </pre> * * @param str the String to remove whitespace from, may be null * @return the stripped String, <code>null</code> if null String input */ public static String strip(String str) { return strip(str, null); }
@Override protected String performOp(String val) { return StringUtils.strip(val, " "); }
newArr[i] = strip(strs[i], stripChars);
/** * <p>Strips whitespace from the start and end of a String returning * <code>null</code> if the String is empty ("") after the strip.</p> * * <p>This is similar to {@link #trimToNull(String)} but removes whitespace. * Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> * StringUtils.stripToNull(null) = null * StringUtils.stripToNull("") = null * StringUtils.stripToNull(" ") = null * StringUtils.stripToNull("abc") = "abc" * StringUtils.stripToNull(" abc") = "abc" * StringUtils.stripToNull("abc ") = "abc" * StringUtils.stripToNull(" abc ") = "abc" * StringUtils.stripToNull(" ab c ") = "ab c" * </pre> * * @param str the String to be stripped, may be null * @return the stripped String, * <code>null</code> if whitespace, empty or null String input * @since 2.0 */ public static String stripToNull(String str) { if (str == null) { return null; } str = strip(str, null); return str.length() == 0 ? null : str; }
protected String getCommittedOffsetGroupPath() { if (Strings.isNullOrEmpty(mCommittedOffsetGroupPath)) { String stripped = StringUtils.strip(mConfig.getKafkaZookeeperPath(), "/"); mCommittedOffsetGroupPath = Joiner.on("/").skipNulls().join( "", stripped.equals("") ? null : stripped, "consumers", mConfig.getKafkaGroup(), "offsets" ); } return mCommittedOffsetGroupPath; }
protected String findAttributeValueGroup(String pattern, int groupNumber, CharSequence cs) { Matcher m = TextUtils.getMatcher(pattern, cs); try { if(m.find()) { String value = m.group(groupNumber); /* * In a case like this <input name="foo"/> the group here will * be "foo"/ ... it's difficult to adjust the regex to avoid * slurping that trailing slash, so handle it here */ value = StringUtils.removeEnd(value, "'/"); value = StringUtils.removeEnd(value, "\"/"); value = StringUtils.strip(value, "\'\""); // strip quotes if present return value; } else { return null; } } finally { TextUtils.recycleMatcher(m); } } }
str = strip(str); if(str == null || str.length() <= 2) { return str;
long lastSeenOffset = mOffsetTracker.getLastSeenOffset(topicPartition); String stripped = StringUtils.strip(mConfig.getZookeeperPath(), "/"); final String lockPath = Joiner.on("/").skipNulls().join( "",
private String normalizeValue(String value) { if (Boolean.class.isAssignableFrom(conditionField.getType()) || boolean.class.isAssignableFrom(conditionField.getType())) { return StringUtils.strip(value, "'"); } else { return value; } }
private boolean findIpInHostFile() throws IOException { BufferedReader bf = new BufferedReader(new FileReader(AnsibleConstant.INVENTORY_FILE)); String line; try { while ((line = bf.readLine()) != null) { line = StringUtils.strip(line.trim(), "\t\r\n"); if (line.equals(targetIp.trim())) { return true; } } return false; } finally { bf.close(); } }
/** * Switch template file or path target on caret offset "foo/bar.html.twig" or "foo" * * "foo" "bar.html.twig" */ @NotNull public static Collection<PsiElement> getTemplateNavigationOnOffset(@NotNull Project project, @NotNull String templateName, int offset) { Set<PsiElement> files = new HashSet<>(); // try to find a path pattern on current offset after path normalization if(offset < templateName.length()) { String templateNameWithCaret = normalizeTemplateName(new StringBuilder(templateName).insert(offset, '\u0182').toString()); offset = templateNameWithCaret.indexOf('\u0182'); int i = StringUtils.strip(templateNameWithCaret.replace(String.valueOf('\u0182'), "").replace(":", "/"), "/").indexOf("/", offset); if(i > 0) { files.addAll(getTemplateTargetOnOffset(project, templateName, offset)); } } // full filepath fallback: "foo/foo<caret>.html.twig" if(files.size() == 0) { files.addAll(getTemplatePsiElements(project, templateName)); } return files; }
public ChecksumValue(String digest) { digest = StringUtils.strip(digest); this.algorithm = algorithmFromDigest(digest); this.checksum = stripAlgorithmFromDigest(digest); }
/** * Get class by shortcut namespace, on a scoped namespace * @param project current project * @param classNameScope Namespace fo search "\Foo\Foo", "Foo\Foo", "Foo\Foo\", last "\*" is stripped * @param className Class name inside namespace also fqn is supported * @return PhpClass matched */ public static PhpClass getClassInsideNamespaceScope(@NotNull Project project, @NotNull String classNameScope, @NotNull String className) { if(className.startsWith("\\")) { return PhpElementsUtil.getClassInterface(project, className); } // strip class name we namespace String strip = StringUtils.strip(classNameScope, "\\"); int i = strip.lastIndexOf("\\"); if(i <= 0) { return PhpElementsUtil.getClassInterface(project, className); } PhpClass phpClass = PhpElementsUtil.getClassInterface(project, strip.substring(0, i) + "\\" + StringUtils.strip(className, "\\")); if(phpClass != null) { return phpClass; } return PhpElementsUtil.getClassInterface(project, className); }
@Nullable public static PsiElement insertKeyIntoFile(final @NotNull YAMLFile yamlFile, final @NotNull YAMLKeyValue yamlKeyValue, @NotNull String... keys) { String keyText = yamlKeyValue.getKeyText(); return insertKeyIntoFile(yamlFile, (yamlMapping, chainedKey) -> { String text = yamlKeyValue.getText(); final String previousIndent = StringUtil.repeatSymbol(' ', YAMLUtil.getIndentInThisLine(yamlMapping)); // split content of array value object; // drop first item as getValueText() removes our key indent String[] remove = (String[]) ArrayUtils.remove(text.split("\\r?\\n"), 0); List<String> map = ContainerUtil.map(remove, s -> previousIndent + s); return "\n" + StringUtils.strip(StringUtils.join(map, "\n"), "\n"); }, (String[]) ArrayUtils.add(keys, keyText)); }
@NotNull @Override public ResolveResult[] multiResolve(boolean b) { String value = this.psiElement.getValue(); Collection<PsiElement> serviceClassTargets = ServiceUtil.getServiceClassTargets(getElement().getProject(), value); // @TODO: on implement multiple service resolve; we can make it nicer here // self add on compiler parameter, in this case we dont have a target; // to not get ide warnings if(serviceClassTargets.size() == 0 && value.startsWith("%") && value.endsWith("%") && value.length() > 2 && ContainerCollectionResolver.getParameterNames(getElement().getProject()).contains(StringUtils.strip(value, "%"))) { serviceClassTargets.add(getElement()); } return PsiElementResolveResult.createResults(serviceClassTargets); }
public ASTNode.Value visitValue(ZQLParser.ValueContext ctx) { if (!ctx.value().isEmpty()) { ASTNode.ListValue l = new ASTNode.ListValue(); l.setValues(ctx.value().stream().map(it->it.accept(new ValueVisitor())).collect(Collectors.toList())); return l; } ASTNode.PlainValue v = new ASTNode.PlainValue(); v.setText(ctx.getText()); if (ctx.INT() != null) { v.setType(Long.class); } else if (ctx.FLOAT() != null) { v.setType(Double.class); } else if (ctx.STRING() != null) { v.setType(String.class); } else if (ctx.BOOLEAN() != null) { v.setType(Boolean.class); v.setText(StringUtils.strip(v.getText(), "'")); } else { DebugUtils.Assert(false, "should not be here"); } v.setCtype(v.getType().getName()); return v; }