RE: addition of lists

2013-05-24 Thread Ricardo.Julio.Rodriguez.Fernandez
Hey Sergiu! A big pleasure to meet you here! Thanks for your answer. Please, 
see below...

 
 From: Sergiu Dumitriu [sergiu.dumit...@gmail.com]
 Sent: 24 May 2013 19:54
 To: user@velocity.apache.org
 Subject: Re: addition of lists

 On 05/24/2013 01:50 PM, ricardo.julio.rodriguez.fernan...@sergas.es wrote:
 Hi!

 Probably I'll use the wrong semantic, but I'll try to explain the very 
 simple result I want
 to get with Velocity: given two lists of results, let's me call them $list1 
 and $list2,
 I want to get a new list, let's call it $listTotal, including all item in 
 $list1 and $list2.

 Please, how could I do that? What is the correct expression I must it in 
 Velocity's World for his operation?

 Thank you so much for your help!

 Ricardo


 Hey Ricardo,

 If those are indeed lists, they should support all the methods that
 Java's List class provides [1], including addAll [2], so this should work:

 #set ($listTotal = [])
 #set ($discard = $listTotal.addAll($list1))
 #set ($discard = $listTotal.addAll($list2))


It worked! They are indeed lists :-) But I've not a clear idea yet about what 
is list, what an array, what a collection, what any sort of collection... 
Please, could you provide me a good reference to keep trying to understand what 
I feel like a must to leverage the power of Velocity and, of course, the nice 
team XWiki/Velocity?

These two lists come from a for you well known lines of code. Something like 
this...

#set ($xwqlquery = where doc.translation = 0 and doc.creationDate  
'2013-01-01' and doc.parent like '%$doc.title%' and doc.fullName NOT IN 
($nicestr0) order by doc.object(XWiki.XWikiUsers).last_name)
#set ($results = $services.query.xwql($xwqlquery).execute())

Please, is it possible to check $results if is it a list? For instance, I 
guessed it is a list because I can apply size() to it. Is this a right guess?

Thank you so much for your help!


 [1] http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html
 [2] 
 http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html#addAll%28java.util.Collection%29

Thanks!

 --
 Sergiu Dumitriu
 http://purl.org/net/sergiu

Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso_confidencialidad.htm


Re: addition of lists

2013-05-24 Thread Sergiu Dumitriu
On 05/24/2013 02:37 PM, ricardo.julio.rodriguez.fernan...@sergas.es wrote:
 Hey Sergiu! A big pleasure to meet you here! Thanks for your answer. Please, 
 see below...
 
 
 From: Sergiu Dumitriu [sergiu.dumit...@gmail.com]
 Sent: 24 May 2013 19:54
 To: user@velocity.apache.org
 Subject: Re: addition of lists

 On 05/24/2013 01:50 PM, ricardo.julio.rodriguez.fernan...@sergas.es wrote:
 Hi!

 Probably I'll use the wrong semantic, but I'll try to explain the very 
 simple result I want
 to get with Velocity: given two lists of results, let's me call them $list1 
 and $list2,
 I want to get a new list, let's call it $listTotal, including all item in 
 $list1 and $list2.

 Please, how could I do that? What is the correct expression I must it in 
 Velocity's World for his operation?

 Thank you so much for your help!

 Ricardo


 Hey Ricardo,

 If those are indeed lists, they should support all the methods that
 Java's List class provides [1], including addAll [2], so this should work:

 #set ($listTotal = [])
 #set ($discard = $listTotal.addAll($list1))
 #set ($discard = $listTotal.addAll($list2))

 
 It worked! They are indeed lists :-) But I've not a clear idea yet about what 
 is list, what an array, what a collection, what any sort of collection... 
 Please, could you provide me a good reference to keep trying to understand 
 what I feel like a must to leverage the power of Velocity and, of course, the 
 nice team XWiki/Velocity?
 
 These two lists come from a for you well known lines of code. Something like 
 this...
 
 #set ($xwqlquery = where doc.translation = 0 and doc.creationDate  
 '2013-01-01' and doc.parent like '%$doc.title%' and doc.fullName NOT IN 
 ($nicestr0) order by doc.object(XWiki.XWikiUsers).last_name)
 #set ($results = $services.query.xwql($xwqlquery).execute())
 
 Please, is it possible to check $results if is it a list? For instance, I 
 guessed it is a list because I can apply size() to it. Is this a right guess?

You can always check the actual class of a variable with:

$var.class

This will print the classname, which will correspond to a real Java
class (most likely an ArrayList).

You can then look up that class in your favorite Java IDE and look at
its hierarchy: which interfaces does it implement (List, Set or Map),
what methods does it have, etc.

One exception is that arrays (like String[]) are treated as lists by
Velocity, so they will also support all the List methods, even though in
Java they don't.

 Thank you so much for your help!
 

 [1] http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html
 [2] 
 http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html#addAll%28java.util.Collection%29
 
 Thanks!


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu

-
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org