Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Operation, asInteger() and EOLInteger constructor
Operation, asInteger() and EOLInteger constructor [message #571501] Tue, 28 July 2009 15:57
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
Hi there,

Just a quick note really.

The other day I was applying asInteger() to certain Strings (which would
usually be number characters). In the Epsilon book, I saw that an error
would be raised if the Strings weren't of an acceptable form (pg. 33). But
I found this not to be the case.

Looking in the EOLInteger constructor (which I believe asInteger() uses),
I see that if the String isn't of a valid form, the EOLInteger object is
set to 0. And in practice, this was the behaviour I was experiencing,
i.e., I didn't get an error even when the String wasn't a number, e.g.,
'Tilly the cat'.

Given this behaviour, I use the following rather pointless looking
operation to determine if a String can be parsed as an integer:

operation String isInteger() : Boolean {
if(self = '0') {
return true;
}
else if(not(self.asInteger()=0)) {
return true;
}
else {
return false;
}
}

Would it make sense to add an operation to EOLString, which could check if
it could indeed be parsed as an integer? I guess I only suggest this
because if an error was raised after trying to parse an unacceptable
String as an integer, I wouldn't know how to handle the error in Epsilon,
e.g., if the error was an exception thrown by the underpinning Java.
Moreover, it would allow you to check for such cases at runtime without
your application stopping.

Anyway,

Best,

Edd
Previous Topic:[EuGENia] Node label from attribute of contained class
Next Topic:Operation, asInteger() and EOLInteger constructor
Goto Forum:
  


Current Time: Mon Dec 22 04:29:25 GMT 2014

Powered by FUDForum. Page generated in 0.01785 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software