You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Ashish Vijaywargiya <vi...@gmail.com> on 2008/06/07 08:58:55 UTC

Effect of a sentence in "Groovy"

Frenz ,

Suppose I have two sentence in Beanshell file :-

1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));

Key i.e partyId in the following sentence will be variable one.
2).  partyId = parameters.get("partyId") ;
context.put(partyId , UtilMisc.topMap("Key1","Value1"));

The converted sentence for the Beanshell statement shown above will be :-

1) context.partyId = [Key1 : "Value1"];

And I am confused about the second one.
Can anybody of you give some pointer on it ?

--
Ashish Vijaywargiya

Re: Effect of a sentence in "Groovy"

Posted by Scott Gray <le...@gmail.com>.
Ignore that first line, it shouldn't have been there.

- Scott

2008/6/7 Scott Gray <le...@gmail.com>:

> Do you mean like this:
> partyId = parameters.partyId;
> context.partyId = [Key1 : "Value1"];
>
> - Scott
>
> 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
>
> Frenz ,
>>
>> Suppose I have two sentence in Beanshell file :-
>>
>> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
>>
>> Key i.e partyId in the following sentence will be variable one.
>> 2).  partyId = parameters.get("partyId") ;
>> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
>>
>> The converted sentence for the Beanshell statement shown above will be :-
>>
>> 1) context.partyId = [Key1 : "Value1"];
>>
>> And I am confused about the second one.
>> Can anybody of you give some pointer on it ?
>>
>> --
>> Ashish Vijaywargiya
>>
>
>

Re: Effect of a sentence in "Groovy"

Posted by Ashish Vijaywargiya <vi...@gmail.com>.
Oh... that's perfect Scott.
Thanks man..... you are soo quick :-)

--
Ashish


On Sat, Jun 7, 2008 at 6:14 AM, Scott Gray <le...@gmail.com> wrote:

> Oh ok I see what you mean, if you do it like this:
> partyId = parameters.partyId;
> context[partyId] = [Key1:"Value1"];
>
> or like this
> testMap = [(partyId):[Key1:"Value1"]];
>
> -Scott
>
> 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
>
> > Scott and Chanwit thanks for your reply.
> > I think we have deviated from my question ..... reason may be I didn't
> ask
> > it in proper way.
> >
> > Let me explain it in some other way :-
> >
> > >>Suppose I have two sentence in Beanshell file :-
> > >>1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
> >
> > I am saying that here you are putting the "partyId" as the "key" in the
> > context map and its value will be  UtilMisc.toMap("Key1","Value1").
> > I am fine with its Groovy conversion.
> > The converted groovy sentence for above will be  :-
> >  context.partyId = [Key1 : "Value1"];
> >
> > >>Key i.e partyId in the following sentence will be variable one.
> > >>2).  partyId = parameters.get("partyId") ;
> > I only wrote the above line to tell that we can get variable value in
> > partyId.
> > >>context.put(partyId , UtilMisc.topMap("Key1","Value1"));
> >
> > In the above sentence you are putting the "value" (that will be variable)
> > of
> > partyId as the "key" and it can be either String or number and then the
> > value of it will be same i.e UtilMisc.topMap("Key1","Value1")).
> > And if we put the groovy conversion of it as same as that of first one in
> > the context then what will be the difference in both the scenario.
> >
> > Please let me know if my explaination is again not to the point.
> >
> > --
> > Ashish
> >
> >
> >
> > On Sat, Jun 7, 2008 at 4:56 AM, Chanwit Kaewkasi <ch...@gmail.com>
> > wrote:
> >
> > > Hello Scott,
> > >
> > > You're right. I've confirmed with a compiled class.
> > >
> > > Anyway, IMHO it's a good practice to use single quotes for a string.
> > >
> > > Cheers,
> > >
> > > Chanwit
> > >
> > > 2008/6/7 Scott Gray <le...@gmail.com>:
> > > > A string enclosed in double quotes only becomes a GString if it
> > contains
> > > an
> > > > ${...} expression otherwise single and double quotes are both treated
> > as
> > > > Strings.
> > > > http://groovy.codehaus.org/Strings#Strings-GStrings
> > > >
> > > > - Scott
> > > >
> > > > 2008/6/7 Chanwit Kaewkasi <ch...@gmail.com>:
> > > >
> > > >>
> > > >> ps. single quote is for String, while double quote is for Groovy's
> > > String.
> > > >>
> > > >> 2008/6/7 Scott Gray <le...@gmail.com>:
> > > >> > Do you mean like this:
> > > >> > partyId = parameters.partyId;
> > > >> > context.partyId = [Key1 : "Value1"];
> > > >> >
> > > >> > - Scott
> > > >> >
> > > >> > 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
> > > >> >
> > > >> >> Frenz ,
> > > >> >>
> > > >> >> Suppose I have two sentence in Beanshell file :-
> > > >> >>
> > > >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
> > > >> >>
> > > >> >> Key i.e partyId in the following sentence will be variable one.
> > > >> >> 2).  partyId = parameters.get("partyId") ;
> > > >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
> > > >> >>
> > > >> >> The converted sentence for the Beanshell statement shown above
> will
> > > be
> > > >> :-
> > > >> >>
> > > >> >> 1) context.partyId = [Key1 : "Value1"];
> > > >> >>
> > > >> >> And I am confused about the second one.
> > > >> >> Can anybody of you give some pointer on it ?
> > > >> >>
> > > >> >> --
> > > >> >> Ashish Vijaywargiya
> > > >> >>
> > > >> >
> > > >>
> > > >
> > >
> >
>

