List of usage examples for java.util StringJoiner add
public StringJoiner add(CharSequence newElement)
From source file:io.mapzone.arena.share.content.ImagePngContentProvider.java
@Override public ImagePngContent get() { ImagePngContent content = new ImagePngContent(); StringJoiner layers = new StringJoiner(","); for (SelectionDescriptor selection : context.selectionDescriptors.get()) { layers.add(GeoServerUtils.simpleName(selection.layer.get().label.get())); // FIXME, if multilayers are working, remove this break!!! //break;// ww w .j a v a 2 s. co m } Envelope bbox = context.boundingBox.get(); String extent = Joiner.on(",").join((int) bbox.getMinX(), (int) bbox.getMinY(), (int) bbox.getMaxX(), (int) bbox.getMaxY()); String imageUrl = ArenaPlugin.instance().config().getProxyUrl() + GeoServerStarter.ALIAS; List<NameValuePair> params = new ArrayList() { { add(nameValue("SERVICE", "WMS")); add(nameValue("VERSION", "1.3.0")); add(nameValue("REQUEST", "GetMap")); add(nameValue("FORMAT", "image/png")); add(nameValue("CRS", "EPSG:3857")); add(nameValue("BBOX", extent.toString())); add(nameValue("LAYERS", layers.toString())); } }; if (!StringUtils.isBlank(ArenaPlugin.instance().config().getServiceAuthToken())) { params.add(nameValue("authToken", ArenaPlugin.instance().config().getServiceAuthToken())); } content.imgWidth = context.displaySize.get().x; content.imgHeight = context.displaySize.get().y; content.previewWidth = 320; content.previewHeight = content.previewWidth * content.imgHeight / content.imgWidth; ArrayList previewParams = new ArrayList(params) { { add(nameValue("WIDTH", content.previewWidth)); add(nameValue("HEIGHT", content.previewHeight)); } }; content.previewResource = imageUrl + "?" + URLEncodedUtils.format(previewParams, "UTF-8"); ArrayList imgParams = new ArrayList(params) { { add(nameValue("WIDTH", content.imgWidth)); add(nameValue("HEIGHT", content.imgHeight)); } }; content.imgResource = imageUrl + "?" + URLEncodedUtils.format(imgParams, "UTF-8"); return content; }
From source file:info.archinnov.achilles.internals.codegen.meta.UDTMetaCodeGen.java
private MethodSpec buildComponentsProperty(TypeName rawBeanType, List<FieldMetaSignature> parsingResults) { TypeName returnType = genericType(LIST, genericType(ABSTRACT_PROPERTY, rawBeanType, WILDCARD, WILDCARD)); final StringJoiner allFields = new StringJoiner(", "); parsingResults.stream().map(x -> x.context.fieldName).forEach(x -> allFields.add(x)); StringBuilder fieldList = new StringBuilder(); fieldList.append("return $T.asList(").append(allFields.toString()).append(")"); return MethodSpec.methodBuilder("getComponentsProperty").addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED).returns(returnType).addStatement(fieldList.toString(), ARRAYS) .build();/* w w w . ja v a2s .c om*/ }
From source file:org.wildfly.test.security.common.elytron.SimpleServerSslContext.java
@Override public void create(ModelControllerClient client, CLIWrapper cli) throws Exception { // /subsystem=elytron/server-ssl-context=twoWaySSC:add(key-manager=twoWayKM,protocols=["TLSv1.2"], // trust-manager=twoWayTM,security-domain=test,need-client-auth=true) StringBuilder sb = new StringBuilder("/subsystem=elytron/server-ssl-context=").append(name).append(":add("); if (StringUtils.isNotBlank(keyManager)) { sb.append("key-manager=\"").append(keyManager).append("\", "); }/* w ww .j a v a 2 s. co m*/ if (protocols != null) { StringJoiner joiner = new StringJoiner(", "); for (String s : protocols) { String s1 = "\"" + s + "\""; joiner.add(s1); } sb.append("protocols=[").append(joiner.toString()).append("], "); } if (StringUtils.isNotBlank(trustManager)) { sb.append("trust-manager=\"").append(trustManager).append("\", "); } if (StringUtils.isNotBlank(securityDomain)) { sb.append("security-domain=\"").append(securityDomain).append("\", "); } if (authenticationOptional != null) { sb.append("authentication-optional=").append(authenticationOptional).append(", "); } sb.append("need-client-auth=").append(needClientAuth).append(")"); cli.sendLine(sb.toString()); }
From source file:net.straylightlabs.archivo.net.MindCommand.java
private String buildRequest() { failOnInvalidCommand();//from w w w. j av a 2 s . co m List<String> headerLines = buildHeaderLines(); bodyData.put("type", commandType.toString()); String body = bodyData.toString(); // The length is the number of characters plus two bytes for each \r\n line ending int headerLength = headerLines.stream().mapToInt(String::length).sum() + (headerLines.size() * MindRPC.LINE_ENDING.length()); headerLines.add(0, String.format("MRPC/2 %d %d", headerLength, body.length())); StringJoiner joiner = new StringJoiner(MindRPC.LINE_ENDING, "", MindRPC.LINE_ENDING); headerLines.stream().forEach(joiner::add); joiner.add(body); return joiner.toString(); }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.external.StatsTest.java
@Test public void itGetsApplicationStats() throws Exception { HttpGet httpGet = new HttpGet("http://localhost:3333/crs/stats"); CloseableHttpResponse httpResponse = null; try {//from w ww.j a va2s.com httpResponse = httpClient.execute(httpGet); String responseContent = EntityUtils.toString(httpResponse.getEntity()); ObjectMapper objectMapper = new ObjectMapper(); Map<String, Object> data = objectMapper.readValue(responseContent, new TypeReference<HashMap<String, Object>>() { }); assertThat(data.keySet(), containsInAnyOrder("app", "stats")); Map<String, Object> appData = (Map<String, Object>) data.get("app"); assertThat(appData.keySet(), containsInAnyOrder("buildTimestamp", "name", "deploy-dir", "git-revision", "version")); Map<String, Object> statsData = (Map<String, Object>) data.get("stats"); assertThat(statsData.keySet(), containsInAnyOrder("dnsMap", "httpMap", "totalDnsCount", "totalHttpCount", "totalDsMissCount", "appStartTime", "averageDnsTime", "averageHttpTime", "updateTracker")); Map<String, Object> dnsStats = (Map<String, Object>) statsData.get("dnsMap"); Map<String, Object> cacheDnsStats = (Map<String, Object>) dnsStats.values().iterator().next(); assertThat(cacheDnsStats.keySet(), containsInAnyOrder("czCount", "geoCount", "missCount", "dsrCount", "errCount", "deepCzCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount")); Map<String, Object> httpStats = (Map<String, Object>) statsData.get("httpMap"); Map<String, Object> cacheHttpStats = (Map<String, Object>) httpStats.values().iterator().next(); assertThat(cacheHttpStats.keySet(), containsInAnyOrder("czCount", "geoCount", "missCount", "dsrCount", "errCount", "deepCzCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount")); Map<String, Object> updateTracker = (Map<String, Object>) statsData.get("updateTracker"); Set<String> keys = updateTracker.keySet(); List<String> expectedStats = Arrays.asList("lastCacheStateCheck", "lastCacheStateChange", "lastConfigCheck", "lastConfigChange"); if (!keys.containsAll(expectedStats)) { StringJoiner joiner = new StringJoiner(","); for (String stat : expectedStats) { joiner.add(stat); } fail("Missing at least one of the following keys '" + joiner.toString() + "'"); } } finally { if (httpResponse != null) httpResponse.close(); } }
From source file:cc.altruix.javaprologinterop.PlUtilsLogic.java
protected String composeVarNameTxt(String[] varNames) { final StringJoiner stringJoiner = new StringJoiner(","); Arrays.stream(varNames).forEach(x -> stringJoiner.add(x)); return stringJoiner.toString(); }
From source file:org.polymap.p4.data.importer.prompts.CharsetPrompt.java
private String displayName(Charset charset) { StringBuffer name = new StringBuffer(charset.displayName(Polymap.getSessionLocale())); if (!charset.aliases().isEmpty()) { name.append(" ( "); StringJoiner joiner = new StringJoiner(", "); for (String alias : charset.aliases()) { joiner.add(alias); }/*from w w w . j a v a 2 s . com*/ name.append(joiner.toString()); name.append(" )"); } return name.toString(); }
From source file:edu.emory.mathcs.nlp.zzz.CSVRadiology.java
public void categorize(String inputFile) throws Exception { CSVParser parser = new CSVParser(IOUtils.createBufferedReader(inputFile), CSVFormat.DEFAULT); List<CSVRecord> records = parser.getRecords(); StringJoiner join; CSVRecord record;//from ww w . jav a2 s . c om for (int i = 0; i <= 500; i++) { if (i == 0) continue; record = records.get(i); join = new StringJoiner(" "); for (int j = 2; j < 7; j++) join.add(record.get(j)); System.out.println(join.toString()); } parser.close(); }
From source file:info.archinnov.achilles.internals.statements.StatementWrapper.java
default void appendRowDataToBuilder(Row row, List<ColumnDefinitions.Definition> columnsDef, StringBuilder builder) {//from w w w . j a v a 2 s . c o m StringJoiner joiner = new StringJoiner(", ", "\t", "\n"); IntStream.range(0, columnsDef.size()).forEach(index -> { final ColumnDefinitions.Definition def = columnsDef.get(index); final Object value = extractValueFromRow(row, index, def.getType()); joiner.add(format("%s: %s", def.getName(), value)); }); builder.append(joiner.toString()); }
From source file:info.archinnov.achilles.internals.parser.FieldInfoParser.java
protected Tuple2<CodeBlock, ColumnInfo> buildColumnInfo(AnnotationTree annotationTree, VariableElement elm, String fieldName, TypeName rawEntityClass) { final CodeBlock.Builder builder = CodeBlock.builder(); final boolean isFrozen = containsAnnotation(annotationTree, Frozen.class); final Optional<TypedMap> partitionKey = extractTypedMap(annotationTree, PartitionKey.class); final Optional<TypedMap> clusteringColumn = extractTypedMap(annotationTree, ClusteringColumn.class); final Optional<TypedMap> computed = extractTypedMap(annotationTree, Computed.class); validateAllowedFrozen(isFrozen, aptUtils, elm, fieldName, rawEntityClass); if (partitionKey.isPresent()) { final int order = partitionKey.get().getTyped("order"); aptUtils.validateTrue(order > 0, "@PartitionKey order on field '%s' of class '%s' should be > 0, the ordering starts at 1", fieldName, rawEntityClass); builder.add("new $T($L, $L)", PARTITION_KEY_INFO, order, isFrozen); return Tuple2.of(builder.build(), new PartitionKeyInfo(order, isFrozen)); } else if (clusteringColumn.isPresent()) { final int order = clusteringColumn.get().getTyped("order"); final ClusteringOrder clusteringOrder = clusteringColumn.get().<Boolean>getTyped("asc") ? ASC : DESC; aptUtils.validateTrue(order > 0, "@ClusteringColumn order on field '%s' of class '%s' should be > 0, the ordering starts at 1", fieldName, rawEntityClass); builder.add("new $T($L, $L, $T.$L)", CLUSTERING_COLUMN_INFO, order, isFrozen, CLUSTERING_ORDER, clusteringOrder.name()); return Tuple2.of(builder.build(), new ClusteringColumnInfo(order, isFrozen, clusteringOrder)); } else if (computed.isPresent()) { final TypedMap typedMap = computed.get(); final String function = typedMap.getTyped("function"); final String alias = typedMap.getTyped("alias"); final List<String> targetColumns = typedMap.getTyped("targetColumns"); final Class<?> cqlClass = typedMap.getTyped("cqlClass"); final ClassName className = ClassName.get(cqlClass); final StringJoiner joiner = new StringJoiner(","); for (String x : targetColumns) { joiner.add("\"" + x + "\""); }//from ww w . ja v a 2 s.co m builder.add("new $T($S, $S, $T.asList(new String[]{$L}), $T.class)", COMPUTED_COLUMN_INFO, function, alias, ARRAYS, joiner.toString(), className); return Tuple2.of(builder.build(), new ComputedColumnInfo(function, alias, targetColumns, cqlClass)); } else { builder.add("new $T($L)", COLUMN_INFO, isFrozen); return Tuple2.of(builder.build(), new ColumnInfo(isFrozen)); } }