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
VipulPathak
Posts: 81
Registered: ‎07-16-2008
My Device: Curve - 8320
My Carrier: AirTel

String is being Truncated unwantedly ...

[ Edited ]

Hi,

 

I am trying to use the following method to build a list of installed modules. Using the Log statement, I have confirmed that there are 44 module groups. However the constructed String only shows 12 out of those. The 13th one is Truncated and nothing after that. I have tried to use String and StringBuffer both, but the behaiour is same in both.

 

This is strange. The source is below, Can any one of you pin-point, what looks unusual into it. I tried but the not able to catch the mistake.

 

 

private String getApplicationInfo()

{

    StringBuffer sendableDeviceInfo =
new StringBuffer() ;

    // 12. Installed Applications:

    //===================================================================================

 

    CodeModuleGroup[] allModuleGroups = CodeModuleGroupManager.loadAll();

 

    if (allModuleGroups != null && allModuleGroups.length > 0)

    {

        sendableDeviceInfo.append(" Applications Installed (" + allModuleGroups.length + ") :\r\n");

        for (int nCounter = 1, nCtr2 = allModuleGroups.length - 1; nCtr2 >= 0; --nCtr2, ++nCounter)

        {

            // Log.error("For-" + nCounter, "nCtr2 => " + allModuleGroups[nCtr2].getName()) ;

            // String sAppVersion = allModuleGroups[nCtr2].getVersion();

            sendableDeviceInfo.append(" " + nCounter + ". " + allModuleGroups[nCtr2].getName());

            sendableDeviceInfo.append("\r\n");

        }

    }

    sendableDeviceInfo.append(
"\r\n");

    //===================================================================================

 

    return sendableDeviceInfo.toString() ;

}

 

 

Thanks,

 

Message Edited by VipulPathak on 09-16-2008 02:03 AM
Message Edited by VipulPathak on 09-16-2008 02:04 AM
*(Vipul)() ;
Please use plain text.
Administrator
MSohm
Posts: 14,437
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: String is being Truncated unwantedly ...

I ran this code in the BlackBerry Simulator included with the version 4.5.0 BlackBerry JDE and the final string did list all modules.  What BlackBerry model and handheld software version are you testing on?  How are you displaying the String?
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
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: String is being Truncated unwantedly ...

How did you deterine the contents of the string? Did you write that to the log at

the end or view it with a different piece of code?

 

Please use plain text.
Developer
VipulPathak
Posts: 81
Registered: ‎07-16-2008
My Device: Curve - 8320
My Carrier: AirTel

Re: String is being Truncated unwantedly ...

I am using Simulator for Blackberry8330 SmartPhone (CDMA) v4.3.0.124 (Platform)

 

I am Logging the generated string and then checking the string in Event Viewer (ALT+L+G+L+G). One thing I have noticed is that no matter if I use StringBuffer or String class, the String that is generated has the maximum length of 1560 characters (string.length()). Any thing that appears after that is truncated.

 

I tried to replace "\n" with ";", but no luck. I also tried to set the initial capacity of StringBuffer (whenever I used it instead of String) to 8192, but still no luck.

 

Is there any MaxSize concept, under some special circumstances ?

 

*(Vipul)() ;
Please use plain text.
Administrator
MSohm
Posts: 14,437
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: String is being Truncated unwantedly ...

Only short messages should be placed within the event log.  The entire log with all entries has a maximum size of 16 KB.
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
VipulPathak
Posts: 81
Registered: ‎07-16-2008
My Device: Curve - 8320
My Carrier: AirTel

Re: String is being Truncated unwantedly ...

Log came into the scene finally, when I came to know that the application list I am trying to save in a Note is getting truncated. Then for debug purpose, I tried to dump the information in the Log.

 

BTW, how would you suggest to debug in such a scenario ?

 

Regards,

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

Re: String is being Truncated unwantedly ...

I'm routinely mailing myself 200k strings concatenated from little bits of status vectors and haven't seen a problem.

Early on, I had various throws that were truncating things but otherwise no problem. I'm not using stringbuffer

since this is non-critical code and I don't care about garbage.

 

If you are worried about the logging resources just try to send yourself mail but if you really logged

the length() result that should narrow down the problem location.

 

 

Please use plain text.
Developer
VipulPathak
Posts: 81
Registered: ‎07-16-2008
My Device: Curve - 8320
My Carrier: AirTel

Re: String is being Truncated unwantedly ...

I would also like to tell that when the above loop fill the items in a Hashtable or Log the items individually, the loop executes  44 times correctly and all Items are visible. However, the problem only appears when I add the items in one string.
*(Vipul)() ;
Please use plain text.
Developer
KarlH
Posts: 29
Registered: ‎09-12-2008
My Device: Curve 8330

Re: String is being Truncated unwantedly ...

You could try attaching the debugger to the simulator, and outputing the string using System.out.println(string);  Any reason you're not returning an array of smaller strings instead of one long string?
Please use plain text.
Developer
KarlH
Posts: 29
Registered: ‎09-12-2008
My Device: Curve 8330

Re: String is being Truncated unwantedly ...

So I placed your code into a program and executed it, and the String object returned is the right length, and includes all 44 results.  Outputting it to STDOUT using System.out.println works, and it includes all the answers.  When I use the EventLogger class to log it, I see only the first few characters, only that which will fit on one line of the screen, using the eventLogViewer (altLGLG).  How are you seeing the longer string from the log?  I'm sure the problem is in using the log for such a long string, but I'm curious about what you're using to view the log.
Please use plain text.