List of usage examples for org.springframework.util StringUtils arrayToCommaDelimitedString
public static String arrayToCommaDelimitedString(@Nullable Object[] arr)
From source file:net.javacrumbs.springws.test.common.SchemaValidator.java
/** * Creates {@link XmlValidator} from schemas. * @param schemas/*w w w .j av a2 s . co m*/ * @param schemaLanguage * @return * @throws IOException */ public XmlValidator createValidatorFromSchemas(Resource[] schemas, String schemaLanguage) throws IOException { Assert.hasLength(schemaLanguage, "schemaLanguage is required"); for (int i = 0; i < schemas.length; i++) { Assert.isTrue(schemas[i].exists(), "schema [" + schemas[i] + "] does not exist"); } if (logger.isInfoEnabled()) { logger.info("Validating using \"" + StringUtils.arrayToCommaDelimitedString(schemas) + "\""); } return XmlValidatorFactory.createValidator(schemas, schemaLanguage); }
From source file:org.eclipse.gemini.blueprint.test.internal.util.ManifestUtilsTest.java
public void testExportEntries() throws Exception { Manifest mf = new Manifest(); Attributes attrs = mf.getMainAttributes(); String[] packages = new String[] { "foo.bar; version:=1", "bar.foo", "hop.trop" }; attrs.putValue(Constants.EXPORT_PACKAGE, StringUtils.arrayToCommaDelimitedString(packages)); createJar(mf);/*from w w w. ja v a 2 s. c o m*/ String[] entries = ManifestUtils .determineImportPackages(new Resource[] { storage.getResource(), storage.getResource() }); assertEquals(3, entries.length); ObjectUtils.nullSafeEquals(packages, entries); }
From source file:net.nicoll.boot.metadata.ConsoleMetadataFormatter.java
@Override public String formatMetadata(ConfigurationMetadataRepository repository) { StringBuilder out = new StringBuilder(); int noDotInDescription = 0; List<String> keysMissingDescription = new ArrayList<String>(); List<ConfigurationMetadataGroup> groups = sortGroups(repository.getAllGroups().values()); for (ConfigurationMetadataGroup group : groups) { out.append("========================================").append(NEW_LINE); StringBuilder sb = new StringBuilder(); for (ConfigurationMetadataSource source : group.getSources().values()) { sb.append(source.getType()).append(" "); }//from w w w . ja va 2 s. c o m out.append("Group --- ").append(group.getId()).append("(").append(sb.toString().trim()).append(")") .append(NEW_LINE).append("========================================").append(NEW_LINE); List<ConfigurationMetadataProperty> properties = sortProperties(group.getProperties().values()); for (ConfigurationMetadataProperty property : properties) { StringBuilder item = new StringBuilder(property.getId()).append("="); Object defaultValue = property.getDefaultValue(); if (defaultValue != null) { if (defaultValue instanceof Object[]) { item.append(StringUtils.arrayToCommaDelimitedString((Object[]) defaultValue)); } else { item.append(defaultValue); } } item.append(" # (").append(property.getType()).append(")"); String description = property.getDescription(); if (StringUtils.hasText(description)) { item.append(" - "); int dot = description.indexOf("."); if (dot != -1) { BreakIterator breakIterator = BreakIterator.getSentenceInstance(); breakIterator.setText(description); item.append(description.substring(breakIterator.first(), breakIterator.next())); } else { item.append(description).append(" --- NO DOT FOUND!"); noDotInDescription++; } } else { keysMissingDescription.add(property.getId()); } out.append(item.toString()).append(NEW_LINE); } } out.append("-------- Stats --------").append(NEW_LINE).append("Not dot in description: ") .append(noDotInDescription).append(NEW_LINE).append("Missing description:").append(NEW_LINE); StringBuilder desc = new StringBuilder(); for (String s : keysMissingDescription) { desc.append("\t").append(s).append("\n"); } out.append(desc.toString()); return out.toString(); }
From source file:io.pivotal.spring.xd.jdbcgpfdist.support.SqlUtils.java
public static String createExternalReadableTable(LoadConfiguration config, String prefix, List<String> overrideLocations) { // TODO: this function needs a cleanup StringBuilder buf = new StringBuilder(); // unique table name String name = quotesEscape(config.getTable() + "_ext_" + prefix); buf.append("CREATE READABLE EXTERNAL TABLE "); buf.append(name);/*ww w . ja v a 2 s .c o m*/ buf.append(" ( "); // column types or like ReadableTable externalTable = config.getExternalTable(); if (externalTable.getLike() != null) { buf.append("LIKE "); buf.append(quotesEscape(config.getTable())); } else if (StringUtils.hasText(externalTable.getColumns())) { buf.append(externalTable.getColumns()); } else { buf.append("LIKE "); buf.append(quotesEscape(config.getTable())); } buf.append(" ) "); // locations buf.append("LOCATION ("); if (overrideLocations != null && !overrideLocations.isEmpty()) { buf.append(createLocationString(overrideLocations.toArray(new String[0]))); } else { buf.append(createLocationString(externalTable.getLocations().toArray(new String[0]))); } buf.append(") "); // format type if (externalTable.getFormat() == Format.TEXT) { buf.append("FORMAT 'TEXT'"); } else { buf.append("FORMAT 'CSV'"); } // format parameters buf.append(" ( "); buf.append("DELIMITER '"); if (externalTable.getDelimiter() != null) { buf.append(unicodeEscaped(externalTable.getDelimiter().charValue())); } else { buf.append("|"); } buf.append("'"); if (externalTable.getNullString() != null) { buf.append(" NULL '"); buf.append(externalTable.getNullString()); buf.append("'"); } if (externalTable.getEscape() != null) { buf.append(" ESCAPE '"); buf.append(externalTable.getEscape()); buf.append("'"); } if (externalTable.getQuote() != null) { buf.append(" QUOTE '"); buf.append(externalTable.getQuote()); buf.append("'"); } if (externalTable.getForceQuote() != null) { buf.append(" FORCE QUOTE "); buf.append(StringUtils.arrayToCommaDelimitedString(externalTable.getForceQuote())); } if (externalTable.isFormatHeader()) { buf.append(" HEADER "); } buf.append(" )"); if (externalTable.getEncoding() != null) { buf.append(" ENCODING '"); buf.append(externalTable.getEncoding()); buf.append("'"); } if (externalTable.getSegmentRejectLimit() != null) { if (externalTable.getLogErrorsInto() != null) { buf.append(" LOG ERRORS INTO "); buf.append(externalTable.getLogErrorsInto()); } buf.append(" SEGMENT REJECT LIMIT "); buf.append(externalTable.getSegmentRejectLimit()); buf.append(" "); } return buf.toString(); }
From source file:de.iew.spring.integration.JmxTestServiceNotificationListener.java
private String formatNotification(Notification notification) { StringBuilder sb = new StringBuilder(); sb.append("recieved notification class: ").append(notification.getType()); sb.append(", method: ").append(notification.getSource()); sb.append(", sequence: ").append(notification.getSequenceNumber()); sb.append(", timestamp: ").append(notification.getTimeStamp()); sb.append(", data: "); Object userData = notification.getUserData(); String formattedUserData;//from w w w. j a v a2 s . c o m if (userData == null) { formattedUserData = ""; } else if (userData instanceof String) { formattedUserData = StringUtils.arrayToCommaDelimitedString((Object[]) notification.getUserData()); } else { formattedUserData = userData.toString(); } sb.append(formattedUserData); return sb.toString(); }
From source file:org.parancoe.web.test.junit4.WebXmlContextLoader.java
/** * Loads a Spring ApplicationContext from the supplied * <code>locations</code>. and creates a standard {@link GenericWebApplicationContext} instance. * * @return a new application context//from w ww .j a va 2s . c o m * @see org.springframework.test.context.ContextLoader#loadContext * @see GenericWebApplicationContext * @see #createBeanDefinitionReader(GenericApplicationContext) * @see BeanDefinitionReader */ @Override public final ConfigurableApplicationContext loadContext(String... locations) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Loading ApplicationContext for locations [{}].", StringUtils.arrayToCommaDelimitedString(locations)); } GenericWebApplicationContext context = new GenericWebApplicationContext(); createBeanDefinitionReader(context).loadBeanDefinitions(locations); MockServletContext servletContext = new MockServletContext(); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); context.setServletContext(servletContext); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:com.apporiented.hermesftp.server.impl.SecureFtpServer.java
/** * {@inheritDoc}//from w w w . j a v a 2 s. c o m */ protected ServerSocket createServerSocket() throws IOException { SSLContext sslContext = getOptions().getSslContext(); int sslPort = getOptions().getImplicitSslPort(); SSLServerSocketFactory factory = sslContext.getServerSocketFactory(); SSLServerSocket sslServerSocket = (SSLServerSocket) factory.createServerSocket(sslPort); enableCipherSuites(sslServerSocket); log.info("Enabled cipher suites (implicit SSL): " + StringUtils.arrayToCommaDelimitedString(sslServerSocket.getEnabledCipherSuites())); return sslServerSocket; }
From source file:com.bose.aem.spring.config.ConfigClientProperties.java
public ConfigClientProperties(Environment environment) { String[] profiles = environment.getActiveProfiles(); if (profiles.length == 0) { profiles = environment.getDefaultProfiles(); }//from w w w .j a va 2 s .co m this.setProfile(StringUtils.arrayToCommaDelimitedString(profiles)); }
From source file:com.consol.citrus.simulator.servlet.SimulatorStatusServlet.java
@Override public void onTestStart(TestCase test) { runningTests.put(StringUtils.arrayToCommaDelimitedString(test.getParameters()), new TestResult(test.getName(), TestResult.RESULT.SUCCESS, test.getParameters())); }
From source file:io.pivotal.spring.cloud.service.common.HystrixAmqpServiceInfo.java
private String assembleAddresses(List<String> uris) { List<String> addresses = new ArrayList<>(); for (String uri : uris) { UriInfo uriInfo = new UriInfo(uri); int port = getSchemeBasedPort(uriInfo.getPort(), uriInfo.getScheme()); addresses.add(uriInfo.getHost() + ":" + port); }//from w w w . j av a 2 s. co m return StringUtils.arrayToCommaDelimitedString(addresses.toArray()); }