Purpose of type=PlainString

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Purpose of type=PlainString

Vikas Mayur-3
Hi,

While doing a commit in rev. 763582 for OFBIZ-2281, I come across a type=PlainString which I think is the only occurrence in all of the xml files. While fixing this issue, I have to remove the <set> tag that has this type. 

-        <set field="newEntity.returnItemSeqId" from-field="newestItem.returnItemSeqId" type="PlainString"/>

Certainly this has nothing to do with my fix but I was still interested in knowing what is this type is all about. I hope I have not done any thing silly with my fix by removing the above line because after my fix that line wasn't used anymore.

Please shed any light on this topic.

Thanks,
Vikas

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Purpose of type=PlainString

Scott Gray-2
Hi Vikas

PlainString just sets the field value to fromField.toString()

Regards
Scott

On 9/04/2009, at 10:08 PM, Vikas Mayur wrote:

Hi,

While doing a commit in rev. 763582 for OFBIZ-2281, I come across a type=PlainString which I think is the only occurrence in all of the xml files. While fixing this issue, I have to remove the <set> tag that has this type. 

-        <set field="newEntity.returnItemSeqId" from-field="newestItem.returnItemSeqId" type="PlainString"/>

Certainly this has nothing to do with my fix but I was still interested in knowing what is this type is all about. I hope I have not done any thing silly with my fix by removing the above line because after my fix that line wasn't used anymore.

Please shed any light on this topic.

Thanks,
Vikas


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Purpose of type=PlainString

Divesh Dutta
Thanks Scott for your explanation. But I am  confused that ,<set
field="newEntity.returnItemSeqId"
from-field="newestItem.returnItemSeqId" type="String"/>  also serves the
same purpose. Is there any other reason for using PlainString . Is it
like using String or PlainString will serve the same purpose?

Thanks
Divesh


Scott Gray wrote:

> Hi Vikas
>
> PlainString just sets the field value to fromField.toString()
>
> Regards
> Scott
>
> On 9/04/2009, at 10:08 PM, Vikas Mayur wrote:
>
>> Hi,
>>
>> While doing a commit in rev. 763582 for OFBIZ-2281
>> <https://issues.apache.org/jira/browse/OFBIZ-2281>, I come across a
>> type=PlainString which I think is the only occurrence in all of the
>> xml files. While fixing this issue, I have to remove the <set> tag
>> that has this type.
>>
>>> -        <set field="newEntity.returnItemSeqId"
>>> from-field="newestItem.returnItemSeqId" type="PlainString"/>
>>
>> Certainly this has nothing to do with my fix but I was
>> still interested in knowing what is this type is all about. I hope I
>> have not done any thing silly with my fix by removing the above line
>> because after my fix that line wasn't used anymore.
>>
>> Please shed any light on this topic.
>>
>> Thanks,
>> Vikas
>

Reply | Threaded
Open this post in threaded view
|

Re: Purpose of type=PlainString

Scott Gray-2
Hi Divesh

The difference between the two becomes evident when you are dealing with numbers and dates, as mentioned below PlainString simply returns object.toString() but String does more than that and attempts to format the string that it returns where applicable.  Here are some examples of what String does (straight out of ObjectType.simpleTypeConvert where all this is done):

For Double, Float, Long, Integer and BigDecimal:
NumberFormat nf = NumberFormat.getNumberInstance(locale);
return nf.format(dbl.doubleValue());

For Date
DateFormat df = null;
if (format == null || format.length() == 0) {
    df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, locale);
} else {
    df = UtilDateTime.toDateFormat(format, timeZone, locale);
}
return df.format(new java.util.Date(dte.getTime()));


For Time and Timestamp
DateFormat df = null;
if (format == null || format.length() == 0) {
    df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, locale);
} else {
    df = UtilDateTime.toTimeFormat(format, timeZone, locale);
}
return df.format(new java.util.Date(tme.getTime()));

TimeZone returns getID()

Buffer throws an exception

Boolean, Locale, GenericValue, Map, List and anything else not mentioned above return toString()

Regards
Scott

HotWax Media

On 9/04/2009, at 11:48 PM, Divesh Dutta wrote:

Thanks Scott for your explanation. But I am  confused that ,<set field="newEntity.returnItemSeqId" from-field="newestItem.returnItemSeqId" type="String"/>  also serves the same purpose. Is there any other reason for using PlainString . Is it like using String or PlainString will serve the same purpose?

Thanks
Divesh


Scott Gray wrote:
Hi Vikas

PlainString just sets the field value to fromField.toString()

Regards
Scott

On 9/04/2009, at 10:08 PM, Vikas Mayur wrote:

Hi,

While doing a commit in rev. 763582 for OFBIZ-2281 <https://issues.apache.org/jira/browse/OFBIZ-2281>, I come across a type=PlainString which I think is the only occurrence in all of the xml files. While fixing this issue, I have to remove the <set> tag that has this type.
-        <set field="newEntity.returnItemSeqId" from-field="newestItem.returnItemSeqId" type="PlainString"/>

Certainly this has nothing to do with my fix but I was still interested in knowing what is this type is all about. I hope I have not done any thing silly with my fix by removing the above line because after my fix that line wasn't used anymore.

Please shed any light on this topic.

Thanks,
Vikas




smime.p7s (3K) Download Attachment