Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
jiza68
Posts: 4
Registered: 02-08-2010
My Carrier: t-mobile

convertEncodingToByteArray function

Does somebody experience with this function ( class PersistentContent , function public static byte[] convertEncodingToByteArray(Object encoding)  )  ,  I have some object stored at database and  , I get this object from database and used this object as parametr convertEncodingToByteArray function ..

 

part of code :

 

private static  final class Record implements Persistable

{

....

}

 

 

                      Record recGroup = new Record();

                     _dataGroup = (Vector)DatabaseGroup.getContents();

                    recGroup =  (Record) _dataGroupelementAt(index);
                                     
                    byte[] pole = PersistentContent.convertEncodingToByteArray(recGroup);

 

when I tried this function I got error message "

Exception thrown:@5D32A000java.lang.IllegalArgumentException

 "

 

Can you tell me, where is problem ..  ( Maybe I bad understend using this function .. )

 

regards

 

jiri bruza

 

 

Please use plain text.
Developer
rihan007
Posts: 408
Registered: 01-14-2009

Re: convertEncodingToByteArray function

 

 

According to Blackberry APIs

 

public static byte[] convertEncodingToByteArray(Object encoding)

Converts a PersistentContent encoding of an object into a byte array.

 

 

the function will not accept an of Record type

 

 

Please use plain text.
New Developer
jiza68
Posts: 4
Registered: 02-08-2010
My Carrier: t-mobile

Re: convertEncodingToByteArray function

allright

 

I try create mybject based on the  object class ..

 

regards

 

jiri bruza

Please use plain text.
New Developer
jiza68
Posts: 4
Registered: 02-08-2010
My Carrier: t-mobile

Re: convertEncodingToByteArray function

I tried it again with parametr based on th Object class , but I have got same result ..   ( error message - invalid argument )

 

part of example code :

 

defination my object  :

 

 

 private static  final class MyObj extends Object implements Persistable
     {
         int number ;
         String text = "ahoj" ;
        
         public MyObj()
         {
             number = 6;
             }       
       }

 

using this object :

 

 MyObj aaa = new MyObj();
 byte[] pole = PersistentContent.convertEncodingToByteArray(aaa);

 

 

regards

 

jiri bruza

Please use plain text.
Developer
rihan007
Posts: 408
Registered: 01-14-2009

Re: convertEncodingToByteArray function

You can pass an object which has been created by the encode function in the persistent content class.

Please use plain text.
New Developer
jiza68
Posts: 4
Registered: 02-08-2010
My Carrier: t-mobile

Re: convertEncodingToByteArray function

do you think  similar to this code ?

 

  public static Object encoding ;
    public static byte[] pole;

 

  MyObj aaa = new MyObj();
                    encoding = PersistentContent.encodeObject(aaa, true, true );
                     pole = PersistentContent.convertEncodingToByteArray(encoding);

 

 

 

is correct that encoding is object type ? ( because when I tried part of this code , I  have same problem as before )

or do you have some sample for this function please?

 

regards

 

Jiri Bruza

 

 

 

 

Please use plain text.