edu.umich.eecs.tac.props
Class AbstractTransportable

java.lang.Object
  extended by edu.umich.eecs.tac.props.AbstractTransportable
All Implemented Interfaces:
java.io.Serializable, se.sics.isl.transport.Transportable
Direct Known Subclasses:
AbstractTransportableEntryListBacking, Ad, AdLink, AdvertiserInfo, Auction, BankStatus, ManufacturerComponentComposable, Pricing, PublisherInfo, Ranking, Ranking.Slot, ReserveInfo, SlotInfo, UserClickModel

public abstract class AbstractTransportable
extends java.lang.Object
implements se.sics.isl.transport.Transportable, java.io.Serializable

This class provides a skeletal implementation of the Transportable interface by providing a locking mechanism. Inheriting classes should issue lockCheck() when setting attributes.

Inheriting classes should implement the readWithLock(se.sics.isl.transport.TransportReader) and writeWithLock(se.sics.isl.transport.TransportWriter) methods.

Author:
Patrick Jordan
See Also:
Serialized Form

Constructor Summary
AbstractTransportable()
           
 
Method Summary
 java.lang.String getTransportName()
          Returns the transport name for externalization of an implementing AbstractTransportable will return the simple name of the implementing class.
protected  boolean isLocked()
          Returns whether the transportable is immutable.
 void lock()
          Make the transportable immutable.
protected  void lockCheck()
          Before writing an attribute value, lockCheck() should be called.
 void read(se.sics.isl.transport.TransportReader reader)
          Reads the state for this transportable from the specified reader.
protected abstract  void readWithLock(se.sics.isl.transport.TransportReader reader)
          Reads the state of the transportable.
 void write(se.sics.isl.transport.TransportWriter writer)
          Writes the state for this transportable to the specified writer.
protected abstract  void writeWithLock(se.sics.isl.transport.TransportWriter writer)
          Writes the state of the transportable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransportable

public AbstractTransportable()
Method Detail

lock

public final void lock()
Make the transportable immutable.


isLocked

protected final boolean isLocked()
Returns whether the transportable is immutable.

Returns:
true if the transportable is locked, false otherwise.

lockCheck

protected final void lockCheck()
                        throws java.lang.IllegalStateException
Before writing an attribute value, lockCheck() should be called. This method will throw an illegal state exception if a write is called on a locked object.

Throws:
java.lang.IllegalStateException - throws exception if object is locked.

read

public final void read(se.sics.isl.transport.TransportReader reader)
                throws java.text.ParseException
Reads the state for this transportable from the specified reader.

Specified by:
read in interface se.sics.isl.transport.Transportable
Parameters:
reader - the reader to read data from
Throws:
java.text.ParseException - if a parse error occurs

write

public final void write(se.sics.isl.transport.TransportWriter writer)
Writes the state for this transportable to the specified writer.

Specified by:
write in interface se.sics.isl.transport.Transportable
Parameters:
writer - the writer to write data to

getTransportName

public final java.lang.String getTransportName()
Returns the transport name for externalization of an implementing AbstractTransportable will return the simple name of the implementing class.

Specified by:
getTransportName in interface se.sics.isl.transport.Transportable
Returns:
the transport name

readWithLock

protected abstract void readWithLock(se.sics.isl.transport.TransportReader reader)
                              throws java.text.ParseException
Reads the state of the transportable. Implementing classes should read in attributes first and then any sub-nodes.

Parameters:
reader - the reader to read data from.
Throws:
java.text.ParseException - if a parse error occurs

writeWithLock

protected abstract void writeWithLock(se.sics.isl.transport.TransportWriter writer)
Writes the state of the transportable. Implementing classes should write out attributes first and then any sub-nodes.

Parameters:
writer - the writer to write data to.


Copyright © 2007-2009 Association for Trading Agent Research. All Rights Reserved.