You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2018/01/25 16:30:51 UTC
Create an empty java.util.Set in VTL
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
If I want to create a new empty array/collection, I can do something
like this:
#set($array = [])
If I want to create a new Map, I can do this:
#set($map = {})
Is there a way to create a new Set?
I'd like to use a set because:
1. I want to use this object as a sort of scratch-area to know what
work I've done before
and
2. I'm going to be consulting it a lot using Set.contains(object) so
something other than ArrayList/LinkedList will be much faster
Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpqBjsdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFisIQ//VqqfK6GzyxnQZ9qK
QvQREhkJoafg5X7n4d1M7pfG99qGTlGhrLXwO8YD0Qhpj0v7QKbJbi3LsjmwIVQT
4wvMXO7cBLXbB3bdc640ITylettTqKODTPk/KBIKq4nvSUVMGKvn/q/NlrZFX776
11SBC2VLcU7ujzaglL+F/xlF0C1ZS1UAFQlBVcRxT48C44dGOGSYVOu9UmYPvxpk
4ExrjKwkuTb6zsXn/Nwn1d/K7jB+Cqx77KDNOj0eBQK5POHZa/cC/W0z9uVdlUJg
oVOwxITiEyTd2XmEFa1OjnU4yrZkU+N+wPzsFxgNwKzWSTC4CsBjIw2oSh4cOEqy
gU7HRlCQMRhhBAYD6M7a8wvI60/UI/klb7aB1wOwt74A2/jtwx3M2mBKoYFYTx3X
sfXS1lRtiXLtmooe50wHBvHBhvWXHkLE0dRETtgsLH/QiFgpG3xjoLPHkm6nL/60
4KJ5kt/a8afm1dBgcSc4Y6eXrAr0XQl9vREPfGWbcQs3h+azJ2L1leoEg2jnA3gh
oytTF7HmuoX4cYqF1SLeLlMlRJdaAzayZYRwWeB739t7W7iRBzackNzTZyWfNqVD
FRTv3vmsl477J9KI05rH7qlmowFL0QmwP6WeRPtOpQq8gDFKhRcGcoPXRtT6aXke
VGfV9fj4L7nJBBUkOWtSfQU7WuY=
=61WB
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Create an empty java.util.Set in VTL
Posted by Sergiu Dumitriu <sd...@apache.org>.
Not with the default syntax and context. If you can control the context,
you can put an utility that can create any type of collection: random
sets, linked sets, ordered sets, linked maps, ordered maps...
On 01/25/2018 11:30 AM, Christopher Schultz wrote:
> All,
>
> If I want to create a new empty array/collection, I can do something
> like this:
>
> #set($array = [])
>
> If I want to create a new Map, I can do this:
>
> #set($map = {})
>
> Is there a way to create a new Set?
>
> I'd like to use a set because:
>
> 1. I want to use this object as a sort of scratch-area to know what
> work I've done before
>
> and
>
> 2. I'm going to be consulting it a lot using Set.contains(object) so
> something other than ArrayList/LinkedList will be much faster
>
> Thanks,
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
--
Sergiu Dumitriu
http://purl.org/net/sergiu
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Create an empty java.util.Set in VTL
Posted by sebb <se...@gmail.com>.
Or use the Map, and use a fixed value (or ignore it)
On 25 January 2018 at 16:44, Alex Fedotov <al...@kayak.com> wrote:
> You can probably use a hack with classloader. Along the lines of:
>
> #set($x =
> "1".getClass().getClassloader().findClass("java.uti.HashSet").newInstance())
>
> Alex
>
>
> On Thu, Jan 25, 2018 at 11:30 AM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> All,
>>
>> If I want to create a new empty array/collection, I can do something
>> like this:
>>
>> #set($array = [])
>>
>> If I want to create a new Map, I can do this:
>>
>> #set($map = {})
>>
>> Is there a way to create a new Set?
>>
>> I'd like to use a set because:
>>
>> 1. I want to use this object as a sort of scratch-area to know what
>> work I've done before
>>
>> and
>>
>> 2. I'm going to be consulting it a lot using Set.contains(object) so
>> something other than ArrayList/LinkedList will be much faster
>>
>> Thanks,
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Comment: GPGTools - http://gpgtools.org
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpqBjsdHGNocmlzQGNo
>> cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFisIQ//VqqfK6GzyxnQZ9qK
>> QvQREhkJoafg5X7n4d1M7pfG99qGTlGhrLXwO8YD0Qhpj0v7QKbJbi3LsjmwIVQT
>> 4wvMXO7cBLXbB3bdc640ITylettTqKODTPk/KBIKq4nvSUVMGKvn/q/NlrZFX776
>> 11SBC2VLcU7ujzaglL+F/xlF0C1ZS1UAFQlBVcRxT48C44dGOGSYVOu9UmYPvxpk
>> 4ExrjKwkuTb6zsXn/Nwn1d/K7jB+Cqx77KDNOj0eBQK5POHZa/cC/W0z9uVdlUJg
>> oVOwxITiEyTd2XmEFa1OjnU4yrZkU+N+wPzsFxgNwKzWSTC4CsBjIw2oSh4cOEqy
>> gU7HRlCQMRhhBAYD6M7a8wvI60/UI/klb7aB1wOwt74A2/jtwx3M2mBKoYFYTx3X
>> sfXS1lRtiXLtmooe50wHBvHBhvWXHkLE0dRETtgsLH/QiFgpG3xjoLPHkm6nL/60
>> 4KJ5kt/a8afm1dBgcSc4Y6eXrAr0XQl9vREPfGWbcQs3h+azJ2L1leoEg2jnA3gh
>> oytTF7HmuoX4cYqF1SLeLlMlRJdaAzayZYRwWeB739t7W7iRBzackNzTZyWfNqVD
>> FRTv3vmsl477J9KI05rH7qlmowFL0QmwP6WeRPtOpQq8gDFKhRcGcoPXRtT6aXke
>> VGfV9fj4L7nJBBUkOWtSfQU7WuY=
>> =61WB
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Create an empty java.util.Set in VTL
Posted by Sergiu Dumitriu <sd...@apache.org>.
Not if you're using the secure uberspector, which everyone should be doing.
On 01/25/2018 11:44 AM, Alex Fedotov wrote:
> You can probably use a hack with classloader. Along the lines of:
>
> #set($x =
> "1".getClass().getClassloader().findClass("java.uti.HashSet").newInstance())
>
> Alex
>
>
> On Thu, Jan 25, 2018 at 11:30 AM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
> All,
>
> If I want to create a new empty array/collection, I can do something
> like this:
>
> #set($array = [])
>
> If I want to create a new Map, I can do this:
>
> #set($map = {})
>
> Is there a way to create a new Set?
>
> I'd like to use a set because:
>
> 1. I want to use this object as a sort of scratch-area to know what
> work I've done before
>
> and
>
> 2. I'm going to be consulting it a lot using Set.contains(object) so
> something other than ArrayList/LinkedList will be much faster
>
> Thanks,
> -chris
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
--
Sergiu Dumitriu
http://purl.org/net/sergiu
--
Sergiu Dumitriu
http://purl.org/net/sergiu
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Create an empty java.util.Set in VTL
Posted by Alex Fedotov <al...@kayak.com>.
You can probably use a hack with classloader. Along the lines of:
#set($x =
"1".getClass().getClassloader().findClass("java.uti.HashSet").newInstance())
Alex
On Thu, Jan 25, 2018 at 11:30 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> All,
>
> If I want to create a new empty array/collection, I can do something
> like this:
>
> #set($array = [])
>
> If I want to create a new Map, I can do this:
>
> #set($map = {})
>
> Is there a way to create a new Set?
>
> I'd like to use a set because:
>
> 1. I want to use this object as a sort of scratch-area to know what
> work I've done before
>
> and
>
> 2. I'm going to be consulting it a lot using Set.contains(object) so
> something other than ArrayList/LinkedList will be much faster
>
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpqBjsdHGNocmlzQGNo
> cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFisIQ//VqqfK6GzyxnQZ9qK
> QvQREhkJoafg5X7n4d1M7pfG99qGTlGhrLXwO8YD0Qhpj0v7QKbJbi3LsjmwIVQT
> 4wvMXO7cBLXbB3bdc640ITylettTqKODTPk/KBIKq4nvSUVMGKvn/q/NlrZFX776
> 11SBC2VLcU7ujzaglL+F/xlF0C1ZS1UAFQlBVcRxT48C44dGOGSYVOu9UmYPvxpk
> 4ExrjKwkuTb6zsXn/Nwn1d/K7jB+Cqx77KDNOj0eBQK5POHZa/cC/W0z9uVdlUJg
> oVOwxITiEyTd2XmEFa1OjnU4yrZkU+N+wPzsFxgNwKzWSTC4CsBjIw2oSh4cOEqy
> gU7HRlCQMRhhBAYD6M7a8wvI60/UI/klb7aB1wOwt74A2/jtwx3M2mBKoYFYTx3X
> sfXS1lRtiXLtmooe50wHBvHBhvWXHkLE0dRETtgsLH/QiFgpG3xjoLPHkm6nL/60
> 4KJ5kt/a8afm1dBgcSc4Y6eXrAr0XQl9vREPfGWbcQs3h+azJ2L1leoEg2jnA3gh
> oytTF7HmuoX4cYqF1SLeLlMlRJdaAzayZYRwWeB739t7W7iRBzackNzTZyWfNqVD
> FRTv3vmsl477J9KI05rH7qlmowFL0QmwP6WeRPtOpQq8gDFKhRcGcoPXRtT6aXke
> VGfV9fj4L7nJBBUkOWtSfQU7WuY=
> =61WB
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>