Created
July 7, 2017 10:40
-
-
Save muthugit/0b16bc622bd1aba6bfc98b8d7d2e35c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AUTHOR: MU | |
* ORGANIZATION: WHIRLDATA | |
* | |
*/ | |
import org.antlr.stringtemplate.*; // IMPORTING THE PACKAGES | |
import org.antlr.stringtemplate.language.*; | |
public class StringTemplateTest { | |
public static void main(String argsp[]) { | |
// PREPARING TEMPLATE WITH THE IDENTIFICATION USING $ SYMBOL | |
StringTemplate hello = new StringTemplate("Hello, $name$. The price of the $product$ is $price$ $currency$", | |
DefaultTemplateLexer.class); | |
// ASSIGN THE VALUES | |
hello.setAttribute("name", "John"); | |
hello.setAttribute("price", 500); | |
hello.setAttribute("product", "car"); | |
hello.setAttribute("currency", "INR"); | |
// PRINT THE STRING | |
System.out.println(hello.toString()); | |
} | |
} | |
// OUTPUT | |
// Hello, John. The price of the car is 500 INR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment