List of usage examples for com.google.common.base Splitter on
@CheckReturnValue @GwtIncompatible("java.util.regex") public static Splitter on(final Pattern separatorPattern)
From source file:com.turn.sorcerer.util.email.Emailer.java
private void sendEmail() throws EmailException, UnknownHostException { List<String> addresses = Lists .newArrayList(Splitter.on(',').omitEmptyStrings().trimResults().split(ADMIN_EMAIL.getAdmins())); logger.info("Sending email to {}", addresses.toString()); Email email = new HtmlEmail(); email.setHostName(ADMIN_EMAIL.getHost()); email.setSocketTimeout(30000); // 30 seconds email.setSocketConnectionTimeout(30000); // 30 seconds for (String address : addresses) { email.addTo(address);//w ww . j a v a 2 s. c om } email.setFrom( SorcererInjector.get().getModule().getName() + "@" + InetAddress.getLocalHost().getHostName()); email.setSubject(title); email.setMsg(body); email.send(); }
From source file:com.google.testing.security.firingrange.tests.reflected.ContentSniffing.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String echoedParam = Strings.nullToEmpty(request.getParameter(ECHOED_PARAM)); echoedParam = echoedParam.replace("\"", "\\\""); String template = Templates.getTemplate("json.tmpl", getClass()); String testType = Splitter.on('/').splitToList(request.getPathInfo()).get(1); String contentType;/* ww w . ja v a 2s . c om*/ switch (testType) { case "json": contentType = "application/json"; break; case "plaintext": contentType = "text/plain"; break; default: throw new IllegalArgumentException(); } Responses.sendXssed(response, Templates.replacePayload(template, echoedParam), contentType); }
From source file:org.apache.nifi.toolkit.zkmigrator.ZooKeeperEndpointConfig.java
ZooKeeperEndpointConfig(String connectString) { Preconditions.checkArgument(!Strings.isNullOrEmpty(connectString), "connectString can not be null or empty"); this.connectString = connectString; final String[] connectStringPath = connectString.split("/", 2); this.servers = Lists.newArrayList(connectStringPath[0].split(",")); if (connectStringPath.length == 2) { this.path = '/' + Joiner.on('/') .join(Splitter.on('/').omitEmptyStrings().trimResults().split(connectStringPath[1])); } else {// w w w. ja v a 2 s. co m path = "/"; } }
From source file:org.dishevelled.bio.assembly.gfa2.Header.java
/** * Parse a header GFA 2.0 record from the specified value. * * @param value value, must not be null/*ww w . j ava2 s. c om*/ * @return a header GFA 2.0 record parsed from the specified value */ public static Header valueOf(final String value) { checkNotNull(value); checkArgument(value.startsWith("H"), "header value must start with H"); List<String> tokens = Splitter.on("\t").splitToList(value); ImmutableMap.Builder<String, Tag> tags = ImmutableMap.builder(); for (int i = 1; i < tokens.size(); i++) { Tag tag = Tag.valueOf(tokens.get(i)); tags.put(tag.getName(), tag); } return new Header(tags.build()); }
From source file:org.jboss.hal.core.finder.FinderColumnStorage.java
Set<String> pinnedItems() { Set<String> items = new HashSet<>(); if (storage != null) { String pinnedItems = storage.getItem(this.pinnedId); if (pinnedItems != null) { //noinspection ResultOfMethodCallIgnored Iterables.addAll(items, Splitter.on(',').split(pinnedItems)); }/*from w w w .j a va2s .co m*/ } return items; }
From source file:org.jclouds.elastichosts.functions.MapToDriveInfo.java
@Override public DriveInfo apply(Map<String, String> from) { if (from.size() == 0) return null; DriveInfo.Builder builder = new DriveInfo.Builder(); if (from.containsKey("status")) builder.status(DriveStatus.fromValue(from.get("status"))); if (from.containsKey("use")) builder.use(Splitter.on(',').split(from.get("use"))); builder.name(from.get("name")); if (from.containsKey("bits")) builder.bits(new Integer(from.get("bits"))); if (from.containsKey("url")) builder.url(URI.create(from.get("url"))); if (from.containsKey("read:bytes")) builder.readBytes(new Long(from.get("read:bytes"))); if (from.containsKey("read:requests")) builder.readRequests(new Long(from.get("read:requests"))); builder.user(from.get("user")); builder.encryptionCipher(from.get("encryption:cipher")); builder.encryptionKey(from.get("encryption:key")); builder.description(from.get("description")); builder.uuid(from.get("drive")); builder.installNotes(from.get("install_notes")); builder.os(from.get("os")); if (from.containsKey("write:bytes")) builder.writeBytes(new Long(from.get("write:bytes"))); if (from.containsKey("write:requests")) builder.writeRequests(new Long(from.get("write:requests"))); if (from.containsKey("claim:type")) builder.claimType(ClaimType.fromValue(from.get("claim:type"))); if (from.containsKey("claimed")) builder.claimed(Splitter.on(' ').split(from.get("claimed"))); if (from.containsKey("drive_type")) builder.driveType(Splitter.on(',').split(from.get("drive_type"))); if (from.containsKey("autoexpanding")) builder.autoexpanding(new Boolean(from.get("autoexpanding"))); if (from.containsKey("readers")) builder.readers(Splitter.on(' ').split(from.get("readers"))); if (from.containsKey("free")) builder.free(new Boolean(from.get("free"))); if (from.containsKey("type")) builder.type(DriveType.fromValue(from.get("type"))); if (from.containsKey("size")) builder.size(new Long(from.get("size"))); Map<String, String> metadata = Maps.newLinkedHashMap(); for (Entry<String, String> entry : from.entrySet()) { if (entry.getKey().startsWith("user:")) metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); }/*from www . j av a 2 s . co m*/ builder.userMetadata(metadata); return builder.build(); }
From source file:org.glowroot.config.GaugeConfigBase.java
@Value.Derived @JsonIgnore/*from w ww .j a v a2 s. co m*/ public String display() { // e.g. java.lang:name=PS Eden Space,type=MemoryPool List<String> parts = Splitter.on(CharMatcher.anyOf(":,")).splitToList(mbeanObjectName()); StringBuilder name = new StringBuilder(); name.append(parts.get(0)); for (int i = 1; i < parts.size(); i++) { name.append('/'); name.append(parts.get(i).split("=")[1]); } return name.toString(); }
From source file:com.facebook.presto.kafka.decoder.json.JsonKafkaRowDecoder.java
private static JsonNode locateNode(JsonNode tree, KafkaColumnHandle columnHandle) { String mapping = columnHandle.getMapping(); checkState(mapping != null, "No mapping for %s", columnHandle.getName()); JsonNode currentNode = tree;// w ww . j a v a2s . c o m for (String pathElement : Splitter.on('/').omitEmptyStrings().split(mapping)) { if (!currentNode.has(pathElement)) { return MissingNode.getInstance(); } currentNode = currentNode.path(pathElement); } return currentNode; }
From source file:com.ctrip.infosec.rule.converter.UserProfileTagsConverter.java
@Override public void convert(PreActionEnums preAction, Map fieldMapping, RiskFact fact, String resultWrapper, boolean isAsync) throws Exception { PreActionParam[] fields = preAction.getFields(); String uidFieldName = (String) fieldMapping.get(fields[0].getParamName()); String uidFieldValue = valueAsString(fact.eventBody, uidFieldName); String tagsFieldValue = (String) fieldMapping.get(fields[1].getParamName()); if (StringUtils.isBlank(uidFieldValue) || StringUtils.isBlank(tagsFieldValue)) { return;/*from w w w. jav a 2 s .c om*/ } List<String> _tags = Splitter.on(",").omitEmptyStrings().trimResults().splitToList(tagsFieldValue); List<String> tags = Lists.newArrayList(_tags); // prefix default value if (Strings.isNullOrEmpty(resultWrapper)) { resultWrapper = uidFieldName + "_ProfileInfo"; } // if (fact.eventBody.containsKey(resultWrapper)) { return; } //cuscharacter? // boolean cuscharacter = false; // if (tags.contains("CUSCHARACTER")) { // tags.add("CUSCHARACTER_V2"); // tags.remove("CUSCHARACTER"); // cuscharacter = true; // } Map params = ImmutableMap.of("uid", uidFieldValue, "tagNames", tags); Map result = DataProxy.queryForMap(serviceName, operationName, params); // if (cuscharacter && (result == null || result.isEmpty())) { // if (result == null) { // result = new HashMap(); // } // if (result.isEmpty()) { // result.put("CUSCHARACTER", "NEW"); // } // } if (result != null && !result.isEmpty()) { // if (result.containsKey("CUSCHARACTER_V2")) { // Object v = result.get("CUSCHARACTER_V2"); // result.put("CUSCHARACTER", v); // result.remove("CUSCHARACTER_V2"); // } fact.eventBody.put(resultWrapper, result); } }
From source file:com.qubole.presto.kinesis.decoder.json.JsonKinesisRowDecoder.java
private static JsonNode locateNode(JsonNode tree, KinesisColumnHandle columnHandle) { String mapping = columnHandle.getMapping(); checkState(mapping != null, "No mapping for %s", columnHandle.getName()); JsonNode currentNode = tree;//from w w w .j a v a2 s .c o m for (String pathElement : Splitter.on('/').omitEmptyStrings().split(mapping)) { if (!currentNode.has(pathElement)) { return MissingNode.getInstance(); } currentNode = currentNode.path(pathElement); } return currentNode; }