org.walluck.oscar
Class TLVChain

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byorg.walluck.oscar.TLVChain
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class TLVChain
extends java.util.ArrayList

A TLV chain is a block of one or more TLV's.

Since:
1.0
Version:
1.0
Author:
David Walluck
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
TLVChain()
          Creates a new TLV chain.
TLVChain(int size)
          Creates a new TLV chain of the specified size.
 
Method Summary
 void addByte(int type, int value)
          Add a byte to this TLV chain.
 void addBytes(int type, byte[] value)
          Add a byte array to this TLV chain.
 void addCaps(int type, int caps)
          Add a capabilities to this TLV chain.
 void addChatRoom(int type, Chat chat)
          Add a chat room to this TLV chain.
 void addInt(int type, int value)
          Add an integer to this TLV chain.
 void addNull(int type)
          Add a null TLV to a null TLV to this TLV chain.
 void addShort(int type, int value)
          Add a short to this TLV chain.
 void addString(int type, java.lang.String value)
          Add a string to this TLV chain.
 void addTLV(TLV tlv)
          Add a TLV to this TLV chain.
 void addTLVChain(int type, TLVChain tlvchain)
          Add a TLV chain to this TLV chain.
 java.lang.Object clone()
          Clone this TLV chain.
 boolean equals(java.lang.Object obj)
          Test two TLV chains for equality.
 TLV getTLV(int type, int n)
          Get the n-th occurence of a TLV of the specified type in this TLV chain.
 int hashCode()
          Return the hashcode of this TLVChain.
 int length()
          Return the length of this TLV chain in bytes
 void removeTLV(int type, int n)
          Remove the n-th occurence of a TLV of the specified type in this TLV chain.
 int size()
          Return the number of TLV's in this TLV chain.
 java.lang.String toString()
          Return a string representation of this TLV chain.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

TLVChain

public TLVChain()
Creates a new TLV chain.


TLVChain

public TLVChain(int size)
Creates a new TLV chain of the specified size.

Parameters:
size - the number of TLV's that you are going to add to this chain
Method Detail

addString

public void addString(int type,
                      java.lang.String value)
               throws java.io.IOException
Add a string to this TLV chain.

Parameters:
type - the type of TLV
value - the string to add
Throws:
java.io.IOException - if an error occurs

addNull

public void addNull(int type)
             throws java.io.IOException
Add a null TLV to a null TLV to this TLV chain.

Parameters:
type - the type of TLV
Throws:
java.io.IOException - if an error occurs

addByte

public void addByte(int type,
                    int value)
             throws java.io.IOException
Add a byte to this TLV chain.

Parameters:
type - the type of TLV
value - the byte to add
Throws:
java.io.IOException - if an error occurs

addBytes

public void addBytes(int type,
                     byte[] value)
              throws java.io.IOException
Add a byte array to this TLV chain.

Parameters:
type - the type of TLV
value - the byte array to add
Throws:
java.io.IOException - if an error occurs

addShort

public void addShort(int type,
                     int value)
              throws java.io.IOException
Add a short to this TLV chain.

Parameters:
type - the type of TLV
value - the short to add
Throws:
java.io.IOException - if an error occurs

addInt

public void addInt(int type,
                   int value)
            throws java.io.IOException
Add an integer to this TLV chain.

Parameters:
type - the type of TLV
value - the integer to add
Throws:
java.io.IOException - if an error occurs

addTLV

public void addTLV(TLV tlv)
Add a TLV to this TLV chain.

Parameters:
tlv - the TLV to add

addTLVChain

public void addTLVChain(int type,
                        TLVChain tlvchain)
                 throws java.io.IOException
Add a TLV chain to this TLV chain.

Parameters:
type - the type of TLV
tlvchain - the TLV chain to add
Throws:
java.io.IOException - if an error occurs

addCaps

public void addCaps(int type,
                    int caps)
             throws java.io.IOException
Add a capabilities to this TLV chain.

The bitfield passed in should be a bitwise OR of any of the AIM_CAPS constants in AIMConstants. For example:

AIM_CAPS_BUDDYICON
Supports Buddy Icons
AIM_CAPS_VOICE
Supports Voice Chat
AIM_CAPS_IMIMAGE
Supports DirectIM/IMImage
AIM_CAPS_CHAT
Supports Chat
AIM_CAPS_GETFILE
Supports Get File functions
AIM_CAPS_SENDFILE
Supports Send File functions

Parameters:
type - the type of TLV
caps - the capability block to add
Throws:
java.io.IOException - if an error occurs
See Also:
AIMConstants

addChatRoom

public void addChatRoom(int type,
                        Chat chat)
                 throws java.io.IOException
Add a chat room to this TLV chain.

Parameters:
type - the type of TLV
chat - the chat room
Throws:
java.io.IOException - if an error occurs

length

public int length()
Return the length of this TLV chain in bytes

Returns:
the length of this TLV chain in bytes

size

public int size()
Return the number of TLV's in this TLV chain.

Returns:
the number of TLV's in this TLV chain

getTLV

public TLV getTLV(int type,
                  int n)
Get the n-th occurence of a TLV of the specified type in this TLV chain.

Parameters:
type - the type of TLV
n - the occurence
Returns:
the TLV if found, null otherwise

removeTLV

public void removeTLV(int type,
                      int n)
Remove the n-th occurence of a TLV of the specified type in this TLV chain.

Parameters:
type - the type of TLV
n - the occurence

clone

public java.lang.Object clone()
Clone this TLV chain.

Returns:
a copy of this TLV chain

equals

public boolean equals(java.lang.Object obj)
Test two TLV chains for equality.

Parameters:
obj - the TLV chain to test
Returns:
true if equal, false otherwise

hashCode

public int hashCode()
Return the hashcode of this TLVChain.

Returns:
the hashcode of this TLVChain

toString

public java.lang.String toString()
Return a string representation of this TLV chain.

Returns:
the string representation of this TLV chain