List of usage examples for java.util StringJoiner StringJoiner
public StringJoiner(CharSequence delimiter)
From source file:com.caricah.iotracah.core.handlers.RequestHandler.java
private IOTPermission getPermission(String partition, String username, String clientId, AuthorityRole role, String topic) {/* w w w. ja va 2 s. c o m*/ String permissionString = new StringJoiner("").add(role.name()).add(":").add(topic).toString(); return new IOTPermission(partition, username, clientId, permissionString); }
From source file:org.rippleosi.search.patient.stats.search.PatientStatsQueryStrategy.java
@Override public Object getRequestBody() { OpenEHRPatientStatsRequestBody body = new OpenEHRPatientStatsRequestBody(); // create a CSV list of NHS Numbers for OpenEHR to query associated data StringJoiner csvBuilder = new StringJoiner(","); for (PatientSummary patient : patientSummaries) { csvBuilder.add(patient.getNhsNumber()); }/*from w w w. j a v a 2 s . c om*/ body.setExternalIds(csvBuilder.toString()); body.setExternalNamespace(externalNamespace); return body; }
From source file:org.openrepose.powerfilter.intrafilterlogging.RequestLog.java
private Map<String, String> convertRequestHeadersToMap(HttpServletRequest httpServletRequest) { Map<String, String> headerMap = new LinkedHashMap<>(); List<String> headerNames = Collections.list(httpServletRequest.getHeaderNames()); for (String headerName : headerNames) { StringJoiner stringJoiner = new StringJoiner(","); Collections.list(httpServletRequest.getHeaders(headerName)).forEach(stringJoiner::add); headerMap.put(headerName, stringJoiner.toString()); }//from www . j a v a 2 s . co m return headerMap; }
From source file:org.eclipse.winery.tools.copybaragenerator.CopybaraGenerator.java
public String generateCopybaraConfigFile() { StringJoiner copybaraConfig = new StringJoiner("\n"); copybaraConfig.add("urlOrigin = \"https://github.com/OpenTOSCA/tosca-definitions-internal.git\""); copybaraConfig.add("urlDestination = \"file:///tmp/copybara/tosca-definitions-public\""); copybaraConfig.add("core.workflow("); copybaraConfig.add(" name = \"default\","); copybaraConfig.add(" origin = git.origin("); copybaraConfig.add(" url = urlOrigin,"); copybaraConfig.add(" ref = \"master\","); copybaraConfig.add(" ),"); copybaraConfig.add(" destination = git.destination("); copybaraConfig.add(" url = urlDestination,"); copybaraConfig.add(" fetch = \"master\","); copybaraConfig.add(" push = \"master\","); copybaraConfig.add(" ),"); copybaraConfig/* ww w. j av a 2s.com*/ .add(" authoring = authoring.pass_thru(\"OpenTOSCA Bot <opentosca@iaas.uni-stuttgart.de>\"),"); copybaraConfig.add(" " + generateOriginFilesConfig()); copybaraConfig.add(" destination_files = glob([\"**\"], exclude = [\"README_INTERNAL.md\"]),"); copybaraConfig.add(")"); return copybaraConfig.toString(); }
From source file:org.jhk.pulsing.search.elasticsearch.client.ESRestClient.java
public Optional<String> putDocument(String index, String type, long id, Map<String, String> jsonObject) { String endpoint = new StringJoiner("/").add(index).add(type).add(id + "").toString(); _LOGGER.debug("ESRestClient.putDocument: " + endpoint + " - " + jsonObject); try {/*from w w w . j a v a2 s.c o m*/ Optional<Response> response = performRequest("PUT", endpoint, Collections.EMPTY_MAP, new NStringEntity(_objectMapper.writeValueAsString(jsonObject)), EMPTY_HEADER); if (response.isPresent()) { HttpEntity hEntity = response.get().getEntity(); String result = EntityUtils.toString(hEntity); _LOGGER.debug("ESRestClient.putDocument: result - " + result); return Optional.of(result); } } catch (IOException iException) { iException.printStackTrace(); } return Optional.empty(); }
From source file:be.bittich.quote.service.impl.TokenServiceImpl.java
@Override public String serializeToken(SecurityToken token) { return new StringJoiner(SEPARATOR).add(token.getExtendedInformation()).add("" + token.getKeyCreationTime()) .add(token.getIpAddress()).toString(); }
From source file:se.nrm.dina.naturarv.portal.controller.MainChart.java
private String buildLabel(Month month, boolean isSwedish) { log.info("month : {} -- {}", month, month.getEnglish()); StringJoiner sj = new StringJoiner(" "); String monName = isSwedish ? month.getSwedish() : month.getEnglish(); int monNum = month.getNumberOfMonth(); sj.add(monName);/* w w w . ja v a 2s.com*/ if (monNum > today.getMonthValue()) { sj.add(String.valueOf(lastYearDate.getYear())); } else { sj.add(String.valueOf(today.getYear())); } return sj.toString(); }
From source file:ch.newscron.encryption.Encryption.java
/** * Given a JSONObject, extracts its fields and computes the hash using the MD5 algorithm * @param obj is a JSONObject consisting of the four fields * @return a MD5 hash of type byte[]//from w w w . j av a 2 s.c o m */ public static byte[] createMD5Hash(JSONObject obj) { //Create a string of the fields with format: "<customerId>$<rew1>$<rew2>$<val>" StringJoiner stringToHash = new StringJoiner("$"); stringToHash.add((String) obj.get("custID")); stringToHash.add((String) obj.get("rew1")); stringToHash.add((String) obj.get("rew2")); stringToHash.add((String) obj.get("val")); //Get hash of string try { MessageDigest m = MessageDigest.getInstance("MD5"); byte[] hash = m.digest(stringToHash.toString().getBytes("UTF-8")); return hash; } catch (Exception e) { } return null; }
From source file:com.sri.ai.praise.sgsolver.solver.HOGMQueryError.java
@Override public String toString() { StringJoiner sj = new StringJoiner(""); if (context == Context.UNKNOWN) { sj.add("General Error: "); } else if (context == Context.QUERY) { sj.add("Error in Query "); } else if (context == Context.MODEL) { sj.add("Error in Model "); }//from w ww . j ava 2 s. com if (context != Context.UNKNOWN) { sj.add("at Line " + line + ": "); } sj.add(errorMessage); if (throwable != null) { sj.add("\n"); sj.add(ExceptionUtils.getStackTrace(throwable)); } return sj.toString(); }
From source file:org.jhk.pulsing.sandbox.timeline.cli.CommandCli.java
private void processCommandLine(String command) { try {/*ww w. jav a 2 s . c o m*/ // only support 3 args max String[] split = command.split(" "); if (split.length > 2) { // hacky for now... String[] temp = new String[3]; temp[0] = split[0]; temp[1] = split[1]; StringJoiner joiner = new StringJoiner(" "); for (int loop = 2; loop < split.length; loop++) { joiner.add(split[loop]); // seriously why doesn't StringJoiner accept a List or Array... } temp[2] = joiner.toString(); split = temp; } CommandLine commandLine = cliParser.parse(cliOptions, split); if (commandLine.hasOption("help")) { cliFormatter.printHelp("timeline", cliOptions); } else if (commandLine.hasOption("getTimeline")) { long timeLineId = Long.valueOf(commandLine.getOptionValue("getTimeline")); Optional<List<String>> tweets = timeLine.getTweets(timeLineId); if (tweets.isPresent()) { LOGGER.info("Tweets => {}", tweets.get()); } else { LOGGER.info("Unable to retrieve tweets with id => {}", timeLineId); } } else if (commandLine.hasOption("tweet")) { String tweet = commandLine.getOptionValue("tweet"); queue.publish(tweet); } else if (commandLine.hasOption("getUser")) { long userId = Long.valueOf(commandLine.getOptionValue("getUser")); Optional<User> user = userCache.getUser(userId); if (user.isPresent()) { LOGGER.info("Retrieved user => {}", user.get()); } else { LOGGER.info("Unable to retrieve user with id => {}", userId); } } else if (commandLine.hasOption("getFollowers")) { long userId = Long.valueOf(commandLine.getOptionValue("getFollowers")); String userScreeNames = userCache.getFollowers(userId).stream().map(user -> user.getScreenName()) .collect(Collectors.joining(",")); LOGGER.info("Retrieved followers => {}", userScreeNames); } } catch (Exception exp) { LOGGER.error(exp.getMessage(), exp); } }