net.kano.joscar.snaccmd
Class ExtraInfoBlock

java.lang.Object
  extended byExtraInfoBlock
All Implemented Interfaces:
LiveWritable, Writable

public final class ExtraInfoBlock
extends java.lang.Object
implements Writable

Represents an "extra information block," as I call it, which contains a single result code and an ExtraInfoData. This structure is used in various SNAC commands related to buddy icons and iChat availabilty messages.


Field Summary
static int TYPE_AIMEXPINFO
          An extra info block type indicating that the block contains AIM Expression information.
static int TYPE_AVAILMSG
          An extra info block type indicating that it contains iChat availability message information.
static int TYPE_CERTINFO_HASHA
          An extra info block type indicating that the block contains a security-related MD5 hash whose significance is unknown at the time of this writing.
static int TYPE_CERTINFO_HASHB
          An extra info block type indicating that the block contains a security-related MD5 hash whose significance is unknown at the time of this writing.
static int TYPE_ICONHASH
          An extra info block type indicating that it contains buddy icon information.
 
Constructor Summary
  ExtraInfoBlock(int type, ExtraInfoData extraData)
          Creates an extra info block object with the given type code and data.
protected ExtraInfoBlock(int code, ExtraInfoData data, int totalSize)
          Creates a new extra info block object with the given properties.
 
Method Summary
 ExtraInfoData getExtraData()
          The data embedded in this extra info block.
 int getTotalSize()
          Returns the total size, in bytes, of this object.
 int getType()
          Returns the type code for this extra info block.
 long getWritableLength()
          Returns the length of the data that was or will be written in a call to write.
static ExtraInfoBlock readExtraInfoBlock(ByteBlock block)
          Reads an extra info block from the given data block.
static ExtraInfoBlock[] readExtraInfoBlocks(ByteBlock block)
          Reads a series of ExtraInfoBlocks from the given block.
 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

TYPE_ICONHASH

public static final int TYPE_ICONHASH
An extra info block type indicating that it contains buddy icon information.

See Also:
Constant Field Values

TYPE_AVAILMSG

public static final int TYPE_AVAILMSG
An extra info block type indicating that it contains iChat availability message information.

See Also:
Constant Field Values

TYPE_AIMEXPINFO

public static final int TYPE_AIMEXPINFO
An extra info block type indicating that the block contains AIM Expression information.

See Also:
Constant Field Values

TYPE_CERTINFO_HASHA

public static final int TYPE_CERTINFO_HASHA
An extra info block type indicating that the block contains a security-related MD5 hash whose significance is unknown at the time of this writing.

See Also:
Constant Field Values

TYPE_CERTINFO_HASHB

public static final int TYPE_CERTINFO_HASHB
An extra info block type indicating that the block contains a security-related MD5 hash whose significance is unknown at the time of this writing.

See Also:
Constant Field Values
Constructor Detail

ExtraInfoBlock

protected ExtraInfoBlock(int code,
                         ExtraInfoData data,
                         int totalSize)
Creates a new extra info block object with the given properties.

Parameters:
code - the type code associated with this extra info block object, like TYPE_AVAILMSG
data - the data in this extra info block
totalSize - the total size of this object, if read from a block of data

ExtraInfoBlock

public ExtraInfoBlock(int type,
                      ExtraInfoData extraData)
Creates an extra info block object with the given type code and data.

Parameters:
type - the type of data being stored in this extra info block
extraData - a block of extra info data
Method Detail

readExtraInfoBlocks

public static ExtraInfoBlock[] readExtraInfoBlocks(ByteBlock block)
Reads a series of ExtraInfoBlocks from the given block. The total number of bytes read is the sum of calling getTotalSize on each element of the returned array.

Parameters:
block - the block containing zero or more extra info blocks
Returns:
a list of zero or more extra info block objects read from the given data block

readExtraInfoBlock

public static ExtraInfoBlock readExtraInfoBlock(ByteBlock block)
Reads an extra info block from the given data block.

Parameters:
block - the data block from which to read
Returns:
an extra info block object read from the given data block, or null if no valid object could be read

getType

public final int getType()
Returns the type code for this extra info block. The returned value will normally be one of TYPE_ICONHASH and TYPE_AVAILMSG.

Returns:
a type code

getExtraData

public final ExtraInfoData getExtraData()
The data embedded in this extra info block.

Returns:
this object's associated extra data block

getTotalSize

public final int getTotalSize()
Returns the total size, in bytes, of this object. Will be -1 if this object was not read using readExtraInfoBlock or readExtraInfos.

Returns:
the total size, in bytes, of this object, if read from a data block

getWritableLength

public long getWritableLength()
Description copied from interface: Writable
Returns the length of the data that was or will be written in a call to write. The value returned by this method must not change after its first invocation.

Specified by:
getWritableLength in interface Writable
Returns:
the length of the data to be written by write

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Description copied from interface: Writable
Writes a representation of this object to the given stream. The length of the data written by this function must match any value previously returned by getWritableLength.

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

toString

public java.lang.String toString()