net.kano.joscar.flapcmd
Class SnacCommand

java.lang.Object
  extended bySnacCommand
Direct Known Subclasses:
AbstractIcbm, AcctCommand, AuthCommand, BuddyCommand, ChatCommand, ConnCommand, IcbmCommand, IconCommand, InviteCommand, LocCommand, PopupCommand, RoomCommand, SearchCommand, SnacError, SsiCommand

public abstract class SnacCommand
extends java.lang.Object

Represents a single SNAC command that can write a single SNAC packet to a stream. SnacCommand is currently the only means of sending a SNAC command over a FLAP connection in joscar.


Field Summary
static short SNACFLAG_DEFAULT
          The default value for both the first and the second flags of a SNAC command.
 
Constructor Summary
protected SnacCommand(int family, int command)
          Creates a new SnacCommand with the given properties and both flags set to SNACFLAG_DEFAULT.
protected SnacCommand(int family, int command, short flag1, short flag2)
          Creates a new SnacCommand with the given properties.
 
Method Summary
 int getCommand()
          Returns the SNAC command subtype of this command.
 int getFamily()
          Returns the SNAC command family of this command.
 short getFlag1()
          Returns the first "flag byte" of this SNAC command.
 short getFlag2()
          Returns the second "flag byte" of this SNAC command.
abstract  void writeData(java.io.OutputStream out)
          Writes this command's SNAC data block to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNACFLAG_DEFAULT

public static final short SNACFLAG_DEFAULT
The default value for both the first and the second flags of a SNAC command.

See Also:
Constant Field Values
Constructor Detail

SnacCommand

protected SnacCommand(int family,
                      int command)
Creates a new SnacCommand with the given properties and both flags set to SNACFLAG_DEFAULT. Using this constructor is equivalent to using new SnacCommand(family, command, SnacCommand.SNACFLAG_DEFAULT, SnacCommand.SNACFLAG_DEFAULT).

Parameters:
family - the SNAC command family of this command
command - the SNAC command subtype of this command

SnacCommand

protected SnacCommand(int family,
                      int command,
                      short flag1,
                      short flag2)
Creates a new SnacCommand with the given properties.

Parameters:
family - the SNAC command family of this command
command - the SNAC command subtype of this command
flag1 - the first flag byte of this command
flag2 - the second flag byte of this command
Method Detail

getFamily

public final int getFamily()
Returns the SNAC command family of this command.

Returns:
this command's SNAC command family

getCommand

public final int getCommand()
Returns the SNAC command subtype of this command.

Returns:
this command's SNAC command ID ("subtype")

getFlag1

public final short getFlag1()
Returns the first "flag byte" of this SNAC command.

Returns:
this SNAC command's first "flag byte"

getFlag2

public final short getFlag2()
Returns the second "flag byte" of this SNAC command.

Returns:
this SNAC command's second "flag byte"

writeData

public abstract void writeData(java.io.OutputStream out)
                        throws java.io.IOException
Writes this command's SNAC data block to the given stream. The SNAC data block is the data after the first ten bytes of a SNAC packet.

Parameters:
out - the stream to which to write the SNAC data
Throws:
java.io.IOException - if an I/O error occurs