[stringtemplate-interest] Re: stringtemplate-interest Digest, Vol 17, Issue 7

Harry Karadimas harry.karadimas at hmn.aphp.fr
Mon Aug 21 08:55:21 PDT 2006


I'm not sure but I think your "HashMap" may be confusing st as it is

HashMap<String,Object>

and not

HashMap<Object,Object>

so it is not an exact instance of "HashMap", which is what st expects. 
However I'm no generics expert.


HK


stringtemplate-interest-request at antlr.org a écrit :
> Send stringtemplate-interest mailing list submissions to
> 	stringtemplate-interest at antlr.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
> or, via email, send a message with subject or body 'help' to
> 	stringtemplate-interest-request at antlr.org
>
> You can reach the person managing the list at
> 	stringtemplate-interest-owner at antlr.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of stringtemplate-interest digest..."
>
>
> Today's Topics:
>
>    1. strange iteration problems when using	HashMaps (Uwe Simm)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 19 Aug 2006 14:18:32 +0200
> From: "Uwe Simm" <uwes at cadence.com>
> Subject: [stringtemplate-interest] strange iteration problems when
> 	using	HashMaps
> To: <stringtemplate-interest at antlr.org>
> Message-ID:
> 	<299857781E0791409D97D9762F4E2FF001B25F0C at MAILEU.global.cadence.com>
> Content-Type: text/plain;	charset="us-ascii"
>
> hi experts,
>
> i'm using StringTemplate for a small application and i was surprised to
> see the following behaviour:
>
>
> i did expect that i do iterate in testme() over the elements of a and
> applying the template op() to every element.
> this works fine if a has got more than one element (the attribute has
> been assigned more than once). however if the attribute is only assigned
> once it looks like the iterator iterates over the contents of the
> aggregate (the contents of the HashMap) which was not the primary
> indent.
>
> the question now is: how can iterate over the elements of the attribute
> a apply the op() function independent of the number of elements in a?
>
> regards
> /uwe
>
> ---------------templates-------------------------
> op(t) ::= "this is [<t.a>]"
>
> testme(a) ::= <<
> 	testme
> 	<a:{<op(it)>};separator="\n">
> 	testme
>   
> -------------------------------------------------
> package convert;
>
> import java.io.FileReader;
> import java.util.HashMap;
>
> import org.antlr.stringtemplate.StringTemplate;
> import org.antlr.stringtemplate.StringTemplateGroup;
>
> public class STtest {
>
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) throws Exception {
>         StringTemplateGroup group = new StringTemplateGroup(new
> FileReader("templates"));
> 		StringTemplate pack = group.getInstanceOf("testme");
>
>         HashMap<String,Object> h = new HashMap<String,Object>();
>
>         h.put("a","attr_a");
>         pack.setAttribute("a", h);
>         pack.setAttribute("a", h); // comment this line!
>
>         System.err.println(pack);
> 	}
> }
> -------------------------------------------------
>
>
> ------------------------------
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>
> End of stringtemplate-interest Digest, Vol 17, Issue 7
> ******************************************************
>
>   


-- 
/

______________________________________________________________________
Dr Harry Karadimas  Medecin Ingenieur resp. Recherche et Developpement            
Departement d'Information Hospitalier
CHU Henri Mondor 51, av. du Mal de Lattre de Tassigny   94010  CRETEIL
tel : (00 33 1) 49 81 21 79                fax : (00 33 1) 49 81 27 08
secr.: (00 33 1) 49 81 23 82 m.el.:harry.karadimas at hmn.ap-hop-paris.fr

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


More information about the stringtemplate-interest mailing list