[stringtemplate-interest] Inconsistent handling of multi-valued attributes?

Terence Parr parrt at cs.usfca.edu
Sun Apr 22 18:03:50 PDT 2007


On Feb 25, 2007, at 12:56 AM, Steve Ims wrote:

> Hi,
>
>    I'm using the latest ST Java APIs.  The first/last/rest  
> operators don't work as I expected them to ... wondering if it's  
> user error/misperception, or a bug?
>
>    Here's an example:
>
>         StringTemplate hello = new StringTemplate("Hello, $first 
> (name/foo)$ $first(name/bar)$");
>         Map m = new HashMap();
>         m.put("name/foo", new String[]{"World","Mary","Bob"});
>         hello.setAttributes(m);
>         hello.setAttribute("name/bar", new String[] 
> {"World","Mary","Bob"});
>         System.out.println(hello.toString());

setAttributes(...) is a very raw thing.  It does not convert the  
array you have there to a list as it does for the second attribute.  
note that you should not be using / as part of an attribute name.
Ter
>
>    My expected result:
> Hello, World World
>
>    Observed result:
> Hello, [Ljava.lang.String;@53f853f8 World
>
>
>    Suggestions?  Thanks.
>
> -- Steve
>
>
>
>
>
> ______________________________________________________________________ 
> ______________
> Food fight? Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink Q&A.
> http://answers.yahoo.com/dir/?link=list&sid=396545367
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list