net.kano.joscar.rvcmd
Class AbstractRvCmd

java.lang.Object
  extended byRvCommand
      extended byAbstractRvCmd
Direct Known Subclasses:
AbstractAcceptRvCmd, AbstractRejectRvCmd, AbstractRequestRvCmd

public abstract class AbstractRvCmd
extends RvCommand

A base class for the basic rendezvous format used by all known AIM clients. Provides a simpler way to read and write the RV data as a TLV chain as well as for reading and writing the common "service data block." Also provides a means of writing "header TLV's" before the RV-type-specific


Field Summary
 
Fields inherited from class RvCommand
RVSTATUS_ACCEPT, RVSTATUS_DENY, RVSTATUS_REQUEST
 
Constructor Summary
protected AbstractRvCmd(int rvStatus, CapabilityBlock cap)
          Creates a new outgoing RV command with the given properties.
protected AbstractRvCmd(RecvRvIcbm icbm)
          Creates a new RV command from the given incoming rendezvous ICBM command.
 
Method Summary
protected  TlvChain getRvTlvs()
          Returns the TLV's contained in this rendezvous command's RV data block.
protected  ByteBlock getServiceData()
          Returns the "service data" block contained in this command, if any.
protected  boolean hasServiceData()
          Returns whether this RV command's TLV list should contain a "service data block" TLV.
protected abstract  void writeHeaderRvTlvs(java.io.OutputStream out)
          Writes this RV command's "header TLV's" to the given stream.
 void writeRvData(java.io.OutputStream out)
          Writes this RV command's "rendezvous data block" to the given stream.
protected abstract  void writeRvTlvs(java.io.OutputStream out)
          Writes this RV command's list of rendezvous TLV's to the given stream.
protected  void writeServiceData(java.io.OutputStream out)
          Writes this RV command's "service data block."
 
Methods inherited from class RvCommand
getCapabilityBlock, getRvStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRvCmd

protected AbstractRvCmd(RecvRvIcbm icbm)
Creates a new RV command from the given incoming rendezvous ICBM command.

Parameters:
icbm - an incoming rendezvous ICBM command

AbstractRvCmd

protected AbstractRvCmd(int rvStatus,
                        CapabilityBlock cap)
Creates a new outgoing RV command with the given properties.

Parameters:
rvStatus - the rendezvous status code for this command
cap - the capability block ("rendezvous type") of this RV command
Method Detail

getServiceData

protected final ByteBlock getServiceData()
Returns the "service data" block contained in this command, if any. "Service data" is the data in the type 0x2711 rendezvous TLV. Note that this will be null if this command was not read from an incoming RecvRvIcbm. This method will also return null if this command was read in from an incoming RV ICBM but contained no service data block.

Returns:
this RV command's "service data block," if any

getRvTlvs

protected final TlvChain getRvTlvs()
Returns the TLV's contained in this rendezvous command's RV data block. This value will be null if this rendezvous command was not read from an incoming RecvRvIcbm but was instead created manually. This command will not otherwise return null for reasons of ease of use. Note that The returned TLV chain may not contain all of the original TLV's that were received in the incoming RV ICBM; for example, the returned chain will not contain TLV's of type 0x2711 as that value is extracted and can be retrieved with a call to getServiceData().

Returns:
this RV command's RV TLV chain, if any

writeRvData

public final void writeRvData(java.io.OutputStream out)
                       throws java.io.IOException
Description copied from class: RvCommand
Writes this RV command's "rendezvous data block" to the given stream.

Specified by:
writeRvData in class RvCommand
Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

writeHeaderRvTlvs

protected abstract void writeHeaderRvTlvs(java.io.OutputStream out)
                                   throws java.io.IOException
Writes this RV command's "header TLV's" to the given stream. This method will always be called prior to any call to writeRvTlvs(java.io.OutputStream); it provides a means for subclasses to write a set of TLV's that are present in all subclasses.

Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

writeRvTlvs

protected abstract void writeRvTlvs(java.io.OutputStream out)
                             throws java.io.IOException
Writes this RV command's list of rendezvous TLV's to the given stream.

Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

hasServiceData

protected boolean hasServiceData()
Returns whether this RV command's TLV list should contain a "service data block" TLV. The return value of this method must be consistent throughout this object's existence. Note that if this method returns false for an object, writeServiceData will never be called on that object. The default implementation of this method returns true.

Returns:
whether or not this RV command has a "service data block"
See Also:
writeServiceData(java.io.OutputStream)

writeServiceData

protected void writeServiceData(java.io.OutputStream out)
                         throws java.io.IOException
Writes this RV command's "service data block." A service data block's format changes from rendezvous to rendezvous, but generally provides information specific to the type of rendezvous being sent. For example, in a file transfer request, the file's name and size (among other fields) are sent in the service block. This method will never be called if hasServiceData() returns false. The default implementation of this method does not write any data to the stream.

Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs