StringTemplate is a java template engine (with ports for C#,Objective-C, JavaScript, Scala) for generating source code, web pages, emails, or any other formatted text output. StringTemplate is particularly good at code generators, multiple site skins, and internationalization / localization.
public String getNametype(){ return nametype; } public String getName(){ return name; } public String getNamejson(){return namejson; }
publicstaticvoidmain(String[] args)throws IOException { Args[] parms = new Args[] { new Args("BID", "string"), new Args("Species", "string"), new Args("Color", "string"), new Args("Weight", "float64"), new Args("NetWeight", "float64"), new Args("Owner", "string"), new Args("Status", "int"), };
STGroup stg = new STGroupFile("testplayer.stg"); ST s = stg.getInstanceOf("sqlTemplate"); s.add("parms", Arrays.asList(parms)); System.out.println(s.render());
Args[] parms2 = new Args[] { new Args("SlicedID", "string"), new Args("BID", "string"), new Args("Weight", "float64"), new Args("Desc", "string"), new Args("Status", "int"), }; ST s2 = stg.getInstanceOf("sqlTemplate2"); s2.add("parms2", Arrays.asList(parms2)); System.out.println(s2.render());
FileOutputStream out = new FileOutputStream(new File("template1.go")); out.write(s.render().getBytes()); out.close();
FileOutputStream out2 = new FileOutputStream(new File("template2.go")); out2.write(s2.render().getBytes()); out2.close();