net.kano.joscar.snaccmd
Class DirInfo

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

public final class DirInfo
extends java.lang.Object
implements LiveWritable

Represents a set of "directory information," used for searching for buddies by various fields.


Constructor Summary
  DirInfo(java.lang.String email, java.lang.String first, java.lang.String middle, java.lang.String last, java.lang.String maiden, java.lang.String nickname, java.lang.String address, java.lang.String city, java.lang.String state, java.lang.String zip, java.lang.String country, java.lang.String language)
          Creates a new directory info object with the given properties and no associated screenname.
  DirInfo(java.lang.String sn, java.lang.String email, java.lang.String first, java.lang.String middle, java.lang.String last, java.lang.String maiden, java.lang.String nickname, java.lang.String address, java.lang.String city, java.lang.String state, java.lang.String zip, java.lang.String country, java.lang.String language)
          Creates a new directory info object with the given properties.
protected DirInfo(java.lang.String sn, java.lang.String email, java.lang.String first, java.lang.String middle, java.lang.String last, java.lang.String maiden, java.lang.String nickname, java.lang.String address, java.lang.String city, java.lang.String state, java.lang.String zip, java.lang.String country, java.lang.String language, int totalSize)
          Creates a new directory info object with the given properties.
 
Method Summary
 java.lang.String getCity()
          Returns the city of residence field of this directory info block.
 java.lang.String getCountryCode()
          Returns the country-code field of this directory info block.
 java.lang.String getEmail()
          Returns the email address field of this directory info block.
 java.lang.String getFirstname()
          Returns the first-name field of this directory info block.
 java.lang.String getLanguageCode()
          Returns the language-code field of this directory info block.
 java.lang.String getLastname()
          Returns the last-name field of this directory info block.
 java.lang.String getMaiden()
          Returns the maiden-name field of this directory info block.
 java.lang.String getMiddlename()
          Returns the middle-name field of this directory info block.
 java.lang.String getNickname()
          Returns the nickname field of this directory info block.
 java.lang.String getScreenname()
          Returns the screenname holding this directory information.
 java.lang.String getState()
          Returns the state field of this directory info block.
 java.lang.String getStreetAddress()
          Returns the street-address field of this directory info block.
 int getTlvCount()
          Returns the total number of TLV's that will be or have been written using write.
 int getTotalSize()
          Returns the total number of bytes this directory information object used when read from a byte block.
 java.lang.String getZip()
          Returns the zip-code field of this directory info block.
static DirInfo readDirInfo(ByteBlock block)
          Reads a directory information entry from the given block.
static DirInfo readDirInfo(ByteBlock block, int maxTlvs)
          Reads a directory information block from the given block, only reading the given number of TLV's from the block.
static DirInfo readDirInfo(TlvChain chain)
          Generates a DirInfo object from the TLV's in the given chain.
 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
 

Constructor Detail

DirInfo

protected DirInfo(java.lang.String sn,
                  java.lang.String email,
                  java.lang.String first,
                  java.lang.String middle,
                  java.lang.String last,
                  java.lang.String maiden,
                  java.lang.String nickname,
                  java.lang.String address,
                  java.lang.String city,
                  java.lang.String state,
                  java.lang.String zip,
                  java.lang.String country,
                  java.lang.String language,
                  int totalSize)
Creates a new directory info object with the given properties. Any of these fields can be null to avoid using the given field or to indicate that the given field was not included in the directory info block.

Parameters:
sn - the screenname having this directory information
email - the email address of this user
first - this user's first name
middle - the user's middle name
last - the user's last name
maiden - the user's maiden name
nickname - the user's nickname
address - the user's street address
city - the user's city of residence
state - the user's state of residence, in any format ("NY" and "New York" are both valid)
zip - the user's zip code
country - the user's country of residence, as a two-letter country code
language - the user's language, as a two-letter code such as "en" (for English)
totalSize - the total size of the directory information block, as read from some sort of stream or data block

DirInfo

public DirInfo(java.lang.String email,
               java.lang.String first,
               java.lang.String middle,
               java.lang.String last,
               java.lang.String maiden,
               java.lang.String nickname,
               java.lang.String address,
               java.lang.String city,
               java.lang.String state,
               java.lang.String zip,
               java.lang.String country,
               java.lang.String language)
Creates a new directory info object with the given properties and no associated screenname. This constructor should be used to create directory info blocks to be sent to the server by a client, as no screenname field is used in such a case. Any of these fields can be null to avoid sending the given field.

Parameters:
email - the email address of this user
first - this user's first name
middle - the user's middle name
last - the user's last name
maiden - the user's maiden name
nickname - the user's nickname
address - the user's street address
city - the user's city of residence
state - the user's state of residence, in any format ("NY" and "New York" are both valid)
zip - the user's zip code
country - the user's country of residence, as a two-letter country code
language - the user's language, as a two-letter code such as "en" (for English)

