Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified
Accepted Solution

Design Problem - Cannot make class persistable

[ Edited ]

Basically, I have a HighScore class which implements Persistable that I either want to extend SimpleSortingVector, or contain private SimpleSortingVector.

 

However, as SimpleSortingVector is NOT persistable, I cannot make HighScore Persistable.

 

I'm guessing that this means I also cannot simple extend SimpleSortingVector and make the sub-class persistable, so how on earth can I persist my class????

 

I get a similar problem with this:

 

 

public class MultiColumnTextField extends Field implements Persistable { <snip> }

 

 because Field is NOT persistable!

 

 

[rapc] net.berrysoft.dib.fields.MultiColumnTextField: Error!: Class net.berrysoft.dib.fields.MultiColumnTextField marked Persistable by interface: net.rim.device.api.util.Persistable is not Persistable: base Class net.rim.device.api.ui.Field does not implement net.rim.vm.Persistable

 

Patrick

 

Message Edited by Berrysoft on 12-20-2008 10:44 PM
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

Vector is persistable.

 

Enumerate the data out of the sorting vector, and persist the vector. You can repopulate the sorting vector when you restore the data.

 

Please use plain text.
Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

Gotcha.  Makes sense (in a roundabout sort of way).  Vector is probably smaller to store.  Just is going to complicate the design a bit.  =)

 

Thanks for the help.

 

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

Alternatively, you could use an array and use the methods in the Arrays class to sort and search.

There doesn't seem to be an "insert into ordered array" function but resorting the whole small list

may not be a big problem.

 

I'm not really sure an array offers much over a vector or how much of the sorted vector

is implemented in native code but generally I've been trying to move things into arrays,

certainly when size is either known ahead of time or can otherwise be handled gracefully.

Any opposing view points here?

 

Please use plain text.
Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

Yes, thanks for posting this.... after sitting with it all night I realized this too.  I knew something was wrong with my code because the Comparator interface wasn't giving me the compareTo( Object obj ) I was expecting.  After more thought, I realized my original plan was the correct one (using an array) which morphed into an arrayList, etc.  You are correct too that I'm only tracking 5 high scores, so I can sort it each time with no performance problem at all.

 

I believe you are also correct in preferring the array over the Vector in this case as it is cheaper in time and space, and this is the recommendation in the memory best practices document.

 

Patrick

 

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

Yeah, coding does let you fall into traps. I guess I've found I tend to get off on "good ideas" that spiral

into complicated patch after patch or start out with "easy to code" approaches and then never go back

to fix them. Normally I try to use the most portable code possible but I have to admit get

having done a lot of RIM specific stuff. With java, you probably need to make any use you can of

native implementations, but see my comments on java codecs LOL.

 

 

Please use plain text.
Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

Yes, I agree.  While I certainly want to utilize the RIM API to reduce code size and reinventing the wheel, it can be a bit frustrating at times re-learning how to do things "the RIM way" so to speak.  Originally, I was considering encapsulating the RIM stuff so I could more easily port something, but then decided it really wasn't worth the trouble and code size increase to do it.

 

One thing that continues to frustrate me is that I can't turn on -source 1.5, to get Enumerations because then I start getting errors within the RIM classes that prevent compilation even though accoring to the manual you are supposed to be able to use 1.5 with 4.2.1.  Very annoying.

 

Please use plain text.
Administrator
MSohm
Posts: 14,554
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Design Problem - Cannot make class persistable

All BlackBerry development conforms Java source version 1.3.  Can you let me know what document do you see that version 1.5 is supported so I can have this corrected?  Thanks!
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: Design Problem - Cannot make class persistable

This one:

 

http://tinyurl.com/DB00568

 

Patrick

 

Please use plain text.
Administrator
MSohm
Posts: 14,554
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Design Problem - Cannot make class persistable

That document pertains to the version of JDK required by the BlackBerry JDE, not the code formatting versions supported.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.