Sun GlassFish Mobility Platform 1.1 Developer's Guide for Client Applications

The BusinessObject Class

Table 4–2 lists the constructors and methods belonging to the BusinessObject class. This class is the base type for objects that will be synchronized with the gateway. Each business object instance is identified by a name, which is also used to name the file holding the serialized form of the object on the device's filesystem. You can create a BusinessObject from scratch by instantiating a concrete subclass, or you can create an empty BusinessObject and deserialize the contents of a byte array into it. Use the latter technique when implementing the deserialize method.

Table 4–2 Class com.sun.mep.client.api.BusinessObject

Method 

Description 

BusinessObject()

No-argument constructor. 

BusinessObject(java.lang.String name)

Constructor that takes the name of the object as an argument. 

public abstract void deserialize(byte[] data)

Deserializes the supplied byte array into this empty BusinessObject.

public abstract java.lang.String getExtension()

Returns the default extension for business objects of this type. Extensions are used by the files holding these objects and must be part of the contract with the Enterprise Connectors. That is, clients and Enterprise Connectors must use the same extension for the same type of business object. Concrete subclasses should redefine this method. 

public java.lang.String getName()

Returns the name of this BusinessObject.

public abstract byte[] serialize()

Serializes this BusinessObject into a byte array.

public void setName(java.lang.String name)

Sets the name of this BusinessObject. This method may only be called once, to initialize a new BusinessObject being deserialized. You may not change the name once it has been set. The name must be a unique identifier that can legally be used as a file name. For more information about the format of the file name, refer to the API documentation for package javax.microedition.io.file under the section entitled “FileConnection URL Format” in JSR-75: Optional Packages for the J2ME Platform.