Expresso 5-6

com.jcorporate.expresso.core.dataobjects
Class DataTransferObject

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.DataTransferObject
All Implemented Interfaces:
Externalizable, Serializable

public final class DataTransferObject
extends Object
implements Externalizable

Basic HashMap wrapper for the Data Transfer Object pattern. The goal of this class is to provide efficient serialization over the wire of DBOBjects and or the up and coming DataObjects. By encapsulating the 'data guts' of the data objects into this class, routing programs that don't have to know anything about a particular instance of a DBObject/DataObject don't have to have any large code base installed on them.

The other advantage of DataTransferObject is serialization size. On tests conducted 3/17/04, the size of com.jcorporate.expresso.services.dbobj.MimeTypes was 1310 bytes. The size of the same item converted into a DataTransfer object was 293 bytes. For in-memory serialization alone, this translates to twice as fast. For slower connections such as sockets, this speed translation will be more pronounced.

Since:
Expresso 5.0
Author:
Michael Rimov
See Also:
Serialized Form

Constructor Summary
DataTransferObject()
           
 
Method Summary
 String getDataContext()
           
 String getObjectClassName()
           
 Map getTableFields()
          Gets the table fields in bulk
 void readExternal(ObjectInput ois)
          Optimized Deserialization
 void setDataContext(String dataContext)
           
 void setObjectClassName(String objectClassName)
          Sets the classname of the DataObject we're attached to so that we can instantiate it at the far end of the wire.
 void setTableFields(Map tableFields)
          Sets the data fields in bulk.
 void writeExternal(ObjectOutput oos)
          Optimized Serialization implementation that does not utilize any reflection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataTransferObject

public DataTransferObject()
Method Detail

readExternal

public void readExternal(ObjectInput ois)
                  throws ClassNotFoundException,
                         IOException
Optimized Deserialization

Specified by:
readExternal in interface Externalizable
Parameters:
ois - The Object Input object
Throws:
ClassNotFoundException - for reading subobjects
IOException - upon I/O error

writeExternal

public void writeExternal(ObjectOutput oos)
                   throws IOException
Optimized Serialization implementation that does not utilize any reflection

Specified by:
writeExternal in interface Externalizable
Parameters:
oos - The Object Output Stream
Throws:
IOException

setTableFields

public void setTableFields(Map tableFields)
Sets the data fields in bulk. Does not perform a data copy unless the passed in type is not a HashMap

Parameters:
tableFields - the new set of table fields to use

getTableFields

public Map getTableFields()
Gets the table fields in bulk

Returns:
java.util.HashMap

setDataContext

public void setDataContext(String dataContext)
Parameters:
dataContext - The new data context to use

getDataContext

public String getDataContext()
Returns:
the currently set data context.

setObjectClassName

public void setObjectClassName(String objectClassName)
Sets the classname of the DataObject we're attached to so that we can instantiate it at the far end of the wire.

Parameters:
objectClassName - the full classname

getObjectClassName

public String getObjectClassName()

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.