Java Code Examples for org.springframework.util.StringUtils#collectionToDelimitedString()
The following examples show how to use
org.springframework.util.StringUtils#collectionToDelimitedString() .
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: HttpServletBean.java From spring-analysis-note with MIT License | 6 votes |
/** * Create new ServletConfigPropertyValues. * @param config the ServletConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public ServletConfigPropertyValues(ServletConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from ServletConfig for servlet '" + config.getServletName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } }
Example 2
Source File: Version.java From spring-data-dev-tools with Apache License 2.0 | 6 votes |
@Override public String toString() { List<Integer> digits = new ArrayList<Integer>(); digits.add(major); digits.add(minor); if (build != 0 || bugfix != 0) { digits.add(bugfix); } if (build != 0) { digits.add(build); } return StringUtils.collectionToDelimitedString(digits, "."); }
Example 3
Source File: SimpleNamingContext.java From spring-analysis-note with MIT License | 6 votes |
/** * Look up the object with the given name. * <p>Note: Not intended for direct use by applications. * Will be used by any standard InitialContext JNDI lookups. * @throws javax.naming.NameNotFoundException if the object could not be found */ @Override public Object lookup(String lookupName) throws NameNotFoundException { String name = this.root + lookupName; if (logger.isDebugEnabled()) { logger.debug("Static JNDI lookup: [" + name + "]"); } if ("".equals(name)) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); if (found == null) { if (!name.endsWith("/")) { name = name + "/"; } for (String boundName : this.boundObjects.keySet()) { if (boundName.startsWith(name)) { return new SimpleNamingContext(name, this.boundObjects, this.environment); } } throw new NameNotFoundException( "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" + StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]"); } return found; }
Example 4
Source File: Version.java From spring-vault with Apache License 2.0 | 6 votes |
@Override public String toString() { List<Integer> digits = new ArrayList<Integer>(); digits.add(this.major); digits.add(this.minor); if (this.build != 0 || this.bugfix != 0) { digits.add(this.bugfix); } if (this.build != 0) { digits.add(this.build); } return StringUtils.collectionToDelimitedString(digits, ".") + (isEnterprise() ? "+ent" : ""); }
Example 5
Source File: SimpleNamingContext.java From java-technology-stack with MIT License | 6 votes |
/** * Look up the object with the given name. * <p>Note: Not intended for direct use by applications. * Will be used by any standard InitialContext JNDI lookups. * @throws javax.naming.NameNotFoundException if the object could not be found */ @Override public Object lookup(String lookupName) throws NameNotFoundException { String name = this.root + lookupName; if (logger.isDebugEnabled()) { logger.debug("Static JNDI lookup: [" + name + "]"); } if ("".equals(name)) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); if (found == null) { if (!name.endsWith("/")) { name = name + "/"; } for (String boundName : this.boundObjects.keySet()) { if (boundName.startsWith(name)) { return new SimpleNamingContext(name, this.boundObjects, this.environment); } } throw new NameNotFoundException( "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" + StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]"); } return found; }
Example 6
Source File: SimpleNamingContext.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Look up the object with the given name. * <p>Note: Not intended for direct use by applications. * Will be used by any standard InitialContext JNDI lookups. * @throws javax.naming.NameNotFoundException if the object could not be found */ @Override public Object lookup(String lookupName) throws NameNotFoundException { String name = this.root + lookupName; if (logger.isDebugEnabled()) { logger.debug("Static JNDI lookup: [" + name + "]"); } if ("".equals(name)) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); if (found == null) { if (!name.endsWith("/")) { name = name + "/"; } for (String boundName : this.boundObjects.keySet()) { if (boundName.startsWith(name)) { return new SimpleNamingContext(name, this.boundObjects, this.environment); } } throw new NameNotFoundException( "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" + StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]"); } return found; }
Example 7
Source File: UrlDecodeCommand.java From spring-cloud-cli with Apache License 2.0 | 6 votes |
@Override protected synchronized ExitStatus run(OptionSet options) throws Exception { String charset = "UTF-8"; if(options.has(charsetOption)){ charset = options.valueOf(charsetOption); } String text = StringUtils .collectionToDelimitedString(options.nonOptionArguments(), " "); try { Charset.forName(charset); String outText = URLDecoder.decode(text, charset); System.out.println(outText); return ExitStatus.OK; } catch (UnsupportedCharsetException e){ System.out.println("Unsupported Character Set"); return ExitStatus.ERROR; } }
Example 8
Source File: CloudbreakResourceNameService.java From cloudbreak with Apache License 2.0 | 5 votes |
public String trimHash(String part) { if (part == null) { throw new IllegalStateException("Resource name part must not be null!"); } LOGGER.debug("Trim the hash part from the end: {}", part); String[] parts = part.split(DELIMITER); String trimmed = part; try { trimmed = StringUtils.collectionToDelimitedString(Arrays.asList(Arrays.copyOf(parts, parts.length - 1)), DELIMITER); } catch (NumberFormatException ignored) { LOGGER.debug("No need to trim hash: {}", part); } return trimmed; }
Example 9
Source File: SimpleMetadataUIInfo.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
/** * Gets display name. * * @return the display name */ public String getDisplayName() { final Collection<String> items = getDisplayNames(); if (items.isEmpty()) { return this.registeredService.getName(); } return StringUtils.collectionToDelimitedString(items, "."); }
Example 10
Source File: EncryptCommand.java From spring-cloud-cli with Apache License 2.0 | 5 votes |
@Override protected synchronized ExitStatus run(OptionSet options) throws Exception { TextEncryptor encryptor = createEncryptor(options); String text = StringUtils.collectionToDelimitedString( options.nonOptionArguments(), " "); System.out.println(formatCipher(options, encryptor.encrypt(text))); return ExitStatus.OK; }
Example 11
Source File: AbstractNestablePropertyAccessor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Parse the given property name into the corresponding property name tokens. * @param propertyName the property name to parse * @return representation of the parsed property tokens */ private PropertyTokenHolder getPropertyNameTokens(String propertyName) { PropertyTokenHolder tokens = new PropertyTokenHolder(); String actualName = null; List<String> keys = new ArrayList<String>(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); searchIndex = -1; if (keyStart != -1) { int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length()); if (keyEnd != -1) { if (actualName == null) { actualName = propertyName.substring(0, keyStart); } String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd); if ((key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) { key = key.substring(1, key.length() - 1); } keys.add(key); searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length(); } } } tokens.actualName = (actualName != null ? actualName : propertyName); tokens.canonicalName = tokens.actualName; if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys); } return tokens; }
Example 12
Source File: DecryptCommand.java From spring-cloud-cli with Apache License 2.0 | 5 votes |
@Override protected synchronized ExitStatus run(OptionSet options) throws Exception { TextEncryptor encryptor = createEncryptor(options); String text = StringUtils.collectionToDelimitedString( options.nonOptionArguments(), " "); if (text.startsWith("{cipher}")) { text = text.substring("{cipher}".length()); } System.out.println(encryptor.decrypt(text)); return ExitStatus.OK; }
Example 13
Source File: DefaultStreamService.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Create a new stream. * * @param streamName stream name * @param dsl DSL definition for stream * @param description description of the stream definition * @param deploy if {@code true}, the stream is deployed upon creation (default is * {@code false}) * @return the created stream definition already exists * @throws InvalidStreamDefinitionException if there are errors in parsing the stream DSL, * resolving the name, or type of applications in the stream */ public StreamDefinition createStream(String streamName, String dsl, String description, boolean deploy) { StreamDefinition streamDefinition = createStreamDefinition(streamName, dsl, description); List<String> errorMessages = new ArrayList<>(); for (StreamAppDefinition streamAppDefinition : this.streamDefinitionService.getAppDefinitions(streamDefinition)) { final String appName = streamAppDefinition.getRegisteredAppName(); ApplicationType applicationType = streamAppDefinition.getApplicationType(); if (!streamValidationService.isRegistered(appName, applicationType)) { errorMessages.add( String.format("Application name '%s' with type '%s' does not exist in the app registry.", appName, applicationType)); } } if (!errorMessages.isEmpty()) { throw new InvalidStreamDefinitionException( StringUtils.collectionToDelimitedString(errorMessages, "\n")); } if (this.streamDefinitionRepository.existsById(streamName)) { throw new DuplicateStreamDefinitionException(String.format( "Cannot create stream %s because another one has already " + "been created with the same name", streamName)); } final StreamDefinition savedStreamDefinition = this.streamDefinitionRepository.save(streamDefinition); if (deploy) { this.deployStream(streamName, new HashMap<>()); } auditRecordService.populateAndSaveAuditRecord( AuditOperationType.STREAM, AuditActionType.CREATE, streamDefinition.getName(), StreamDefinitionServiceUtils.sanitizeStreamDefinition(streamDefinition.getName(), streamDefinitionService.getAppDefinitions(streamDefinition)), null); return streamDefinition; }
Example 14
Source File: StubsConfiguration.java From spring-cloud-zookeeper with Apache License 2.0 | 5 votes |
private String[] parsedDependencyPathEmptyByDefault(String path, String delimiter) { String trimmedPath = path.startsWith(delimiter) ? path.substring(1) : path; String[] splitPath = trimmedPath.split(delimiter); String stubsGroupId = ""; String stubsArtifactId = ""; String stubsClassifier = ""; if (splitPath.length >= 2) { LinkedList<String> list = new LinkedList<>(Arrays.asList(splitPath)); String lastElement = list.removeLast(); stubsGroupId = StringUtils.collectionToDelimitedString(list, "."); stubsArtifactId = lastElement; stubsClassifier = DEFAULT_STUBS_CLASSIFIER; } return new String[] { stubsGroupId, stubsArtifactId, stubsClassifier }; }
Example 15
Source File: ProjectRequestDocument.java From initializr with Apache License 2.0 | 5 votes |
private static String computeDependenciesId(List<String> dependencies) { if (ObjectUtils.isEmpty(dependencies)) { return "_none"; } Collections.sort(dependencies); return StringUtils.collectionToDelimitedString(dependencies, " "); }
Example 16
Source File: WireMockHttpServerStub.java From spring-cloud-contract with Apache License 2.0 | 4 votes |
private String jsonArrayOfMappings(Collection<String> mappings) { return "[" + StringUtils.collectionToDelimitedString(mappings, ",\n") + "]"; }
Example 17
Source File: ServletAnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public String getAsText() { return StringUtils.collectionToDelimitedString((Collection<String>) getValue(), ";"); }
Example 18
Source File: ApiClient.java From openapi-generator with Apache License 2.0 | 4 votes |
private String collectionToString(Collection<?> collection) { return StringUtils.collectionToDelimitedString(collection, separator); }
Example 19
Source File: SimpleMetadataUIInfo.java From springboot-shiro-cas-mybatis with MIT License | 2 votes |
/** * Gets privacy statement uRL. * * @return the privacy statement uRL */ public String getPrivacyStatementURL() { final Collection<String> items = getPrivacyStatementURLs(); return StringUtils.collectionToDelimitedString(items, "."); }
Example 20
Source File: OAuth2Utils.java From MaxKey with Apache License 2.0 | 2 votes |
/** * Formats a set of string values into a format appropriate for sending as a single-valued form value. * * @param value The value of the parameter. * @return The value formatted for form submission etc, or null if the input is empty */ public static String formatParameterList(Collection<String> value) { return value == null ? null : StringUtils.collectionToDelimitedString(value, " "); }