public static LatLng getLatLng(String address, String city, String state, String zip) throws IOException { String url = "https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address="; url += encodeUrl(String.format("%s, %s, %s %s", address, city, state, zip)); URLConnection connection = new URL(url).openConnection(); String data = IoUtils.toString(connection.getInputStream()); data = getTagContents(data, "location", 0); return new LatLng( getTagContents(data, "lat", 0), getTagContents(data, "lng", 0) ); } }
private SmtpEmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }
protected EmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }
private SesEmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }
String data = wrapper.toString(); String htmlHead = StringUtils.getTagContents(data, "head", 0); String htmlTitle = StringUtils.getTagContents(htmlHead, "title", 0); request.setAttribute(PageAttribute.title, htmlTitle); String htmlBody = StringUtils.getTagContents(data, "body", 0); if (htmlBody != null) data = htmlBody;