Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Operation, asInteger() and EOLInteger constructor
Operation, asInteger() and EOLInteger constructor [message #369106] Tue, 28 July 2009 15:57 Go to next message
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
Re: Operation, asInteger() and EOLInteger constructor [message #369250 is a reply to message #369106] Tue, 28 July 2009 21:41 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Edd,

Sounds like a reasonable enhancement indeed :) Could you please file an
enhancement request in the bugzilla and post the link here?

Cheers,
Dimitris

Edward Turner wrote:
> 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
>
Re: Operation, asInteger() and EOLInteger constructor [message #372650 is a reply to message #369250] Wed, 29 July 2009 10:16 Go to previous message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
K, have done, the bug enhancement is here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=284987

PS. I hope I filled in the enhancement request properly, and it doesn't
show up as a bug?!

Ta,

Edd
Re: Operation, asInteger() and EOLInteger constructor [message #571535 is a reply to message #369106] Tue, 28 July 2009 21:41 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Edd,

Sounds like a reasonable enhancement indeed :) Could you please file an
enhancement request in the bugzilla and post the link here?

Cheers,
Dimitris

Edward Turner wrote:
> 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
>
Re: Operation, asInteger() and EOLInteger constructor [message #571568 is a reply to message #369250] Wed, 29 July 2009 10:16 Go to previous message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
K, have done, the bug enhancement is here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=284987

PS. I hope I filled in the enhancement request properly, and it doesn't
show up as a bug?!

Ta,

Edd
Previous Topic:Operation, asInteger() and EOLInteger constructor
Next Topic:Loading an instanciated model via EGL loadModel
Goto Forum:
  


Current Time: Fri Apr 26 22:17:22 GMT 2024

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

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

Back to the top