@Override public String toString() { return this.name + "(" + StringUtils.arrayToCommaDelimitedString(this.parameterTypes) + ")"; }
@Override public String toString() { return this.name + "(" + StringUtils.arrayToCommaDelimitedString(this.parameterTypes) + ")"; }
@Override public String toString() { return getClass().getSimpleName() + " [" + StringUtils.arrayToCommaDelimitedString(this.params) + "]"; }
private JAXBContext createJaxbContextFromClasses(Class<?>... classesToBeBound) throws JAXBException { if (logger.isDebugEnabled()) { logger.debug("Creating JAXBContext with classes to be bound [" + StringUtils.arrayToCommaDelimitedString(classesToBeBound) + "]"); } if (this.jaxbContextProperties != null) { return JAXBContext.newInstance(classesToBeBound, this.jaxbContextProperties); } else { return JAXBContext.newInstance(classesToBeBound); } }
@Override public String toString() { StringBuilder sb = new StringBuilder("SimpleMailMessage: "); sb.append("from=").append(this.from).append("; "); sb.append("replyTo=").append(this.replyTo).append("; "); sb.append("to=").append(StringUtils.arrayToCommaDelimitedString(this.to)).append("; "); sb.append("cc=").append(StringUtils.arrayToCommaDelimitedString(this.cc)).append("; "); sb.append("bcc=").append(StringUtils.arrayToCommaDelimitedString(this.bcc)).append("; "); sb.append("sentDate=").append(this.sentDate).append("; "); sb.append("subject=").append(this.subject).append("; "); sb.append("text=").append(this.text); return sb.toString(); }
/** * Return a friendly, short description for the bean, stating name and aliases. * @see #getBeanName() * @see #getAliases() */ public String getShortDescription() { StringBuilder sb = new StringBuilder(); sb.append("Bean definition with name '").append(this.beanName).append("'"); if (this.aliases != null) { sb.append(" and aliases [").append(StringUtils.arrayToCommaDelimitedString(this.aliases)).append("]"); } return sb.toString(); }
@Override public String toString() { return getClass().getSimpleName() + " [" + StringUtils.arrayToCommaDelimitedString(this.params) + "]"; }
/** * Register fields that are required for each binding process. * <p>If one of the specified fields is not contained in the list of * incoming property values, a corresponding "missing field" error * will be created, with error code "required" (by the default * binding error processor). * @param requiredFields array of field names * @see #setBindingErrorProcessor * @see DefaultBindingErrorProcessor#MISSING_FIELD_ERROR_CODE */ public void setRequiredFields(@Nullable String... requiredFields) { this.requiredFields = PropertyAccessorUtils.canonicalPropertyNames(requiredFields); if (logger.isDebugEnabled()) { logger.debug("DataBinder requires binding of required fields [" + StringUtils.arrayToCommaDelimitedString(requiredFields) + "]"); } }
private JAXBContext createJaxbContextFromPackages(String... packagesToScan) throws JAXBException { if (logger.isDebugEnabled()) { logger.debug("Creating JAXBContext by scanning packages [" + StringUtils.arrayToCommaDelimitedString(packagesToScan) + "]"); } ClassPathJaxb2TypeScanner scanner = new ClassPathJaxb2TypeScanner(this.beanClassLoader, packagesToScan); Class<?>[] jaxb2Classes = scanner.scanPackages(); if (logger.isDebugEnabled()) { logger.debug("Found JAXB2 classes: [" + StringUtils.arrayToCommaDelimitedString(jaxb2Classes) + "]"); } this.classesToBeBound = jaxb2Classes; if (this.jaxbContextProperties != null) { return JAXBContext.newInstance(jaxb2Classes, this.jaxbContextProperties); } else { return JAXBContext.newInstance(jaxb2Classes); } }
/** * Set the accept-version header. Must be one of "1.1", "1.2", or both. * Applies to the CONNECT frame. * @since 5.0.7 */ public void setAcceptVersion(@Nullable String... acceptVersions) { if (ObjectUtils.isEmpty(acceptVersions)) { set(ACCEPT_VERSION, null); return; } Arrays.stream(acceptVersions).forEach(version -> Assert.isTrue(version != null && (version.equals("1.1") || version.equals("1.2")), "Invalid version: " + version)); set(ACCEPT_VERSION, StringUtils.arrayToCommaDelimitedString(acceptVersions)); }
/** * Adds a comma-separated list of the short {@code Class} names of the * method argument types to the output. For example, if a method has signature * {@code put(java.lang.String, java.lang.Object)} then the value returned * will be {@code String, Object}. * @param methodInvocation the {@code MethodInvocation} being logged. * Arguments will be retrieved from the corresponding {@code Method}. * @param matcher the {@code Matcher} containing the state of the output * @param output the {@code StringBuffer} containing the output */ private void appendArgumentTypes(MethodInvocation methodInvocation, Matcher matcher, StringBuffer output) { Class<?>[] argumentTypes = methodInvocation.getMethod().getParameterTypes(); String[] argumentTypeShortNames = new String[argumentTypes.length]; for (int i = 0; i < argumentTypeShortNames.length; i++) { argumentTypeShortNames[i] = ClassUtils.getShortName(argumentTypes[i]); } matcher.appendReplacement(output, Matcher.quoteReplacement(StringUtils.arrayToCommaDelimitedString(argumentTypeShortNames))); }
@SuppressWarnings("deprecation") // on JDK 9 private Schema loadSchema(Resource[] resources, String schemaLanguage) throws IOException, SAXException { if (logger.isDebugEnabled()) { logger.debug("Setting validation schema to " + StringUtils.arrayToCommaDelimitedString(this.schemaResources)); } Assert.notEmpty(resources, "No resources given"); Assert.hasLength(schemaLanguage, "No schema language provided"); Source[] schemaSources = new Source[resources.length]; XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; Assert.isTrue(resource != null && resource.exists(), () -> "Resource does not exist: " + resource); InputSource inputSource = SaxResourceUtils.createInputSource(resource); schemaSources[i] = new SAXSource(xmlReader, inputSource); } SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage); if (this.schemaResourceResolver != null) { schemaFactory.setResourceResolver(this.schemaResourceResolver); } return schemaFactory.newSchema(schemaSources); }
@Override public Object getValue(@Nullable String name) { Object value = this.delegate.getValue(name); if (ObjectUtils.isArray(value)) { value = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(value)); } return value; } }
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) { if (logger.isErrorEnabled()) { String version = request.getHeaders().getFirst("Sec-WebSocket-Version"); logger.error("Handshake failed due to unsupported WebSocket version: " + version + ". Supported versions: " + Arrays.toString(getSupportedVersions())); } response.setStatusCode(HttpStatus.UPGRADE_REQUIRED); response.getHeaders().set(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION, StringUtils.arrayToCommaDelimitedString(getSupportedVersions())); }
private void doTestStringArrayReverseTransformationMatches(String[] sa) { String[] reverse = StringUtils.commaDelimitedListToStringArray(StringUtils.arrayToCommaDelimitedString(sa)); assertEquals("Reverse transformation is equal", Arrays.asList(sa), Arrays.asList(reverse)); }
private static Set<TestGroup> parseGroups(String originalValue, String value) throws IllegalArgumentException { Set<TestGroup> groups = new HashSet<>(); for (String group : value.split(",")) { try { groups.add(valueOf(group.trim().toUpperCase())); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException(format( "Unable to find test group '%s' when parsing testGroups value: '%s'. " + "Available groups include: [%s]", group.trim(), originalValue, StringUtils.arrayToCommaDelimitedString(TestGroup.values()))); } } return groups; }
@Test public void testContextLoaderListenerWithLocalContextInitializers() { MockServletContext sc = new MockServletContext(""); sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); sc.addInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM, StringUtils.arrayToCommaDelimitedString( new Object[] {TestContextInitializer.class.getName(), TestWebContextInitializer.class.getName()})); ContextLoaderListener listener = new ContextLoaderListener(); listener.contextInitialized(new ServletContextEvent(sc)); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc); TestBean testBean = wac.getBean(TestBean.class); assertThat(testBean.getName(), equalTo("testName")); assertThat(wac.getServletContext().getAttribute("initialized"), notNullValue()); }
@Test public void testContextLoaderListenerWithGlobalContextInitializers() { MockServletContext sc = new MockServletContext(""); sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); sc.addInitParameter(ContextLoader.GLOBAL_INITIALIZER_CLASSES_PARAM, StringUtils.arrayToCommaDelimitedString( new Object[] {TestContextInitializer.class.getName(), TestWebContextInitializer.class.getName()})); ContextLoaderListener listener = new ContextLoaderListener(); listener.contextInitialized(new ServletContextEvent(sc)); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc); TestBean testBean = wac.getBean(TestBean.class); assertThat(testBean.getName(), equalTo("testName")); assertThat(wac.getServletContext().getAttribute("initialized"), notNullValue()); }
@Override public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) { // Create field error with the exceptions's code, e.g. "typeMismatch". String field = ex.getPropertyName(); Assert.state(field != null, "No field in exception"); String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field); Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field); Object rejectedValue = ex.getValue(); if (ObjectUtils.isArray(rejectedValue)) { rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue)); } FieldError error = new FieldError(bindingResult.getObjectName(), field, rejectedValue, true, codes, arguments, ex.getLocalizedMessage()); error.wrap(ex); bindingResult.addError(error); }
@Test public void testContextLoaderListenerWithUnknownContextInitializer() { MockServletContext sc = new MockServletContext(""); // config file doesn't matter. just a placeholder sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/org/springframework/web/context/WEB-INF/empty-context.xml"); sc.addInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM, StringUtils.arrayToCommaDelimitedString(new Object[] {UnknownContextInitializer.class.getName()})); ContextLoaderListener listener = new ContextLoaderListener(); try { listener.contextInitialized(new ServletContextEvent(sc)); fail("expected exception"); } catch (ApplicationContextException ex) { assertTrue(ex.getMessage().contains("not assignable")); } }