[stringtemplate-interest] Missing convenience ctor in StringTemplateGroup(?)

Andrew Goodnough Andrew.Goodnough at wicourts.gov
Fri Sep 23 05:46:58 PDT 2005


I was surprised to see the convienient constructor using the Classloader but soon realized it was only for the non-group files.  I wrote something almost identical to Olivers method to load the group file.  But the "Reader" constuctor is very useful because you can parse any stream wrapped in a Reader and not have to invent a constructor for each.
 
Andy
 

>>> Terence Parr <parrt at cs.usfca.edu> 9/22/2005 1:05:33 PM >>>


On Aug 15, 2005, at 10:26 AM, Oliver Zeigermann wrote:

> I thought it might be convenient to have something that resolves the
> file a group is specified in in the same way as with string templates.
> While now you can use the ctor
>
> public StringTemplateGroup(Reader r)
>
> to make clear that the group is specified in a file, something like
> that might be more convenient:
>
> public StringTemplateGroup(String name, boolean groupFormat);

Hi.  This is mainly for legacy  confusion issues.  The old stuff pre- 
group format used strings for args to the groups.  I used the Reader  
stuff to make it clear.  Perhaps I should have done a new subclass  
instead. :(

Ter

>
> Right now I saw myself forced to write something like
>
>     static Reader getGroup(String name) {
>         ClassLoader cl = Thread.currentThread 
> ().getContextClassLoader();
>         InputStream is = cl.getResourceAsStream(name + ".stg");
>         if (is == null) {
>             return null;
>         }
>         BufferedReader reader = new BufferedReader(new  
> InputStreamReader(is));
>         return reader;
>     }
>
> to map the name to a reader.
>
> Why isn't this part of StringTemplate?
>
> Or did I get it all wrong?
>
> Thanks for any hints/comments and cheers
>
> Oliver
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>

--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com

_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20050923/cbe55513/attachment.html


More information about the stringtemplate-interest mailing list