Skip to main content

sending object over internet to my PDA

1 reply [Last post]
Joined: 2005-08-12

i need some programming advice using J2ME.
I am going to send some person data objects using HttpConnection to my PDA client for maintaining a person name list, it will possible hold 500 to 1000 names, The person object must be saved on my client using RecordStore and the object must be mutable. what is the best to do?

1 Using eneumeration adding person object to it and send it to my client
2 Using vector adding person object to it and send it to my client.

the enumeration or vector must be converted to a ByteArray before sending I guess., and then mapped to a Person object on my client for reading data to the list, before showing it. Perhaps it uses to much resources. I have looked on some examples using a class for maintaining information about the fields and a wrapper class for a record store

Best Regards


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-03-04


I'm not sure I fully understand. You seem to be mixing together several topics:

- Data structure for holding the person objects: You will need a data structure on the PDA to hold the person objects. Whether this is a vector or a different mechanism (such as a hash table, or list) doesn't matter that much, it depends on your situation. The important part is to keep a cache of person objects in memory because read/write access to RMS is often slow. PS: An enumeration is merely a mechanism to iterate over a set of objects so point 1. in your post is really not applicable (enumeration requires a datastructure to be present to interate over).

- Persistent store in RMS: Periodically (when a person object in memory has changed, for example) you will then need to write the person to RMS. This is best done by converting the person to a byte array and then storing that in RMS. Such caching mechanisms are well known and you should find several examples on the web.

- Sending the data over http: There are many ways to encode the data. In your case, since you are sending 1000 names you probably want to choose an efficient encoding scheme. But for starters you could simply serialize all appropriate fields of the person class into UTF8 and invent a little protocol that indicates the start and end of each person serialization stream. Using this protocol and encoding then iterate overall all persons on the server side, push them down http, and deserialize them on the PDA.

Trying to serialize the actual vector I think is not beneficial. Simply send the person objects one-by-one and then on the PDA side store them in whatever datastructure is most appropriate (vector, list, etc).

Hope this helps,

-- Terrence