/** * Initialize the logger. * * @param state * Source state */ private static void initLogger(SourceState state) { StringBuilder sb = new StringBuilder(); sb.append("["); sb.append(StringUtils.stripToEmpty(state.getProp(ConfigurationKeys.SOURCE_QUERYBASED_SCHEMA))); sb.append("_"); sb.append(StringUtils.stripToEmpty(state.getProp(ConfigurationKeys.SOURCE_ENTITY))); sb.append("]"); MDC.put("sourceInfo", sb.toString()); } }
private static String getRuleSetDescriptionSingleLine(RuleSet ruleset) { String description = ruleset.getDescription(); description = StringEscapeUtils.escapeHtml4(description); description = description.replaceAll("\\n|\\r", " "); description = StringUtils.stripToEmpty(description); return description; }
private String getWorkUnitName() { StringBuilder sb = new StringBuilder(); sb.append("["); sb.append(StringUtils.stripToEmpty(this.workUnitState.getProp(ConfigurationKeys.SOURCE_QUERYBASED_SCHEMA))); sb.append("_"); sb.append(StringUtils.stripToEmpty(this.workUnitState.getProp(ConfigurationKeys.SOURCE_ENTITY))); sb.append("_"); String id = this.workUnitState.getId(); int seqIndex = id.lastIndexOf("_", id.length()); if (seqIndex > 0) { String timeSeqStr = id.substring(0, seqIndex); int timeIndex = timeSeqStr.lastIndexOf("_", timeSeqStr.length()); if (timeIndex > 0) { sb.append(id.substring(timeIndex + 1)); } } sb.append("]"); return sb.toString(); }
/** * Shortens and escapes (for markdown) some special characters. Otherwise the shortened text * could contain some unfinished sequences. * @param rule * @return */ private static String getShortRuleDescription(Rule rule) { return StringEscapeUtils.escapeHtml4( StringUtils.abbreviate( StringUtils.stripToEmpty( rule.getDescription() .replaceAll("\n|\r", "") .replaceAll("\\|", "\\\\|") .replaceAll("`", "'") .replaceAll("\\*", "")), 100)); }
@Test public void testStripToEmpty_String() { assertEquals("", StringUtils.stripToEmpty(null)); assertEquals("", StringUtils.stripToEmpty("")); assertEquals("", StringUtils.stripToEmpty(" ")); assertEquals("", StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE)); assertEquals("ab c", StringUtils.stripToEmpty(" ab c ")); assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); }
public String usages(Request request, Response response) { final String elasticProfileId = StringUtils.stripToEmpty(request.params(PROFILE_ID_PARAM)); final Collection<ElasticProfileUsage> jobsUsingElasticProfile = elasticProfileService.getUsageInformation(elasticProfileId); return ElasticProfileUsageRepresenter.toJSON(jobsUsingElasticProfile); } }
lines.add("**This rule is defined by the following XPath expression:**"); lines.add("``` xpath"); lines.addAll(toLines(StringUtils.stripToEmpty(rule.getProperty(XPathRule.XPATH_DESCRIPTOR)))); lines.add("```"); } else { for (String example : rule.getExamples()) { lines.add("``` " + mapLanguageForHighlighting(languageTersename)); lines.addAll(toLines(StringUtils.stripToEmpty(example))); lines.add("```"); lines.add("");
/** * Constructor * * @param module the module containing the given path (can be blank) * @param path the path within the module, if any (required) */ private LogicalPath(final String module, final Path path) { Validate.notNull(path, "Path required"); this.module = StringUtils.stripToEmpty(module); this.path = path; }
private Map<String, String> getReceiveEmailPropertiesFormattedToInsert(String host, String port, String protocol, String username, String password, Boolean starttls, String jndiName) { String starttlsStr = String.valueOf(starttls); if (starttls == null) { starttlsStr = null; } Map<String, String> props = new HashMap<String, String>(); props.put("springlets.mail.receiver.host", StringUtils.stripToEmpty(host)); props.put("springlets.mail.receiver.port", StringUtils.stripToEmpty(port)); props.put("springlets.mail.receiver.protocol", StringUtils.stripToEmpty(protocol)); props.put("springlets.mail.receiver.username", StringUtils.stripToEmpty(username)); props.put("springlets.mail.receiver.password", StringUtils.stripToEmpty(password)); props.put("springlets.mail.receiver.starttls-enable", StringUtils.stripToEmpty(starttlsStr)); props.put("springlets.mail.receiver.jndi-name", StringUtils.stripToEmpty(jndiName)); return props; }
/** * Constructor that allows all fields to be set * * @param method the method to invoke (required) * @param target the object on which the method is to be invoked (required) * @param remainingBuffer can be blank * @param key can be blank * @since 1.2.0 */ public MethodTarget(final Method method, final Object target, final String remainingBuffer, final String key) { Validate.notNull(method, "Method is required"); Validate.notNull(target, "Target is required"); this.key = StringUtils.stripToEmpty(key); this.method = method; this.remainingBuffer = StringUtils.stripToEmpty(remainingBuffer); this.target = target; }
private Map<String, String> getSendEmailPropertiesFormattedToInsert(String host, String port, String protocol, String username, String password, Boolean starttls, String jndiName) { String starttlsStr = String.valueOf(starttls); if (starttls == null) { starttlsStr = null; } Map<String, String> props = new HashMap<String, String>(); props.put("spring.mail.host", StringUtils.stripToEmpty(host)); props.put("spring.mail.port", StringUtils.stripToEmpty(port)); props.put("spring.mail.protocol", StringUtils.stripToEmpty(protocol)); props.put("spring.mail.username", StringUtils.stripToEmpty(username)); props.put("spring.mail.password", StringUtils.stripToEmpty(password)); props.put("spring.mail.properties.mail.smtp.starttls.enable", StringUtils.stripToEmpty(starttlsStr)); props.put("spring.mail.jndi-name", StringUtils.stripToEmpty(jndiName)); return props; }
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, String existingData, final String optionContext, final MethodTarget target) { existingData = StringUtils.stripToEmpty(existingData); if (StringUtils.isBlank(optionContext) || optionContext.contains(PROJECT) || optionContext.contains(SUPERCLASS) || optionContext.contains(INTERFACE) || optionContext.contains(ENUMERATION)) { completeProjectSpecificPaths(completions, existingData, optionContext); } if (StringUtils.contains(optionContext, "java")) { completeJavaSpecificPaths(completions, existingData, optionContext); } return false; }
public void createOrUpdateTextFileIfRequired(final String fileIdentifier, final String newContents, final String descriptionOfChange, final boolean writeImmediately) { if (writeImmediately) { createOrUpdateTextFileIfRequired(fileIdentifier, newContents, descriptionOfChange); } else { deferredFileWrites.put(fileIdentifier, newContents); String deferredDescriptionOfChange = StringUtils.defaultIfEmpty(deferredDescriptionOfChanges.get(fileIdentifier), ""); if (StringUtils.isNotBlank(deferredDescriptionOfChange) && !deferredDescriptionOfChange.trim().endsWith(";")) { deferredDescriptionOfChange += "; "; } deferredDescriptionOfChanges.put(fileIdentifier, deferredDescriptionOfChange + StringUtils.stripToEmpty(descriptionOfChange)); } }
public void commit() { final Map<String, String> toRemove = new LinkedHashMap<String, String>(deferredFileWrites); try { for (final Entry<String, String> entry : toRemove.entrySet()) { final String fileIdentifier = entry.getKey(); final String newContents = entry.getValue(); if (StringUtils.isNotBlank(newContents)) { createOrUpdateTextFileIfRequired(fileIdentifier, newContents, StringUtils.stripToEmpty(deferredDescriptionOfChanges.get(fileIdentifier))); } else if (exists(fileIdentifier)) { delete(fileIdentifier, "empty"); } } } finally { for (final String remove : toRemove.keySet()) { deferredFileWrites.remove(remove); } deferredDescriptionOfChanges.clear(); } }
/** * Compares this dependency's identifying coordinates (i.e. not the version) * to those of the given dependency * * @param other the dependency being compared to (required) * @return see {@link Comparable#compareTo(Object)} */ private int compareCoordinates(final Dependency other) { Validate.notNull(other, "Dependency being compared to cannot be null"); int result = groupId.compareTo(other.getGroupId()); if (result == 0) { result = artifactId.compareTo(other.getArtifactId()); } if (result == 0) { result = StringUtils.stripToEmpty(classifier).compareTo( StringUtils.stripToEmpty(other.getClassifier())); } if (result == 0 && type != null) { result = type.compareTo(other.getType()); } return result; }
hasChanged |= !StringUtils.stripToEmpty(userName).equals(uname); hasChanged |= !StringUtils.stripToEmpty(password).equals(pwd); if (!hasChanged) { LOGGER.log(Level.INFO, "INFO: No changes are needed."); props.put(DATABASE_DRIVER, jdbcDatabase.getDriverClassName()); if (userName != null) { props.put(DATABASE_USERNAME, StringUtils.stripToEmpty(userName)); } else { getApplicationConfigService().removeProperty(moduleName, DATASOURCE_PREFIX, props.put(DATABASE_PASSWORD, StringUtils.stripToEmpty(password)); } else { getApplicationConfigService().removeProperty(moduleName, DATASOURCE_PREFIX, jndiProperty == null || !jndiProperty.equals(StringUtils.stripToEmpty(jndi)); if (!hasChanged) {
private static String normaliseValue(final String property) { if (property == null) { return null; } else { return StringUtils.stripToEmpty(property); } }
this.moduleName = StringUtils.stripToEmpty(moduleName); this.name = StringUtils.stripToEmpty(name); this.packaging = packaging; this.parent = parent;
@Override public boolean doesStreetsMatch(Map<String, String> o1names, Map<String, String> o2names) { String name1 = AddressesUtils.foldASCII(StringUtils.stripToEmpty(o1names.get("name")).toLowerCase()); String name2 = AddressesUtils.foldASCII(StringUtils.stripToEmpty(o2names.get("name")).toLowerCase()); return name1.contains(name2) || name2.contains(name1) || o2names.values().contains(name1) || o1names.values().contains(name2); }
@Override public List<Object> marshallize() { List<Object> parameters = new ArrayList<Object>(); parameters.add(REFERENCE_REQUIREMENT_IDX, requirement.marshallize()); parameters.add(REFERENCE_SPECIFICATION_IDX, specification.marshallize()); parameters.add(REFERENCE_SUT_IDX, systemUnderTest.marshallize()); parameters.add(REFERENCE_SECTIONS_IDX, StringUtils.stripToEmpty(sections)); parameters.add(REFERENCE_LAST_EXECUTION_IDX, lastExecution != null ? lastExecution.marshallize() : Execution.none() .marshallize()); return parameters; }