Re: Effect of a sentence in "Groovy"

Posted by Scott Gray <le...@gmail.com>.
Oh ok I see what you mean, if you do it like this:
partyId = parameters.partyId;
context[partyId] = [Key1:"Value1"];

or like this
testMap = [(partyId):[Key1:"Value1"]];

-Scott

2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:

> Scott and Chanwit thanks for your reply.
> I think we have deviated from my question ..... reason may be I didn't ask
> it in proper way.
>
> Let me explain it in some other way :-
>
> >>Suppose I have two sentence in Beanshell file :-
> >>1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
>
> I am saying that here you are putting the "partyId" as the "key" in the
> context map and its value will be  UtilMisc.toMap("Key1","Value1").
> I am fine with its Groovy conversion.
> The converted groovy sentence for above will be  :-
>  context.partyId = [Key1 : "Value1"];
>
> >>Key i.e partyId in the following sentence will be variable one.
> >>2).  partyId = parameters.get("partyId") ;
> I only wrote the above line to tell that we can get variable value in
> partyId.
> >>context.put(partyId , UtilMisc.topMap("Key1","Value1"));
>
> In the above sentence you are putting the "value" (that will be variable)
> of
> partyId as the "key" and it can be either String or number and then the
> value of it will be same i.e UtilMisc.topMap("Key1","Value1")).
> And if we put the groovy conversion of it as same as that of first one in
> the context then what will be the difference in both the scenario.
>
> Please let me know if my explaination is again not to the point.
>
> --
> Ashish
>
>
>
> On Sat, Jun 7, 2008 at 4:56 AM, Chanwit Kaewkasi <ch...@gmail.com>
> wrote:
>
> > Hello Scott,
> >
> > You're right. I've confirmed with a compiled class.
> >
> > Anyway, IMHO it's a good practice to use single quotes for a string.
> >
> > Cheers,
> >
> > Chanwit
> >
> > 2008/6/7 Scott Gray <le...@gmail.com>:
> > > A string enclosed in double quotes only becomes a GString if it
> contains
> > an
> > > ${...} expression otherwise single and double quotes are both treated
> as
> > > Strings.
> > > http://groovy.codehaus.org/Strings#Strings-GStrings
> > >
> > > - Scott
> > >
> > > 2008/6/7 Chanwit Kaewkasi <ch...@gmail.com>:
> > >
> > >>
> > >> ps. single quote is for String, while double quote is for Groovy's
> > String.
> > >>
> > >> 2008/6/7 Scott Gray <le...@gmail.com>:
> > >> > Do you mean like this:
> > >> > partyId = parameters.partyId;
> > >> > context.partyId = [Key1 : "Value1"];
> > >> >
> > >> > - Scott
> > >> >
> > >> > 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
> > >> >
> > >> >> Frenz ,
> > >> >>
> > >> >> Suppose I have two sentence in Beanshell file :-
> > >> >>
> > >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
> > >> >>
> > >> >> Key i.e partyId in the following sentence will be variable one.
> > >> >> 2).  partyId = parameters.get("partyId") ;
> > >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
> > >> >>
> > >> >> The converted sentence for the Beanshell statement shown above will
> > be
> > >> :-
> > >> >>
> > >> >> 1) context.partyId = [Key1 : "Value1"];
> > >> >>
> > >> >> And I am confused about the second one.
> > >> >> Can anybody of you give some pointer on it ?
> > >> >>
> > >> >> --
> > >> >> Ashish Vijaywargiya
> > >> >>
> > >> >
> > >>
> > >
> >
>

