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
Highlighted
Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Question on Java

I have a class containing configuration settings in the form of String variables like

 

public static final String IMEI2 = "00460101501594500";

 

This class contains about 35 different strings like that. And nothing else

 

These settings are also saved in Runtime storage. Is it possible to code a routine that saves these into Runtime storage without explicity code the names of these variables. Like some kind of "Meta" code that first finds all the names of these variabes in the class and saves the name of the variabl and its value. Similar question is if it is possible to retrieve a value for a specific configuration by its name like something like this "pseudo code"

 

variableName = "IMEI2";

variablecontent = variableName.content;

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 149
Registered: ‎03-09-2009
My Device: Not Specified

Re: Question on Java

The only way i know to do what you request is to make a singleton object class. Call the instance of the class with a personalized method get and set. In this class you also create Key constant to you in your set and get method.

 

 

Pascal Bourque, Analyste-Programmeur : "je pense donc je programme"
Really want to thank a user? Click the Kudos! badge on right side of the message. When you do so, you are offering a thumbs up for good content and a pat on the back to its author.
Accepted Solutions is a way for you to choose the reply that best answers a thread that you've started. To mark a message as a solution: Click the Solution? icon on the reply.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Question on Java

I think you are looking for reflection - there is no reflection possible in J2ME.

 

But two quick questions for you to think about.

 

1) Why do you need to put these in RuntimeStore if they are in your static class?

 

2) If you wanted to have name value pairs, why didn't you just code your static class in that way in the first place?

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: Question on Java

... or use a hash table?