jSyncManager

org.jSyncManager.API.Protocol
Class ShortArgument

java.lang.Object
  extended byorg.jSyncManager.API.Protocol.Argument
      extended byorg.jSyncManager.API.Protocol.ShortArgument
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SmallArgument, TinyArgument

abstract class ShortArgument
extends Argument
implements java.io.Serializable

The short argument abstract class. This argument type is used as a parent to all "short" arguments. Short arguments all contain an argument ID, and can have multiple representations.


Field Summary
(package private)  byte argumentID
          A field to hold this arguments ID number.
(package private)  byte[] data
          The data contained by this argument.
static byte FIRST_ARG_ID
          The ID number for the first argument in any packet containing arguments.
 
Constructor Summary
(package private) ShortArgument()
          Create a new short argument.
(package private) ShortArgument(byte[] inData)
          Constructs a new argument from the specified data.
 
Method Summary
(package private) abstract  byte[] arg2Bytes()
          Converts this argument into an array of bytes.
static Argument createArgument(byte[] data, int i)
          Creates an argument from a byte array.
(package private) abstract  byte[] getArgument()
          Gets this arguments data as an array of bytes.
(package private) abstract  int getSize()
          Retreives the size of this argument.
static Argument parseArgument(byte[] inData)
          Parses a byte array representing an argument into its corresponding Argument object.
static Argument[] parseArguments(int i, byte[] data)
          Parses a series of arguments into an array of argument objects.
 java.lang.String toString()
          Convert this object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

argumentID

byte argumentID
A field to hold this arguments ID number.


data

byte[] data
The data contained by this argument.


FIRST_ARG_ID

public static final byte FIRST_ARG_ID
The ID number for the first argument in any packet containing arguments.

See Also:
Constant Field Values
Constructor Detail

ShortArgument

ShortArgument()
Create a new short argument. This class cannot be constructed directly, as it is marked as abstract. Instead, this is provided so subclasses can call super() in their constructors.


ShortArgument

ShortArgument(byte[] inData)
Constructs a new argument from the specified data. As this class is abstract, direct calls to this constructor will fail.

Method Detail

toString

public java.lang.String toString()
Convert this object to a human-readable String.

Returns:
this object to a human-readable String.

arg2Bytes

abstract byte[] arg2Bytes()
Converts this argument into an array of bytes.

Returns:
a byte array representation of this argument.

getSize

abstract int getSize()
Retreives the size of this argument.

Returns:
the size of this argument.

getArgument

abstract byte[] getArgument()
Gets this arguments data as an array of bytes. Calls to this method differ from arg2Bytes in that where it returns the full bytes of the argument (including any header information), calls to this method will return only the data that this argument contains.

Returns:
an array of bytes containing this argument objects data.

createArgument

public static Argument createArgument(byte[] data,
                                      int i)
Creates an argument from a byte array. This method will construct the proper Argument subclass according to the size of the input data.

Parameters:
data - the data to be included in the argument.
i - the ID of the first argument in this packet.
Returns:
the Argument object representing the input data.

parseArgument

public static Argument parseArgument(byte[] inData)
Parses a byte array representing an argument into its corresponding Argument object.

Parameters:
inData - the input byte array to be parsed.
Returns:
the argument object representing by the input data.

parseArguments

public static Argument[] parseArguments(int i,
                                        byte[] data)
Parses a series of arguments into an array of argument objects.

Parameters:
i - the number of arguments to parse.
data - the input data array.

jSyncManager

Copyright (c) 1999 - 2004 Brad BARCLAY and others. All Rights Reserved.