Re: Effect of a sentence in "Groovy"

Posted by Ashish Vijaywargiya <vi...@gmail.com>.
Scott and Chanwit thanks for your reply.
I think we have deviated from my question ..... reason may be I didn't ask
it in proper way.

Let me explain it in some other way :-

>>Suppose I have two sentence in Beanshell file :-
>>1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));

I am saying that here you are putting the "partyId" as the "key" in the
context map and its value will be  UtilMisc.toMap("Key1","Value1").
I am fine with its Groovy conversion.
The converted groovy sentence for above will be  :-
 context.partyId = [Key1 : "Value1"];

>>Key i.e partyId in the following sentence will be variable one.
>>2).  partyId = parameters.get("partyId") ;
I only wrote the above line to tell that we can get variable value in
partyId.
>>context.put(partyId , UtilMisc.topMap("Key1","Value1"));

In the above sentence you are putting the "value" (that will be variable) of
partyId as the "key" and it can be either String or number and then the
value of it will be same i.e UtilMisc.topMap("Key1","Value1")).
And if we put the groovy conversion of it as same as that of first one in
the context then what will be the difference in both the scenario.

Please let me know if my explaination is again not to the point.

--
Ashish



On Sat, Jun 7, 2008 at 4:56 AM, Chanwit Kaewkasi <ch...@gmail.com> wrote:

> Hello Scott,
>
> You're right. I've confirmed with a compiled class.
>
> Anyway, IMHO it's a good practice to use single quotes for a string.
>
> Cheers,
>
> Chanwit
>
> 2008/6/7 Scott Gray <le...@gmail.com>:
> > A string enclosed in double quotes only becomes a GString if it contains
> an
> > ${...} expression otherwise single and double quotes are both treated as
> > Strings.
> > http://groovy.codehaus.org/Strings#Strings-GStrings
> >
> > - Scott
> >
> > 2008/6/7 Chanwit Kaewkasi <ch...@gmail.com>:
> >
> >>
> >> ps. single quote is for String, while double quote is for Groovy's
> String.
> >>
> >> 2008/6/7 Scott Gray <le...@gmail.com>:
> >> > Do you mean like this:
> >> > partyId = parameters.partyId;
> >> > context.partyId = [Key1 : "Value1"];
> >> >
> >> > - Scott
> >> >
> >> > 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
> >> >
> >> >> Frenz ,
> >> >>
> >> >> Suppose I have two sentence in Beanshell file :-
> >> >>
> >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
> >> >>
> >> >> Key i.e partyId in the following sentence will be variable one.
> >> >> 2).  partyId = parameters.get("partyId") ;
> >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
> >> >>
> >> >> The converted sentence for the Beanshell statement shown above will
> be
> >> :-
> >> >>
> >> >> 1) context.partyId = [Key1 : "Value1"];
> >> >>
> >> >> And I am confused about the second one.
> >> >> Can anybody of you give some pointer on it ?
> >> >>
> >> >> --
> >> >> Ashish Vijaywargiya
> >> >>
> >> >
> >>
> >
>

Re: Effect of a sentence in "Groovy"

Posted by Chanwit Kaewkasi <ch...@gmail.com>.
Hello Scott,

You're right. I've confirmed with a compiled class.

Anyway, IMHO it's a good practice to use single quotes for a string.

Cheers,

Chanwit

