List of usage examples for java.lang String join
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
From source file:org.trustedanalytics.user.invite.EmailOrgUserInvitationService.java
private String getConsoleUrl() { if (Strings.isNullOrEmpty(appUrl)) { throw new IllegalArgumentException("Application url not set"); }/*from www .j av a 2 s . c o m*/ appUrl = appUrl.replaceAll("^http(s)?://", ""); String[] split = appUrl.split("\\."); if (split.length == 0) { throw new IllegalArgumentException("Invalid application url: " + appUrl); } split[0] = consoleHost; return (consoleUsesSsl ? "https://" : "http://") + String.join(".", split); }
From source file:controller.AppController.java
@RequestMapping(value = "/typesServices", method = RequestMethod.GET) public @ResponseBody String getTousTypesService(@RequestParam String entree, @RequestParam String langue) throws UnsupportedEncodingException { DBHelper helper = DBHelper.getInstance(); String typesServices = String.join(",", helper.getListeTousTypesService(entree, langue)); typesServices = StringEscapeUtils.escapeHtml4(typesServices); return typesServices; }
From source file:org.createnet.raptor.db.mapdb.MapDBConnectionTest.java
private void populateObjectData(long dataLength) throws IOException { ObjectNode obj = loadData("model"); obj.put("id", "test1"); obj.put("userId", "test-user"); objectStore.set(obj.get("id").asText(), obj, 0); obj.put("id", "test2"); obj.put("userId", "test-user-x"); objectStore.set(obj.get("id").asText(), obj, 0); obj.put("id", "test3"); obj.put("userId", "test-user"); objectStore.set(obj.get("id").asText(), obj, 0); // push data/*from www.j av a2 s . com*/ for (int i = 0; i < dataLength; i++) { ObjectNode record = loadData("record"); String streamId = "mylocation"; String objId = "test1"; String userId = "test-user"; Long timestamp = Instant.now().getEpochSecond() + i; record.put("streamId", streamId); record.put("objectId", objId); record.put("userId", userId); record.put("timestamp", timestamp); String key = String.join("-", new String[] { objId, streamId, timestamp.toString() }); dataStore.set(key, record, 0); } }
From source file:io.servicecomb.serviceregistry.config.AbstractPropertiesLoader.java
protected static String mergeStrings(String... strArr) { return String.join("", strArr); }
From source file:com.amazonaws.codepipeline.jobworker.JobWorkerDaemon.java
/** * Initializes the daemon./* ww w . j a va2 s.c om*/ * @param context daemon context. * @throws DaemonInitException exception during initialization */ @Override public void init(final DaemonContext context) throws DaemonInitException { LOGGER.info("Initialize daemon."); final String[] arguments = context.getArguments(); if (arguments != null) { LOGGER.debug(String.format("JobWorker arguments '%s'", String.join(", ", arguments))); loadConfiguration(arguments); } }
From source file:org.brunocvcunha.instagram4j.requests.InstagramDirectShareRequest.java
@Override public StatusResult execute() throws ClientProtocolException, IOException { String recipients = ""; if (this.recipients != null) { recipients = "\"" + String.join("\",\"", this.recipients.toArray(new String[0])) + "\""; }/*from w w w . ja va 2 s . com*/ List<Map<String, String>> data = new ArrayList<Map<String, String>>(); Map<String, String> map = new HashMap<String, String>(); if (shareType == ShareType.MEDIA) { map.put("type", "form-data"); map.put("name", "media_id"); map.put("data", mediaId); data.add(map); } map = map.size() > 0 ? new HashMap<String, String>() : map; map.put("type", "form-data"); map.put("name", "recipient_users"); map.put("data", "[[" + recipients + "]]"); data.add(map); map = new HashMap<String, String>(); map.put("type", "form-data"); map.put("name", "client_context"); map.put("data", InstagramGenericUtil.generateUuid(true)); data.add(map); map = new HashMap<String, String>(); map.put("type", "form-data"); map.put("name", "thread_ids"); map.put("data", "[" + (threadId != null ? threadId : "") + "]"); data.add(map); map = new HashMap<String, String>(); map.put("type", "form-data"); map.put("name", "text"); map.put("data", message == null ? "" : message); data.add(map); HttpPost post = createHttpRequest(); post.setEntity(new ByteArrayEntity(buildBody(data, api.getUuid()).getBytes(StandardCharsets.UTF_8))); try (CloseableHttpResponse response = api.getClient().execute(post)) { api.setLastResponse(response); int resultCode = response.getStatusLine().getStatusCode(); String content = EntityUtils.toString(response.getEntity()); log.info("Direct-share request result: " + resultCode + ", " + content); post.releaseConnection(); StatusResult result = parseResult(resultCode, content); return result; } }
From source file:com.cdd.bao.template.ClipboardSchema.java
public static String composeGroupTSV(Schema.Group group) { List<String> lines = new ArrayList<>(); lines.add("name\tdescription\tproperty URI\tgroup..."); formatGroupTSV(lines, group);//from w w w. j av a 2 s.c om return String.join("\n", lines); }
From source file:mtsar.api.csv.AnswerCSV.java
public static void write(Collection<Answer> answers, OutputStream output) throws IOException { try (final Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) { final Iterable<String[]> iterable = () -> answers.stream().sorted(ORDER) .map(answer -> new String[] { Integer.toString(answer.getId()), // id answer.getStage(), // stage Long.toString(answer.getDateTime().toInstant().getEpochSecond()), // datetime String.join("|", answer.getTags()), // tags answer.getType(), // type Integer.toString(answer.getTaskId()), // task_id Integer.toString(answer.getWorkerId()), // worker_id String.join("|", answer.getAnswers()) // answers }).iterator();//from w w w.ja v a2s . c o m FORMAT.withHeader(HEADER).print(writer).printRecords(iterable); } }
From source file:fi.hsl.parkandride.itest.HubsAndFacilitiesReportITest.java
private void checkHubsAndFacilities_facilityInfo(Workbook workbook) { final Sheet facilities = workbook.getSheetAt(1); assertThat(facilities.getPhysicalNumberOfRows()).isEqualTo(2); final List<String> facilityInfo = getDataFromRow(facilities, 1); assertThat(facilityInfo).containsSequence(facility1.name.fi, String.join(", ", facility1.aliases), hub.name.fi, operator1.name.fi, translationService.translate(facility1.status), facility1.statusDescription.fi, String.format(Locale.ENGLISH, "%.4f", facility1.location.getCentroid().getX()), String.format(Locale.ENGLISH, "%.4f", facility1.location.getCentroid().getY()), "", "08:00 - 18:00", "08:00 - 18:00", facility1.openingHours.info.fi, "" + facility1.builtCapacity.entrySet().stream() .filter(entry -> asList(motorCapacities).contains(entry.getKey())) .mapToInt(entry -> entry.getValue()).sum(), "" + facility1.builtCapacity.entrySet().stream() .filter(entry -> asList(bicycleCapacities).contains(entry.getKey())) .mapToInt(entry -> entry.getValue()).sum(), "" + facility1.builtCapacity.getOrDefault(CAR, 0), "" + facility1.builtCapacity.getOrDefault(DISABLED, 0), "" + facility1.builtCapacity.getOrDefault(ELECTRIC_CAR, 0), "" + facility1.builtCapacity.getOrDefault(MOTORCYCLE, 0), "" + facility1.builtCapacity.getOrDefault(BICYCLE, 0), "" + facility1.builtCapacity.getOrDefault(BICYCLE_SECURE_SPACE, 0)); }
From source file:org.fcrepo.camel.reindexing.RestProcessor.java
/** * Convert the incoming REST request into the correct * Fcrepo header fields.//from w ww . jav a2 s . co m * * @param exchange the current message exchange */ public void process(final Exchange exchange) throws Exception { final Message in = exchange.getIn(); final String path = in.getHeader(Exchange.HTTP_PATH, "", String.class); final String contentType = in.getHeader(Exchange.CONTENT_TYPE, "", String.class); final String body = in.getBody(String.class); final Set<String> endpoints = new HashSet<>(); for (final String s : in.getHeader(ReindexingHeaders.RECIPIENTS, "", String.class).split(",")) { endpoints.add(s.trim()); } in.removeHeaders("CamelHttp*"); in.removeHeader("JMSCorrelationID"); in.setBody(null); if (contentType.equals("application/json") && body != null && !body.trim().isEmpty()) { final ObjectMapper mapper = new ObjectMapper(); try { final JsonNode root = mapper.readTree(body); final Iterator<JsonNode> ite = root.elements(); while (ite.hasNext()) { final JsonNode n = ite.next(); endpoints.add(n.asText()); } } catch (JsonProcessingException e) { LOGGER.debug("Invalid JSON", e); in.setHeader(Exchange.HTTP_RESPONSE_CODE, BAD_REQUEST); in.setBody("Invalid JSON"); } } in.setHeader(FcrepoHeaders.FCREPO_IDENTIFIER, path); in.setHeader(ReindexingHeaders.RECIPIENTS, String.join(",", endpoints)); }