net.kano.joscar.snaccmd.ssi
Class SsiItem

java.lang.Object
  extended bySsiItem
All Implemented Interfaces:
LiveWritable, java.io.Serializable

public class SsiItem
extends java.lang.Object
implements LiveWritable, java.io.Serializable

A data structure used to store various types of "items" on the server. These items can be buddies (with comments and buddy alert data), groups, blocked buddies, and other settings. See the the ssiitem package for more logical implementations of specific SSI item types.

See Also:
net.kano.joscar.ssiitem, Serialized Form

Field Summary
static int TYPE_BUDDY
          An SSI item type for a buddy.
static int TYPE_DENY
          An SSI item type for a "blocked" user, or "deny."
static int TYPE_GROUP
          An SSI item type for a buddy group.
static int TYPE_ICON_INFO
          An SSI item type for a buddy icon hash.
static int TYPE_PERMIT
          An SSI item type for an "allowed" user, or "permit."
static int TYPE_PRIVACY
          An SSI item type for various privacy-related settings.
static int TYPE_VISIBILITY
          An SSI item type for various "visiblity-related" settings.
 
Constructor Summary
SsiItem(int parentid, int id, int type)
          Creates a new SSI item with no name or type-specific data and with the given parent ID, sub ID, and item type.
SsiItem(java.lang.String name, int parentid, int id, int type, ByteBlock data)
          Creates a new SSI item with the given properties.
 
Method Summary
 ByteBlock getData()
          Returns the type-specific data stored in this item.
 int getId()
          Returns the ID or "sub ID" of this item.
 int getItemType()
          Returns this item's type.
 java.lang.String getName()
          Returns the name of this item.
 int getParentId()
          Returns the "parent ID" of this item.
 int getTotalSize()
          Returns the total size, in bytes, of this object, if read from an incoming block of binary data.
protected static SsiItem readSsiItem(ByteBlock block)
          Generates a new SSI item from the given block of binary data, or null if no valid item could 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
 

Field Detail

TYPE_BUDDY

public static final int TYPE_BUDDY
An SSI item type for a buddy.

See Also:
BuddyItem, Constant Field Values

TYPE_GROUP

public static final int TYPE_GROUP
An SSI item type for a buddy group.

See Also:
RootItem, GroupItem, Constant Field Values

TYPE_PERMIT

public static final int TYPE_PERMIT
An SSI item type for an "allowed" user, or "permit."

See Also:
PermitItem, Constant Field Values

TYPE_DENY

public static final int TYPE_DENY
An SSI item type for a "blocked" user, or "deny."

See Also:
DenyItem, Constant Field Values

TYPE_PRIVACY

public static final int TYPE_PRIVACY
An SSI item type for various privacy-related settings.

See Also:
PrivacyItem, Constant Field Values

TYPE_VISIBILITY

public static final int TYPE_VISIBILITY
An SSI item type for various "visiblity-related" settings.

See Also:
VisibilityItem, Constant Field Values

TYPE_ICON_INFO

public static final int TYPE_ICON_INFO
An SSI item type for a buddy icon hash.

See Also:
IconItem, Constant Field Values
Constructor Detail

SsiItem

public SsiItem(int parentid,
               int id,
               int type)
Creates a new SSI item with no name or type-specific data and with the given parent ID, sub ID, and item type.

Parameters:
parentid - the "parent ID" of this item
id - the ID of this item in its parent
type - the type of this item, like TYPE_BUDDY

SsiItem

public SsiItem(java.lang.String name,
               int parentid,
               int id,
               int type,
               ByteBlock data)
Creates a new SSI item with the given properties.

Parameters:
name - the name of this item
parentid - the "parent ID" of this item
id - the ID of this item in its parent
type - the type of this item, like TYPE_GROUP
data - a block of type-specific data, or null (or an empty block) for none
Method Detail

readSsiItem

protected static SsiItem readSsiItem(ByteBlock block)
Generates a new SSI item from the given block of binary data, or null if no valid item could be read.

Parameters:
block - a block of data containing an SSI item
Returns:
a new SSI item object read from the given block of data, or null if none could be read

getName

public final java.lang.String getName()
Returns the name of this item.

Returns:
the name of this item

getParentId

public final int getParentId()
Returns the "parent ID" of this item.

Returns:
this item's "parent ID"

getId

public final int getId()
Returns the ID or "sub ID" of this item. This value is only unique within its parent.

Returns:
this item's "sub ID" in its parent

getItemType

public final int getItemType()
Returns this item's type. Normally one of the TYPE_* constants defined in this class.

Returns:
this item's SSI item type

getData

public final ByteBlock getData()
Returns the type-specific data stored in this item.

Returns:
this item's type-specific data block

getTotalSize

public int getTotalSize()
Returns the total size, in bytes, of this object, if read from an incoming block of binary data. Note that this will be -1 if this item was not read from an incoming data block.

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

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