DirInfo

public DirInfo(java.lang.String sn,
               java.lang.String email,
               java.lang.String first,
               java.lang.String middle,
               java.lang.String last,
               java.lang.String maiden,
               java.lang.String nickname,
               java.lang.String address,
               java.lang.String city,
               java.lang.String state,
               java.lang.String zip,
               java.lang.String country,
               java.lang.String language)
Creates a new directory info object with the given properties. Any of these fields can be null to avoid sending the given field.

Parameters:
sn - the screenname holding this directory information
email - the email address of this user
first - this user's first name
middle - the user's middle name
last - the user's last name
maiden - the user's maiden name
nickname - the user's nickname
address - the user's street address
city - the user's city of residence
state - the user's state of residence, in any format ("NY" and "New York" are both valid)
zip - the user's zip code
country - the user's country of residence, as a two-letter country code
language - the user's language, as a two-letter code such as "en" (for English)
Method Detail

readDirInfo

public static DirInfo readDirInfo(ByteBlock block)
Reads a directory information entry from the given block. Equivalent to calling readDirInfo(TlvChain.readChain(block)). The total number of bytes read can be retrieved by calling getTotalSize on the returned object.

Parameters:
block - the data block containing directory information
Returns:
a directory information object generated from the data in the given block

readDirInfo

public static DirInfo readDirInfo(ByteBlock block,
                                  int maxTlvs)
Reads a directory information block from the given block, only reading the given number of TLV's from the block. (Directory info blocks consist of a series of TLV's.) Using this method is equivalent to calling readDirInfo(TlvChain.readChain(block, maxTlvs)). The total number of bytes read can be retrieved by calling getTotalSize on the returned object.

Parameters:
block - the block of data from which to read
maxTlvs - the maximum number of TLV's to read from the block
Returns:
a directory information object

readDirInfo

public static DirInfo readDirInfo(TlvChain chain)
Generates a DirInfo object from the TLV's in the given chain. (A directory info block consists solely of a series of TLV's.) Note that if no TLV's are present in the given chain, null is returned.

Parameters:
chain - the TLV chain containing directory information TLV's
Returns:
a directory information object generated from the TLV's in the given chain

getScreenname

public final java.lang.String getScreenname()
Returns the screenname holding this directory information.

Returns:
this directory information's associated screenname

getEmail

public final java.lang.String getEmail()
Returns the email address field of this directory info block.

Returns:
this directory info block's associated email address

getFirstname

public final java.lang.String getFirstname()
Returns the first-name field of this directory info block.

Returns:
this directory info block's associated first name

getMiddlename

public final java.lang.String getMiddlename()
Returns the middle-name field of this directory info block.

Returns:
this directory info block's associated middle name

getLastname

public final java.lang.String getLastname()
Returns the last-name field of this directory info block.

Returns:
this directory info block's associated last name

getMaiden

public final java.lang.String getMaiden()
Returns the maiden-name field of this directory info block.

Returns:
this directory info block's associated maiden name

getNickname

public final java.lang.String getNickname()
Returns the nickname field of this directory info block.

Returns:
this directory info block's associated nickname

getStreetAddress

public final java.lang.String getStreetAddress()
Returns the street-address field of this directory info block.

Returns:
this directory info block's associated street address

getCity

public final java.lang.String getCity()
Returns the city of residence field of this directory info block.

Returns:
this directory info block's associated city name

getState

public final java.lang.String getState()
Returns the state field of this directory info block. This may be in "NY" format or "New York" format, or actually any other format, as WinAIM allows the user to simply type it in.

Returns:
this directory info block's associated state of residence

getZip

public final java.lang.String getZip()
Returns the zip-code field of this directory info block.

Returns:
this directory info block's associated zip code

getCountryCode

public final java.lang.String getCountryCode()
Returns the country-code field of this directory info block. This will be a two-letter abbreviation like "US" or "CA".

Returns:
this directory info block's associated country code

getLanguageCode

public final java.lang.String getLanguageCode()
Returns the language-code field of this directory info block. This will be in a format like "en" (representing English).

Returns:
this directory info block's associated language code

getTotalSize

public final int getTotalSize()
Returns the total number of bytes this directory information object used when read from a byte block. Will be -1 if this info block was not read using any of the readDirInfo forms.

Returns:
the total size, in bytes, of this object, if read from a block of data

getTlvCount

public final int getTlvCount()
Returns the total number of TLV's that will be or have been written using write.

Returns:
the total number of TLV's that will be or have been written by invoking write

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