net.kano.joscar.snaccmd.search
Class InterestInfo

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

public class InterestInfo
extends java.lang.Object
implements LiveWritable

A data structure containing information about a "chat interest." A quick example of a list of interest information follows (note that these are not actual chat topics on AOL's AIM servers; I just made them up for an example).

Consider the given list of interests sent in an InterestListCmd.

Type Parent ID Name
TYPE_CHILD 34 Cats
TYPE_CHILD 34 Fish
TYPE_PARENT 34 Pets
TYPE_PARENT 7 Food
TYPE_CHILD 34 Birds
TYPE_CHILD 0 General Chat
TYPE_CHILD 7 Pizza
TYPE_CHILD 0 AIM Help


The preceding list of chat interest information blocks should be rendered to the user as such: Note that even though "Pets" is a "parent" interest, it is still a valid chat interest (meaning one can list "Pets" as one of his or her chat interests just like with, say, "Cats").

Also note that, by design, the sent "tree" of interests can be only one level deep; interests cannot be children of other children (for instance, it is impossible to have a "Pepperoni" interest as a sub-interest of "Pizza" in the above example because "Pizza" is already a sub-interest).


Field Summary
static int TYPE_CHILD
          An interest type indicating that the interest has no sub-interests.
static int TYPE_PARENT
          An interest type indicating that the interest has sub-interests.
 
Constructor Summary
  InterestInfo(int type, int parent, java.lang.String name)
          Creates a new chat interest information block with the given properties.
protected InterestInfo(int type, int parent, java.lang.String name, int totalSize)
          Creates a new chat interest information block with the given properties.
 
Method Summary
 java.lang.String getName()
          Returns the name of this chat interest, like "Travel."
 int getParentId()
          Returns the "parent ID" of this chat interest.
 int getTotalSize()
          Returns the total size of this chat interest information block, as read from a block of binary data.
 int getType()
          Returns the "interest type" of this chat interest.
protected static InterestInfo readInterestInfo(ByteBlock block)
          Generates a new chat interest information block from the given block of binary data.
 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_PARENT

public static final int TYPE_PARENT
An interest type indicating that the interest has sub-interests.

See Also:
Constant Field Values

TYPE_CHILD

public static final int TYPE_CHILD
An interest type indicating that the interest has no sub-interests.

See Also:
Constant Field Values
Constructor Detail

InterestInfo

protected InterestInfo(int type,
                       int parent,
                       java.lang.String name,
                       int totalSize)
Creates a new chat interest information block with the given properties.

Parameters:
type - the type of chat interest, like TYPE_PARENT
parent - the parent ID of this chat interest: the ID of this interest if the type is TYPE_PARENT, or the ID of this interest's parent if the type is TYPE_CHILD
name - the name of this interest, like "Travel"
totalSize - the total size of this object, as read from a block of binary data

InterestInfo

public InterestInfo(int type,
                    int parent,
                    java.lang.String name)
Creates a new chat interest information block with the given properties.

Parameters:
type - the type of chat interest, like TYPE_PARENT
parent - the parent ID of this chat interest: the ID of this interest if the type is TYPE_PARENT, or the ID of this interest's parent if the type is TYPE_CHILD
name - the name of this interest, like "Travel"
Method Detail

readInterestInfo

protected static InterestInfo readInterestInfo(ByteBlock block)
Generates a new chat interest information block from the given block of binary data. Will return null if no valid interest information block can be read.

Parameters:
block - a block of binary data containing a chat interest information block
Returns:
an interest information block read from the given block of binary data, or null if none could be read

getType

public final int getType()
Returns the "interest type" of this chat interest. Normally either TYPE_CHILD or TYPE_PARENT. Note that this value dictates the meaning of the parent ID.

Returns:
the type of this chat interest, like TYPE_CHILD

getParentId

public final int getParentId()
Returns the "parent ID" of this chat interest. Normally, if the type is TYPE_PARENT, this value represents a unique ID for this chat interest. If the type is TYPE_CHILD, this value represents the unique ID of a "parent" interest under which this interest should be listed.

Returns:
this chat interest's "parent ID"

getName

public final java.lang.String getName()
Returns the name of this chat interest, like "Travel."

Returns:
this chat interest's name

getTotalSize

public int getTotalSize()
Returns the total size of this chat interest information block, as read from a block of binary data. Note that this will be -1 if this block was not created from an incoming block of data.

Returns:
the total size, in bytes, of this chat interest block, as read from an incoming data block

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