2008/6/7 Scott Gray <le...@gmail.com>:
> A string enclosed in double quotes only becomes a GString if it contains an
> ${...} expression otherwise single and double quotes are both treated as
> Strings.
> http://groovy.codehaus.org/Strings#Strings-GStrings
>
> - Scott
>
> 2008/6/7 Chanwit Kaewkasi <ch...@gmail.com>:
>
>>
>> ps. single quote is for String, while double quote is for Groovy's String.
>>
>> 2008/6/7 Scott Gray <le...@gmail.com>:
>> > Do you mean like this:
>> > partyId = parameters.partyId;
>> > context.partyId = [Key1 : "Value1"];
>> >
>> > - Scott
>> >
>> > 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
>> >
>> >> Frenz ,
>> >>
>> >> Suppose I have two sentence in Beanshell file :-
>> >>
>> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
>> >>
>> >> Key i.e partyId in the following sentence will be variable one.
>> >> 2).  partyId = parameters.get("partyId") ;
>> >> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
>> >>
>> >> The converted sentence for the Beanshell statement shown above will be
>> :-
>> >>
>> >> 1) context.partyId = [Key1 : "Value1"];
>> >>
>> >> And I am confused about the second one.
>> >> Can anybody of you give some pointer on it ?
>> >>
>> >> --
>> >> Ashish Vijaywargiya
>> >>
>> >
>>
>

Re: Effect of a sentence in "Groovy"

Posted by Scott Gray <le...@gmail.com>.
A string enclosed in double quotes only becomes a GString if it contains an
${...} expression otherwise single and double quotes are both treated as
Strings.
http://groovy.codehaus.org/Strings#Strings-GStrings

- Scott

2008/6/7 Chanwit Kaewkasi <ch...@gmail.com>:

>
> ps. single quote is for String, while double quote is for Groovy's String.
>
> 2008/6/7 Scott Gray <le...@gmail.com>:
> > Do you mean like this:
> > partyId = parameters.partyId;
> > context.partyId = [Key1 : "Value1"];
> >
> > - Scott
> >
> > 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
> >
> >> Frenz ,
> >>
> >> Suppose I have two sentence in Beanshell file :-
> >>
> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
> >>
> >> Key i.e partyId in the following sentence will be variable one.
> >> 2).  partyId = parameters.get("partyId") ;
> >> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
> >>
> >> The converted sentence for the Beanshell statement shown above will be
> :-
> >>
> >> 1) context.partyId = [Key1 : "Value1"];
> >>
> >> And I am confused about the second one.
> >> Can anybody of you give some pointer on it ?
> >>
> >> --
> >> Ashish Vijaywargiya
> >>
> >
>

Re: Effect of a sentence in "Groovy"

Posted by Chanwit Kaewkasi <ch...@gmail.com>.
Another way to express this:

context['partyId'] = [Key1: 'Value1']

HTH,

Chanwit

ps. single quote is for String, while double quote is for Groovy's String.

2008/6/7 Scott Gray <le...@gmail.com>:
> Do you mean like this:
> partyId = parameters.partyId;
> context.partyId = [Key1 : "Value1"];
>
> - Scott
>
> 2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:
>
>> Frenz ,
>>
>> Suppose I have two sentence in Beanshell file :-
>>
>> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
>>
>> Key i.e partyId in the following sentence will be variable one.
>> 2).  partyId = parameters.get("partyId") ;
>> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
>>
>> The converted sentence for the Beanshell statement shown above will be :-
>>
>> 1) context.partyId = [Key1 : "Value1"];
>>
>> And I am confused about the second one.
>> Can anybody of you give some pointer on it ?
>>
>> --
>> Ashish Vijaywargiya
>>
>

Re: Effect of a sentence in "Groovy"

Posted by Scott Gray <le...@gmail.com>.
Do you mean like this:
partyId = parameters.partyId;
context.partyId = [Key1 : "Value1"];

- Scott

2008/6/7 Ashish Vijaywargiya <vi...@gmail.com>:

> Frenz ,
>
> Suppose I have two sentence in Beanshell file :-
>
> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1"));
>
> Key i.e partyId in the following sentence will be variable one.
> 2).  partyId = parameters.get("partyId") ;
> context.put(partyId , UtilMisc.topMap("Key1","Value1"));
>
> The converted sentence for the Beanshell statement shown above will be :-
>
> 1) context.partyId = [Key1 : "Value1"];
>
> And I am confused about the second one.
> Can anybody of you give some pointer on it ?
>
> --
> Ashish Vijaywargiya
>