Well, you should at least try to catch the possiblity of a
NumberFormatException when doing Integer.valueOf(String)
In fact, you should be using Integer.parseInt(String) instead .. like this:
protected int handleGetPoolWidth()
{
int poolWidth = 0;
Object taggedValueObject = findTaggedValue("@andromda.tran.width");
if (taggedValueObject != null)
{
poolWidth = Integer.parseInt(String.valueOf(taggedValueObject));
}
return poolWidth;
}
-- Wouter
A few rethorical questions:
Ps1: why don't you catch the exception ? you need to because
String.valueOf(null) = "null"
Ps2: why are you casting zero (0) to an integer ?
> -----Original Message-----
> From: ngocbao bui [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 18, 2005 12:14 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [Andromda-user] Tagged Value
>
> Hi,
> Sorry, I have got some typing mistake. Actually my
> code is
> protected int handleGetPoolWidth()
> {
>
> String value =
> String.valueOf(this.findTaggedValue("@andromda.tran.width"));
> Integer width = Integer.valueOf(value);
>
> if (width != null)
> return width.intValue();
>
> return (int)0;
> }
>
> The tag "@andromda.tran.width" has type Integer[0..*].
> In the template, $pool.poolWidth didn't work (pool is
> just variable in the template, poolWidth is attribute
> declared in the metafacade). It still appeared the
> same in the generated code. What is problem with my
> code?
> Regards,
> Betty
>
>
> ________________________________________________________________________
> Yahoo! Messenger - Communicate instantly..."Ping"
> your friends today! Download Messenger Now
> http://uk.messenger.yahoo.com/download/index.html
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Andromda-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/andromda-user