List of usage examples for java.lang String join
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
From source file:edu.umd.umiacs.clip.tools.classifier.LibSVMUtils.java
public static List<String> applyZscoringModel(Map<Integer, Pair<Double, Double>> model, List<String> examples) { return examples.stream().map(LibSVMUtils::split).map(triple -> triple.getLeft() + String.join(" ", triple.getMiddle().stream().map(pair -> Pair.of(pair.getLeft(), (!model.containsKey(pair.getLeft()) || model.get(pair.getLeft()).getRight() == 0) ? 1f : ((pair.getRight() - model.get(pair.getLeft()).getLeft()) / model.get(pair.getLeft()).getRight()))) .filter(pair -> pair.getRight().floatValue() != 0f) .map(pair -> pair.getLeft() + ":" + pair.getRight().floatValue()).collect(toList())) + triple.getRight()).collect(toList()); }
From source file:net.continuumsecurity.Config.java
public String getNoProxyHosts() { return String.join(",", validateAndGetStringArray("upstreamProxy.noProxyHosts")); }
From source file:com.vmware.admiral.host.BaseManagementHostClusterIT.java
protected ManagementHost setUpHost(int port, URI sandboxUri, List<String> peers) throws Throwable { String sandboxPath;// w ww.j av a2s .c o m if (sandboxUri != null) { sandboxPath = sandboxUri.toString().replace("file:", ""); sandboxPath = sandboxPath.substring(0, sandboxPath.lastIndexOf("/")); } else { TemporaryFolder sandbox = new TemporaryFolder(test.getRoot()); sandbox.create(); sandboxPath = sandbox.getRoot().toPath().toString(); } String hostId = getClass().getSimpleName() + "-" + port; String peerNodes = String.join(",", peers); ManagementHost host = ManagementHostBaseTest.createManagementHost(new String[] { ARGUMENT_PREFIX + "id" + ARGUMENT_ASSIGNMENT + hostId, ARGUMENT_PREFIX + FIELD_NAME_START_MOCK_HOST_ADAPTER_INSTANCE + ARGUMENT_ASSIGNMENT + TRUE.toString(), ARGUMENT_PREFIX + AuthBootstrapService.LOCAL_USERS_FILE + ARGUMENT_ASSIGNMENT + LOCAL_USERS_FILE, ARGUMENT_PREFIX + "bindAddress" + ARGUMENT_ASSIGNMENT + "0.0.0.0", ARGUMENT_PREFIX + "peerNodes" + ARGUMENT_ASSIGNMENT + peerNodes, ARGUMENT_PREFIX + "sandbox" + ARGUMENT_ASSIGNMENT + sandboxPath, ARGUMENT_PREFIX + "keyFile" + ARGUMENT_ASSIGNMENT + KEY_FILE, ARGUMENT_PREFIX + "certificateFile" + ARGUMENT_ASSIGNMENT + CERTIFICATE_FILE, ARGUMENT_PREFIX + "securePort" + ARGUMENT_ASSIGNMENT + port, ARGUMENT_PREFIX + "port" + ARGUMENT_ASSIGNMENT + "-1" }, true); assertTrue(host.isAuthorizationEnabled()); assertNotNull(host.getAuthorizationServiceUri()); assertTrue(host.isStarted()); // Sleep to give some time for the host to initialize Thread.sleep(3000); return host; }
From source file:com.netflix.spinnaker.halyard.cli.command.v1.NestableCommand.java
/** * Used to consistently format exceptions thrown by connecting to the halyard daemon. *///w w w.ja v a2 s . c o m private void safeExecuteThis() { try { if (options != null) { List<String> available = options(translateFieldName(options)); AnsiUi.raw(String.join(" ", available)); } else { executeThis(); } } catch (RetrofitError e) { if (e.getCause() instanceof ConnectException) { AnsiUi.error(e.getCause().getMessage()); AnsiUi.remediation("Is your daemon running?"); System.exit(1); } AnsiUi.error(e.getMessage()); AnsiUi.remediation("Try the command again with the --debug flag."); System.exit(1); } catch (TaskKilledException e) { AnsiUi.failure(e.getMessage()); System.exit(7); } catch (ExpectedDaemonFailureException e) { showRandomFailureMessage(); AnsiUi.failure(e.getMessage()); if (GlobalOptions.getGlobalOptions().isDebug()) { e.printStackTrace(); } System.exit(1); } catch (Exception e) { if (GlobalOptions.getGlobalOptions().isDebug()) { e.printStackTrace(); } else { AnsiUi.error(e.getMessage()); } System.exit(3); } }
From source file:uk.ac.ebi.eva.pipeline.io.mappers.AnnotationLineMapper.java
/** * From org.opencb.biodata.formats.annotation.io.VepFormatReader#parseVariant(java.lang.String, java.lang.String) *///from w w w. j ava 2 s .co m private Map<String, String> parseVariant(String variantString, String coordinatesString) { // private Map<String,String> parseVariant(String coordinatesString, String alternativeString) { Map<String, String> parsedVariant = new HashMap<>(5); try { String[] variantLocationFields = coordinatesString.split("[:-]"); // parsedVariant.put("chromosome", variantLocationFields[0]); // parsedVariant.put("start", variantLocationFields[1]); parsedVariant.put("end", (variantLocationFields.length > 2) ? variantLocationFields[2] : variantLocationFields[1]); } catch (ArrayIndexOutOfBoundsException e) { logger.error("Unexpected format for column 2: " + coordinatesString); throw e; } try { // Some VEP examples: // 1_718787_-/T 1:718786-718787 T ... // 1_718787_T/- 1:718787 - ... // 1_718788_T/A 1:718788 A ... String[] variantFields = variantString.split("[\\/]"); // String[] variantFields = variantString.split("[\\_\\/]"); String[] leftVariantFields = variantFields[0].split("_"); // Chr id containing _ if (leftVariantFields.length > 3) { parsedVariant.put("chromosome", String.join("_", (String[]) ArrayUtils.subarray(leftVariantFields, 0, leftVariantFields.length - 2))); } else { parsedVariant.put("chromosome", leftVariantFields[0]); } parsedVariant.put("start", leftVariantFields[leftVariantFields.length - 2]); parsedVariant.put("reference", leftVariantFields[leftVariantFields.length - 1]); parsedVariant.put("alternative", variantFields[1]); } catch (ArrayIndexOutOfBoundsException e) { logger.error("Unexpected variant format for column 1: " + variantString); throw e; } return parsedVariant; }
From source file:org.shareok.data.documentProcessor.DocumentProcessorUtil.java
/** * Return the folder path of a file//w w w.j a va 2 s . co m * Note: suppose the file path is separated by the File.separator * * @param filePath * @return String : folder path */ public static String getFileContainerPath(String filePath) { String fileContainerPath = null; try { String[] filePathInfo = filePath.split("/"); if (filePathInfo.length == 1) { return File.separator; } else { filePathInfo[filePathInfo.length - 1] = ""; fileContainerPath = String.join(File.separator, filePathInfo); } } catch (Exception ex) { ex.printStackTrace(); } return fileContainerPath; }
From source file:de.jackwhite20.japs.server.JaPSServer.java
public void removeClient(Connection connection) { for (String s : connection.channels()) { channelSessions.get(s).remove(connection); }/*from ww w .jav a2 s . c o m*/ if (!connection.channels().isEmpty()) { LOGGER.log(Level.FINE, "[{0}] Channels unsubscribed from {1}: {2}", new Object[] { connection.remoteAddress().toString(), connection.name(), String.join(", ", connection.channels()) }); } }
From source file:business.services.MailService.java
public void notifyLab(@NotNull LabRequestRepresentation labRequest) { log.info("Notify lab for lab request " + labRequest.getId() + "."); Lab lab = labRequest.getLab();/*from w w w . j a v a2s .c o m*/ if (lab.getEmailAddresses() == null || lab.getEmailAddresses().isEmpty()) { log.warn("No email address set for lab " + lab.getNumber()); return; } String recipients = String.join(", ", lab.getEmailAddresses()); log.info("Sending notification to " + recipients); try { MimeMessageHelper message = new MimeMessageHelper(mailSender.createMimeMessage()); for (String email : lab.getEmailAddresses()) { message.addTo(email); } message.setFrom(getFrom(), fromName); message.setReplyTo(replyAddress, replyName); message.setSubject(String.format("PALGA-verzoek aan laboratorium, aanvraagnummer: %s", labRequest.getLabRequestCode())); String labRequestLink = getLink("/#/lab-request/view/" + labRequest.getId()); String body = String.format(labNotificationTemplate, labRequestLink, // %1 labRequest.getLabRequestCode(), // %2 labRequest.getRequest().getTitle(), // %3 labRequest.getRequesterName(), // %4 labRequest.getRequest().getPathologistName() == null ? "" : labRequest.getRequest().getPathologistName(), // %5 labRequest.getRequesterLab().getName() // %6 ); message.setText(body); mailSender.send(message.getMimeMessage()); } catch (MessagingException e) { log.error(e.getMessage()); throw new EmailError("Email error: " + e.getMessage()); } catch (UnsupportedEncodingException e) { log.error(e.getMessage()); throw new EmailError("Email error: " + e.getMessage()); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractComponent.java
@Override public String getStyleName() { if (CollectionUtils.isEmpty(styles)) return StringUtils.EMPTY; return String.join(" ", styles); }
From source file:ddf.catalog.registry.transformer.RegistryServiceConverter.java
private void readClassificationValue(HierarchicalStreamReader reader, MetacardImpl meta, String name) { String key = CLASSIFICATIONS.get(name); if (key != null) { if ("xs:dateTime".equals(reader.getAttribute("slotType"))) { meta.setAttribute(key, readDates(reader).get(0)); } else {// ww w. j a v a 2s.c om meta.setAttribute(key, String.join(", ", readValueList(reader))); } } }