net.kano.joscar.snaccmd
Class InfoData

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

public class InfoData
extends java.lang.Object
implements LiveWritable

A data structure used to transmit one's "info" ("profile"), away message, and capability blocks.


Field Summary
static java.lang.String NOT_AWAY
          An away message string indicating that one has come back from away.
 
Constructor Summary
InfoData(java.lang.String awayMessage)
          Creates a new InfoData structure containing only an away message.
InfoData(java.lang.String info, java.lang.String awayMessage, CapabilityBlock[] caps, CertificateInfo certInfo)
          Creates a new info data object with the given properties.
 
Method Summary
 java.lang.String getAwayMessage()
          Returns the away message associated with this object, or null if that field was not sent.
 CapabilityBlock[] getCaps()
          Returns a list of capability blocks advertised by this user, or null if this field was not sent.
 CertificateInfo getCertificateInfo()
          Returns the certificate information block contained in this info data object.
 java.lang.String getInfo()
          Returns the user info text associated with this object, or null if that field was not included in this object.
static InfoData readInfoData(ByteBlock block)
          Reads a user info data block from the given data block.
static InfoData readInfoDataFromChain(TlvChain chain)
          Reads a user info data block from the given TLV chain.
 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
 

Field Detail

NOT_AWAY

public static final java.lang.String NOT_AWAY
An away message string indicating that one has come back from away. It is of note that this is just an empty string, or "".

See Also:
Constant Field Values
Constructor Detail

InfoData

public InfoData(java.lang.String awayMessage)
Creates a new InfoData structure containing only an away message. Note that the awayMessage can be NOT_AWAY (an empty string), indicating that the user is back from being away.

Parameters:
awayMessage - the away message, or NOT_AWAY (an empty string) to indicate that the user is back from being away

InfoData

public InfoData(java.lang.String info,
                java.lang.String awayMessage,
                CapabilityBlock[] caps,
                CertificateInfo certInfo)
Creates a new info data object with the given properties. Any of these can be null to indicate that that field shall not be sent. Note that to unset away (to set "back"), one must use NOT_AWAY (which is actually just an empty string) instead of null for the awayMessage argument.

Parameters:
info - the user's user info text
awayMessage - the user's away message
caps - a list of supported capability blocks
certInfo - client certificate information (for Encrypted IM)
Method Detail

readInfoData

public static InfoData readInfoData(ByteBlock block)
Reads a user info data block from the given data block. Calling this method is equvalent to calling readInfoDataFromChain(TlvChain.readChain(block).

Parameters:
block - the data block containing user info
Returns:
a user info data object read from the given data block

readInfoDataFromChain

public static InfoData readInfoDataFromChain(TlvChain chain)
Reads a user info data block from the given TLV chain. (A user info data block is simply a series of TLV's.)

Parameters:
chain - the TLV chain containing user info TLV's
Returns:
a user info data block read from the given TLV chain

getInfo

public final java.lang.String getInfo()
Returns the user info text associated with this object, or null if that field was not included in this object.

Returns:
the users user info text (his or her "profile")

getAwayMessage

public final java.lang.String getAwayMessage()
Returns the away message associated with this object, or null if that field was not sent.

Returns:
the user's away message

getCaps

public final CapabilityBlock[] getCaps()
Returns a list of capability blocks advertised by this user, or null if this field was not sent. Note that this field will be a zero-length array instead of null if this field was sent but empty.

Returns:
the user's supported capability blocks

getCertificateInfo

public final CertificateInfo getCertificateInfo()
Returns the certificate information block contained in this info data object.

Returns:
the associated user's certificate information block, or null if none was sent

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()