net.kano.joscar.snaccmd
Class MiniRoomInfo

java.lang.Object
  extended byMiniRoomInfo
All Implemented Interfaces:
LiveWritable

public final class MiniRoomInfo
extends java.lang.Object
implements LiveWritable

A data structure used to transmit a small amount of information about a chat room. Contains fields for an exchange number, a service redirect cookie, and an instance number.


Constructor Summary
  MiniRoomInfo(FullRoomInfo roomInfo)
          Creates a new miniature room information block with the exchange, cookie, and instance properties of the given full room information block.
  MiniRoomInfo(int exchange, java.lang.String cookie, int instance)
          Creates a new mini room info object with the given properties.
protected MiniRoomInfo(int exchange, java.lang.String cookie, int instance, int totalSize)
          Creates a room info object with the given properties.
 
Method Summary
 java.lang.String getCookie()
          Returns the service redirect cookie that can be used to join this room.
 int getExchange()
          Returns the number of the exchange on which this room resides.
 int getInstance()
          Returns "instance number" of this room.
 int getTotalSize()
          Returns the total size of this object, as read from a block of binary data.
static MiniRoomInfo readMiniRoomInfo(ByteBlock block)
          Reads a MiniRoomInfo block from the given data block, or null if no valid block can be read.
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
          Writes a representation of this object to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MiniRoomInfo

protected MiniRoomInfo(int exchange,
                       java.lang.String cookie,
                       int instance,
                       int totalSize)
Creates a room info object with the given properties.

Parameters:
exchange - the number of the exchange on which this room resides
cookie - the service redirect cookie that can be used to join this room
instance - the "instance number" of this room
totalSize - the total size of this object, as read from a block of binary data

MiniRoomInfo

public MiniRoomInfo(FullRoomInfo roomInfo)
Creates a new miniature room information block with the exchange, cookie, and instance properties of the given full room information block.

Parameters:
roomInfo - a full room information block from which to derive this miniature room information block's properties

MiniRoomInfo

public MiniRoomInfo(int exchange,
                    java.lang.String cookie,
                    int instance)
Creates a new mini room info object with the given properties.

Parameters:
exchange - the number of the chat exchange on which the associated room exists
cookie - the service redirect cookie that can be used to join this room
instance - the "instance number" of this room
Method Detail

readMiniRoomInfo

public static MiniRoomInfo readMiniRoomInfo(ByteBlock block)
Reads a MiniRoomInfo block from the given data block, or null if no valid block can be read.

Parameters:
block - the data block from which to generate the mini room info object
Returns:
a mini room info object read from the given data block, or null if no valid object can be read

getExchange

public final int getExchange()
Returns the number of the exchange on which this room resides. See ExchangeInfo for a brief explanation of exchanges.

Returns:
the exchange on which this room exists

getCookie

public final java.lang.String getCookie()
Returns the service redirect cookie that can be used to join this room.

Returns:
the service redirect cookie associated with this room

getInstance

public final int getInstance()
Returns "instance number" of this room. As of this writing I am unsure of the significance of this number.

Returns:
this room's "instance number"

getTotalSize

public final int getTotalSize()
Returns the total size of this object, as read from a block of binary data. Will be -1 if this object was not read using readMiniRoomInfo.

Returns:
the total size, in bytes, of this object, or -1 if it was not read from binary data but instead instantiated manually

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Description copied from interface: LiveWritable
Writes a representation of this object to the given stream.

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

toString

public java.lang.String toString()