[stringtemplate-interest] handling of arrays (John Snyders)
Harry Karadimas
harry.karadimas at hmn.aphp.fr
Tue Jan 30 09:13:16 PST 2007
Hi, I don't know if that relates to the previous post, but java *does*
have something
to encapsulate an array into a list, and that is the "asList" method of
the java.util.Arrays
class.
Object[] myArray = ...
List myList = Arrays.asList(myArray);
Harry Karadimas
/______________________________________________________________________
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
/
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. Re: handling of arrays (John Snyders)
> 2. Re: inconsistency with length function (Oliver Flege)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 28 Jan 2007 21:44:26 -0500
> From: "John Snyders" <jjsnyders at rcn.com>
> Subject: Re: [stringtemplate-interest] handling of arrays
> To: "Terence Parr" <parrt at cs.usfca.edu>, "StringTemplate"
> <stringtemplate-interest at antlr.org>
> Message-ID: <PMEOJKDLMMHOHNEAMPBGGEJMCAAA.jjsnyders at rcn.com>
> Content-Type: text/plain; charset="US-ASCII"
>
>
>> -----Original Message-----
>> From: stringtemplate-interest-bounces at antlr.org
>> [mailto:stringtemplate-interest-bounces at antlr.org]On Behalf Of Terence
>> Parr
>> Sent: Saturday, January 27, 2007 6:38 PM
>> To: StringTemplate
>> Subject: Re: [stringtemplate-interest] handling of arrays
>>
>> On Jan 16, 2007, at 9:40 PM, John Snyders wrote:
>>
>>
>>> I noticed in ASTExpr.java the method convertArrayToList.
>>>
>> it is. just done to make things consistent...else have to check for
>> arrays everyone. gross, eh?
>>
>>
>>> It seems to me that this is wasteful. I have not looked at it too
>>> deep but why not handle arrays like other collections and wrap them
>>> in an ArrayIterator inside convertAnythingIteratableToIterator.
>>>
>> Interesting...ArrayIterator, eh? Does Sun have a standard one? I
>> don't see it. Do you mean I should create one real quick?
>>
>
> There isn't one in the Java SDK (as far as I know) but jakarta commons has
> one
> http://jakarta.apache.org/commons/collections/api-release/org/apache/commons
> /collections/iterators/ArrayIterator.html
>
> ST probably shouldn't rely on this so you can create your own. It is
> straight forward.
> I created one before I found the one in commons collections. I can give it
> to you if you like
> (assuming I can find it). But again I didn't think this through fully.
>
>
>> Ter
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>>
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 29 Jan 2007 10:25:24 +0100
> From: Oliver Flege <o.flege at market-maker.de>
> Subject: Re: [stringtemplate-interest] inconsistency with length
> function
> To: StringTemplate <stringtemplate-interest at antlr.org>
> Message-ID: <45BDBD84.4040707 at market-maker.de>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi,
>
> Terence Parr wrote:
>
>>> I think that the length method in ASTExpr.java should be changed as
>>> follows:
>>> From:
>>>
>>> } else if (attribute instanceof List) {
>>> i = ((List)attribute).size();
>>> }
>>> To:
>>>
>>> } else if (attribute instanceof Collection) {
>>> i = ((List)attribute).size();
>>> }
>>>
>> Howdy! OK, yep, good fix.
>>
>
> even better would be
>
> } else if (attribute instanceof Collection) {
> i = ((Collection)attribute).size();
> }
>
> :)
>
> Cheers,
>
> Oliver
>
>
>
> ------------------------------
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>
> End of stringtemplate-interest Digest, Vol 22, Issue 14
> *******************************************************
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070130/a22ba43e/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: harry.karadimas.vcf
Type: text/x-vcard
Size: 407 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070130/a22ba43e/attachment.vcf
More information about the stringtemplate-interest
mailing list