List of usage examples for org.apache.commons.text StringSubstitutor replace
public String replace(final StringBuffer source)
From source file:com.esri.geoportal.commons.pdf.PdfUtils.java
/** * Generates the projection Well-Known Text (WKT) for reprojecting the geospatial points * /* ww w . jav a2 s. com*/ * @see <a href="http://www.geoapi.org/2.0/javadoc/org/opengis/referencing/doc-files/WKT.html">The WKT specification</a>, specifically the "Coordinate System WKT". * @see <a href="https://www.loc.gov/preservation/digital/formats/fdd/fdd000312.shtml">The GeoPDF specification</a> for the projection dictionary properties/parameters. * * @param projectionDictionary the PDF Carousel Object Structure (COS) dictionary for the GeoPDF * @param projectionType the projection algorithm to use * * @returns the WKT for the projection */ private static String getProjectionWKT(COSDictionary projectionDictionary, String projectionType) throws IOException { Map<String, String> tokens = new HashMap<>(); tokens.put("name", projectionType); // Different projection algorithms require different parameters if ("LE".equalsIgnoreCase(projectionType)) { tokens.put("projection", "PROJECTION[\"Lambert_Conformal_Conic\"]"); // Set up the projection parameters String paramsString = generateWKTParameters(projectionDictionary); tokens.put("parameters", paramsString); tokens.put("linear_unit", "UNIT[\"Meter\",1.0]"); tokens.put("geo_cs", datumTranslation(projectionDictionary.getDictionaryObject("Datum"))); // Set the parameters tokens.put("parameters", generateWKTParameters(projectionDictionary)); StringSubstitutor subber = new StringSubstitutor(tokens); return subber.replace(PROJ_WKT_TEMPLATE); } else if ("MC".equalsIgnoreCase(projectionType)) { tokens.put("projection", "PROJECTION[\"Mercator\"]"); // Get the datum COSBase datumObj = projectionDictionary.getDictionaryObject("Datum"); tokens.put("geo_cs", datumTranslation(datumObj)); // Set the parameters tokens.put("parameters", generateWKTParameters(projectionDictionary.asUnmodifiableDictionary())); tokens.put("linear_unit", "UNIT[\"Meter\",1.0]"); StringSubstitutor subber = new StringSubstitutor(tokens); return subber.replace(PROJ_WKT_TEMPLATE); } // Returning null bypasses projection return null; }
From source file:com.formkiq.core.service.notification.ExternalMailSender.java
/** * Send Reset Email./*w ww . j av a 2 s .co m*/ * @param to {@link String} * @param email {@link String} * @param subject {@link String} * @param text {@link String} * @param html {@link String} * @throws MessagingException MessagingException */ private void sendResetEmail(final String to, final String email, final String subject, final String text, final String html) throws MessagingException { String hostname = this.systemProperties.getSystemHostname(); String resetToken = this.userservice.generateResetToken(to); StringSubstitutor s = new StringSubstitutor( ImmutableMap.of("hostname", hostname, "to", to, "email", email, "resettoken", resetToken)); MimeBodyPart textPart = new MimeBodyPart(); textPart.setText(s.replace(text), "UTF-8"); s.replace(html); MimeBodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent(s.replace(html), "text/html;charset=UTF-8"); final Multipart mp = new MimeMultipart("alternative"); mp.addBodyPart(textPart); mp.addBodyPart(htmlPart); MimeMessage msg = this.mail.createMimeMessage(); msg.setContent(mp); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject); this.mail.send(msg); }
From source file:org.jdbi.v3.commonstext.StringSubstitutorTemplateEngine.java
@Override public String render(String template, StatementContext ctx) { StringSubstitutor substitutor = new StringSubstitutor(ctx.getAttributes()); customizer.accept(substitutor);//w w w . j a v a2 s.co m return substitutor.replace(template); }