RE: Converting Number Type EOCustomObjects
RE: Converting Number Type EOCustomObjects
- Subject: RE: Converting Number Type EOCustomObjects
- From: "Jonathan Fleming" <email@hidden>
- Date: Fri, 21 Feb 2003 18:02:17 +0000
OK, Thanks
I'm feeling much more relaxed now, I hate when coding catches you like that,
because you know it's simple but you just can't see it or understand it for
the frustration and anxiety you cause yourself, and to top it all you don't
want to post something like that because you're too embaressed at not
knowing something so seemingly basic.
Regardless, thanks for your help
Jonathan
Ps. I didn't realise I was deling with an abstract Class which answers some
of my frustration.
From: "Fournier, Pete" <email@hidden>
To: "Jonathan Fleming" <email@hidden>,
<email@hidden>, <email@hidden>
Subject: RE: Converting Number Type EOCustomObjects
Date: Fri, 21 Feb 2003 12:15:34 -0500
When you need to go back, you can do this.
int value = <some equation>;
Integer myInt = new Integer(value);
myEORef.setSomeValue(myInt);
Remember, Number is abstract, you should deal primarily with Integer or
whatever other descendant you require based on the type of numbers you
are dealing with.
Check out the docs to see exactly which one you need to be using. Here
is a link to the 1.3.1 J2SE docs.
http://java.sun.com/j2se/1.3/docs/api/
Pete Fournier
-----Original Message-----
From: Jonathan Fleming [mailto:email@hidden]
Sent: Friday, February 21, 2003 11:11 AM
To: Fournier, Pete; email@hidden;
email@hidden
Subject: RE: Converting Number Type EOCustomObjects
But what happens when I need to get a Number Object back into the
database
that is now an int type, how do I reconvert that? A Number type won't
accept
an int type.
I've seen methods to convert everything that is a Number or String into
int's, float's, long's, double's etc but not from any of these back to
Number types and the EO's won't accept anthing other than the type that
it
is... a Number
Jonathan
>From: "Fournier, Pete" <email@hidden>
>To: "Jonathan Fleming" <email@hidden>
>Subject: RE: Converting Number Type EOCustomObjects
>Date: Fri, 21 Feb 2003 10:52:20 -0500
>
>Not hard at all. You are dealing with a Number object. Check out the
>documentation for the JDK available at www.javasoft.com It will be
>worth your while to become familiar with Java and how its objects work.
>
>If you want the int value of your number object you can just do
>
>Number myVar = <whereever you get it from>;
>
>If(myVar != null && myVar.intValue() > 0)
>
>Or whatever you would like to check.
>
>Pete Fournier
>
>
>-----Original Message-----
>From: Jonathan Fleming [mailto:email@hidden]
>Sent: Friday, February 21, 2003 10:34 AM
>To: email@hidden; email@hidden
>Subject: Converting Number Type EOCustomObjects
>
>
>I'm having a real nightmere just trying to convert two Number object
>types in my EOCustom code so that I can do a simple addition on their
>values.
>
>I've given up trying to tidy the code up so you have to forgive the
>mess you witness here, this is as far as I have got with it:
>I don't understand why I am not allowed to use operator to read if a
>value
>is > 0 or == 0 and so forth? Nor can I use (+) symbol says the
>projectBuilder compiler to add the two values together even if the code
>was
>right, and converting the EO's is just winding me up... 8 hours I've
>been at
>this nonesense (UK time), it should have been real easy.
>Can someone please help before I go out of my tiny mind...
>All I want to do is add one EOCustomObject that is a Number type to
>another
>EOCustomObject that is a Number type, how hard can that be?
>
>public WOComponent dbSaveChanges(){
> try {
>
> // get editing context
> EOEditingContext ec = session().defaultEditingContext();
>
> // this checks if a number was entered into the
>countOfImagesToUpload variable
> if (getSCountOfImagesToUpload().equals("0"))
> {
> Number sum;
> Number nCountOfImagesUploaded = (Number)
>tbClient.valueForKey("countOfImagesUploaded");
> Number nCountOfUploadMatch = (Number)
>tbClient.valueForKey("countOfUploadMatch");
> // Something was uploaded, update the EO
> tbClient.setCountOfImagesUploaded(
>getSCountOfImagesToUpload().intValue() );
> if (nCountOfUploadMatch > 0) {
> sum = nCountOfImagesUploaded +
nCountOfUploadMatch;
> tbClient.setCountOfUploadMatch(sum);
> } else {
>
>tbClient.setCountOfUploadMatch(getSCountOfImagesToUpload());
> }
> }
>
>_________________________________________________________________
>Stay in touch with absent friends - get MSN Messenger
>http://messenger.msn.co.uk
>_______________________________________________
>webobjects-dev mailing list | email@hidden
>Help/Unsubscribe/Archives:
>http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>Do not post admin requests to the list. They will be ignored.
_________________________________________________________________
Chat online in real time with MSN Messenger http://messenger.msn.co.uk
_________________________________________________________________
Stay in touch with MSN Messenger http://messenger.msn.co.uk
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.