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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 41
Registered: ‎11-18-2012
My Device: blackberry sms message making
My Carrier: 9951111450
Accepted Solution

how about the personalization feature in reading a csv file?

I want to know about the personalization feature and how to implement it in blackberry j2me for reading a csv file

So guys any one help me regarding this

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how about the personalization feature in reading a csv file?

what do you mean with personalization?

You can read some files using http://www.blackberry.com/developers/docs/7.1.0api/javax/microedition/pim/PIM.html#fromSerialFormat(... in the PIM API, depends on what you have.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 41
Registered: ‎11-18-2012
My Device: blackberry sms message making
My Carrier: 9951111450

Re: how about the personalization feature in reading a csv file?

I came to know that personalization is ,in which if we give   " %name% "   then the name should check from csv file and it replace with that name

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how about the personalization feature in reading a csv file?

well, you would have to implement that yourself, there is no API for that.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 41
Registered: ‎11-18-2012
My Device: blackberry sms message making
My Carrier: 9951111450

Re: how about the personalization feature in reading a csv file?

ho is that....So can you help me to implement personalisation,because am new to this BB

 

So please anyone can give suggestions and procedure for this

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how about the personalization feature in reading a csv file?

you could just use substring with the index of your %name% and replace that with a value you read from the file.
see the file demo for some starting point about reading files.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 41
Registered: ‎11-18-2012
My Device: blackberry sms message making
My Carrier: 9951111450

Re: how about the personalization feature in reading a csv file?

Sorry to say that i dint get you..can you explain it breifly

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how about the personalization feature in reading a csv file?

string manipulation is basic java.
http://www.blackberry.com/developers/docs/7.1.0api/java/lang/String.html#indexOf(java.lang.String) to find your placeholder, http://www.blackberry.com/developers/docs/7.1.0api/java/lang/String.html#substring(int,%20int) to create substrings, put them together with your result for the final string.
depending on the size of the strings a stringbuffer might be better:
http://www.blackberry.com/developers/docs/7.1.0api/java/lang/StringBuffer.html#delete(int,%20int)
http://www.blackberry.com/developers/docs/7.1.0api/java/lang/StringBuffer.html#insert(int,%20java.la...
etc
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how about the personalization feature in reading a csv file?

Her is some code that I found somewhere that will provide this sort of feature.

 

It uses % and $ to indicate where the substitutions should go, and the number in between is used as an index into the String array that you supply as the second parameter. 

 

I suspect you can adapt this to your needs.

 

As Simon noted, this is really just a standard Java problem, and you wil find solutions to these sorts of things by looking round the Internet rather than on here, where our focus is BlackBerry Java.    i think in fact I found this code somewhere on the Net. 

 

 

        private final static char LEFT_INDICATOR = '%';
        private final static char RIGHT_INDICATOR = '$';

        /**
        * Replace placeholders in template with parameters.
        *
        * @param message  the template with placeholders
        * @param params   array of parameters
        * @return         buffer containing formatted message
        */
        public static String formatMessage(String message, String[] params) {
                if (message == null || message.length() < 1 || params == null || params.length < 1 ) {
                        throw new NullPointerException("formatMessage Template or parameter array is null or empty.");
                }               
                boolean inside = false;
                boolean escaped = false;
                StringBuffer result = new StringBuffer();
                StringBuffer placeholder = null;
                char lookingFor = LEFT_INDICATOR;
                char c;

                for (int i = 0; i < message.length(); i++) {
                        c = message.charAt(i);
                        if (c == lookingFor) {
                                if (escaped) {
                                        result.append(c);
                                        escaped = false;
                                        continue;
                                }
                                if (c == LEFT_INDICATOR) {
                                        // look ahead for escaped indicator
                                        if ((i + 1) < message.length() &&
                                                message.charAt(i + 1) == LEFT_INDICATOR) {
                                                escaped = true;
                                        } else {
                                                inside = true;
                                                lookingFor = RIGHT_INDICATOR;
                                                placeholder = new StringBuffer();
                                        }
                                } else {
                                        inside = false;
                                        lookingFor = LEFT_INDICATOR;
                                        // placeholder finished get parameter
                                        int index = -1;
                                        try {
                                                index = Integer.parseInt(placeholder.toString());
                                            	result.append(params[index-1]);
                                        } catch (Throwable t) {
                                        		result.append(Characters.EM_DASH); // Something
                                        		t.printStackTrace();
                                        		LibraryRepository.logEventError("Format Error for:" + message +
                                        				", placeholder: " + placeholder.toString() + ", parm #:" + params.length);
                                        }
                                }
                        } else {
                                if (inside) {
                                        placeholder.append(c);
                                } else {
                                        result.append(c);
                                }
                        }
                }
                // for
                return result.toString();
        }

 

Highlighted
Contributor
Posts: 41
Registered: ‎11-18-2012
My Device: blackberry sms message making
My Carrier: 9951111450

Re: how about the personalization feature in reading a csv file?

yeahh....i asked it because i want to implement this personalization feature in blackberry java...thats why i posted this in this forum...i am developing a app in blackberry which will send sms and it has to have personalization feature ...

 

The code you posted is useful for me but it is not in j2me,,,yeahh but it may be useful for basic idea 

 

thanks for giving me...