net.anidb.udp
Class UdpConnection

java.lang.Object
  extended by net.anidb.udp.UdpConnection

public class UdpConnection
extends java.lang.Object

A connection to AniDB via UDP.

For further information on the UDP communication look at the UDP API Definition.

The flood protection limits the packets / requests per minute:


If you turn off the flood protection you have take care of it by yourself.
See also: Flood Protection

Version:
1.0, 29.11.2009, 1.1, 22.03.2010
Author:
grizzlyxp (http://anidb.net/perl-bin/animedb.pl?show=userpage&uid=63935)

Field Summary
static java.lang.String CLIENT_NAME
          The client name of the Java AniDB API.
static int CLIENT_VERSION
          The client version of this version of the Java AniDB API.
static int MAXMIMUM_NUMBER_OF_BONUS_PACKETS
          The maximum number of bonus packets.
static int PROTOCOL_VERSION
          The supported protocol version.
static int TIME_BETWEEN_BONUS_PACKETS
          The time between the bonus packets in milliseconds.
static int TIME_BETWEEN_NORMAL_PACKETS
          The time between normal packets in milliseconds.
 
Method Summary
 void acknowledgeNotification(NotificationListEntry listEntry)
          Acknowledges the notification for the given list entry.
 void acknowledgeNotification(java.lang.String type, long id)
          Acknowledges the notification for the given type and Id.
 void authenticate(java.lang.String username, java.lang.String password)
          Authenticates the user and client to AniDB.
 void authenticate(java.lang.String username, java.lang.String password, java.lang.String clientname, int clientversion)
          Authenticates the user and client to AniDB.
 void close()
          Closes the connection.
 Anime getAnime(long animeId)
          Returns the anime with the given Id.
 Anime getAnime(long animeId, AnimeMask mask)
          Returns the anime with the given Id.
 Anime getAnime(java.lang.String animeName)
          Returns the anime with the given name.
 Anime getAnime(java.lang.String animeName, AnimeMask mask)
          Returns the anime with the given name.
 java.lang.String getAnimeDescription(long animeId)
          Returns the description for the anime with the given Id.
 Character getCharacter(long characterId)
          Returns the character with the given character Id.
 Creator getCreator(long creatorId)
          Returns the creator with the given creator Id.
 java.nio.charset.Charset getCurrentEncoding()
          Returns the charset which is currently used for encoding.
 Episode getEpisode(long episodeId)
          Returns the episode with the given Id.
 Episode getEpisode(long animeId, long episodeNumber)
          Returns the episode with the given anime Id and episode number.
 Episode getEpisode(java.lang.String animeName, long episodeNumber)
          Returns the episode with the given anime name and episode number.
 File getFile(long fileId, FileMask fileMask, AnimeFileMask animeFileMask)
          Returns the file with the given Id.
 java.util.List<File> getFiles(long animeId, long groupId, long episodeNumber, FileMask fileMask, AnimeFileMask animeFileMask)
          Returns the files with the given anime Id, group Id and episode number.
 java.util.List<File> getFiles(long size, java.lang.String ed2kHash, FileMask fileMask, AnimeFileMask animeFileMask)
          Returns the files with the given size and ed2k hash.
 java.util.List<File> getFiles(long animeId, java.lang.String groupName, long episodeNumber, FileMask fileMask, AnimeFileMask animeFileMask)
          Returns the files with the given anime Id, group name and episode number.
 java.util.List<File> getFiles(java.lang.String animeName, long groupId, long episodeNumber, FileMask fileMask, AnimeFileMask animeFileMask)
          Returns the files with the given anime name, group Id and episode number.
 java.util.List<File> getFiles(java.lang.String animeName, java.lang.String groupName, long episodeNumber, FileMask fileMask, AnimeFileMask animeFileMask)
          Returns the files with the given anime name, group name and episode number.
 Group getGroup(long groupId)
          Returns the group with the given group Id.
 Group getGroup(java.lang.String groupName)
          Returns the group with the given group name or short name.
 java.util.List<GroupStatus> getGroupStatus(long animeId)
          Returns a list of the group status for the anime with the given anime Id.
 java.util.List<GroupStatus> getGroupStatus(long animeId, GroupStatusState state)
          Returns a list of the group status for the anime with the given anime Id and the given state.
 Notification getNotification(NotificationListEntry listEntry)
          Returns the notification for the given list entry.
 Notification getNotification(java.lang.String type, long id)
          Returns the notification for the given type and Id.
 java.util.List<NotificationListEntry> getNotifyList()
          Returns a list of entries of all pending (not acknowledged) new private message and new file notifications.
 java.nio.charset.Charset getPreferredEncoding()
          Returns the preferred charset for encoding.
 java.lang.String getServerVersion()
          Returns the server version.
 long getUptime()
          Returns the UDP server uptime in milliseconds.
 long getUserId(java.lang.String userName)
          Returns the user Id for the user with the given user name.
 boolean isLoggedIn()
          Return the state if the client is logged in.
 boolean isOpen()
          Return the state if connection is open.
 void logout()
          Logs the client out.
 void ping()
          Sends a ping to a server.
 void sendMessage(java.lang.String userName, java.lang.String title, java.lang.String body)
          Sends a message to the user with the given user name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL_VERSION

public static final int PROTOCOL_VERSION
The supported protocol version.

See Also:
Constant Field Values

MAXMIMUM_NUMBER_OF_BONUS_PACKETS

public static final int MAXMIMUM_NUMBER_OF_BONUS_PACKETS
The maximum number of bonus packets.

See Also:
Constant Field Values

TIME_BETWEEN_BONUS_PACKETS

public static final int TIME_BETWEEN_BONUS_PACKETS
The time between the bonus packets in milliseconds.

See Also:
Constant Field Values

TIME_BETWEEN_NORMAL_PACKETS

public static final int TIME_BETWEEN_NORMAL_PACKETS
The time between normal packets in milliseconds.

See Also:
Constant Field Values

CLIENT_NAME

public static final java.lang.String CLIENT_NAME
The client name of the Java AniDB API.

See Also:
Constant Field Values

CLIENT_VERSION

public static final int CLIENT_VERSION
The client version of this version of the Java AniDB API.

See Also:
Constant Field Values
Method Detail

isOpen

public boolean isOpen()
Return the state if connection is open.

Returns:
The state: true, if the connection is currently open, otherwise false.

close

public void close()
           throws UdpConnectionException,
                  AniDbException

Closes the connection.

If the client is not logged out, a logout will be performed. And if there any problems the logout will raise an exception. In spite of that the connection will be closed by all means.

Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
logout()

isLoggedIn

public boolean isLoggedIn()
Return the state if the client is logged in.

Returns:
The state: true, if the client is currently logged in, otherwise false.

getCurrentEncoding

public java.nio.charset.Charset getCurrentEncoding()

Returns the charset which is currently used for encoding.

At the beginning of a connection the charset US-ASCII will be used - as defined in the API documentation. If you don't specify any encoding at the AUTHENTICATE command, the preferred charset will be used after that command.

Remark: In the current version of this class you can't specifiy a encoding at the AUTHENTICATE command. This will be implemented later on.

Returns:
The charset.
See Also:
getPreferredEncoding(), authenticate(String, String), authenticate(String, String, String, int)

getPreferredEncoding

public java.nio.charset.Charset getPreferredEncoding()

Returns the preferred charset for encoding.

If you don't specify any encoding at the AUTHENTICATE command, this charset will be used. But please keep in mind that the used charset at the beginning of a connection is allways US-ASCII - as defined in the API documentation.

Remark: In the current version of this class you can't specifiy a encoding at the AUTHENTICATE command. This will be implemented later on.

Returns:
The charset.
See Also:
getCurrentEncoding(), authenticate(String, String), authenticate(String, String, String, int)

authenticate

public void authenticate(java.lang.String username,
                         java.lang.String password)
                  throws UdpConnectionException,
                         AniDbException
Authenticates the user and client to AniDB.

Parameters:
username - The username.
password - The password.
Throws:
java.lang.IllegalArgumentException - If the username is null.
java.lang.IllegalArgumentException - If the password is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.LOGIN_ACCEPTED, UdpReturnCodes.LOGIN_ACCEPTED_NEW_VER, UdpReturnCodes.LOGIN_FAILED, UdpReturnCodes.ACCESS_DENIED, UdpReturnCodes.CLIENT_VERSION_OUTDATED, UdpReturnCodes.CLIENT_BANNED, UdpReturnCodes.ILLEGAL_INPUT_OR_ACCESS_DENIED, UdpReturnCodes.ANIDB_OUT_OF_SERVICE

authenticate

public void authenticate(java.lang.String username,
                         java.lang.String password,
                         java.lang.String clientname,
                         int clientversion)
                  throws UdpConnectionException,
                         AniDbException
Authenticates the user and client to AniDB.

Parameters:
username - The username.
password - The password.
clientname - The name of the client.
clientversion - The version of the client.
Throws:
java.lang.IllegalArgumentException - If the username is null.
java.lang.IllegalArgumentException - If the password is null.
java.lang.IllegalArgumentException - If the client name is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.LOGIN_ACCEPTED, UdpReturnCodes.LOGIN_ACCEPTED_NEW_VER, UdpReturnCodes.LOGIN_FAILED, UdpReturnCodes.ACCESS_DENIED, UdpReturnCodes.CLIENT_VERSION_OUTDATED, UdpReturnCodes.CLIENT_BANNED, UdpReturnCodes.ILLEGAL_INPUT_OR_ACCESS_DENIED, UdpReturnCodes.ANIDB_OUT_OF_SERVICE

logout

public void logout()
            throws UdpConnectionException,
                   AniDbException

Logs the client out.

If client is currently not logged in, an exception will be thrown.

Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.

ping

public void ping()
          throws UdpConnectionException,
                 AniDbException

Sends a ping to a server.

If the server doesn't respond, an exception will be thrown.

Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.

getServerVersion

public java.lang.String getServerVersion()
                                  throws UdpConnectionException,
                                         AniDbException
Returns the server version.

Returns:
The version.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.

getUptime

public long getUptime()
               throws UdpConnectionException,
                      AniDbException

Returns the UDP server uptime in milliseconds.

If client is currently not logged in, an exception will be thrown.

Returns:
The uptime.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.

getAnime

public Anime getAnime(long animeId)
               throws UdpConnectionException,
                      AniDbException
Returns the anime with the given Id.

Parameters:
animeId - The anime Id.
Returns:
The anime.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ANIME

getAnime

public Anime getAnime(java.lang.String animeName)
               throws UdpConnectionException,
                      AniDbException
Returns the anime with the given name.

Parameters:
animeName - The anime name.
Returns:
The anime.
Throws:
java.lang.IllegalArgumentException - If the anime name is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ANIME

getAnime

public Anime getAnime(long animeId,
                      AnimeMask mask)
               throws UdpConnectionException,
                      AniDbException

Returns the anime with the given Id.

Only the fields specified by the mask will be filled.

Parameters:
animeId - The anime Id.
mask - The mask.
Returns:
The anime.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ANIME

getAnime

public Anime getAnime(java.lang.String animeName,
                      AnimeMask mask)
               throws UdpConnectionException,
                      AniDbException

Returns the anime with the given name.

Only the fields specified by the mask will be filled.

Parameters:
animeName - The anime name.
mask - The mask.
Returns:
The anime.
Throws:
java.lang.IllegalArgumentException - If the anime name is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ANIME

getAnimeDescription

public java.lang.String getAnimeDescription(long animeId)
                                     throws UdpConnectionException,
                                            AniDbException

Returns the description for the anime with the given Id.

It should be considered that this method has to use more than one request for retrieving the complete description. The reason is that a descrption can take up to ~5000 characters while the maximum data of an UDP packet is ~1400 bytes.

Parameters:
animeId - The anime Id.
Returns:
The description.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ANIME, UdpReturnCodes.NO_SUCH_ANIME_DESCRIPTION

getEpisode

public Episode getEpisode(long episodeId)
                   throws UdpConnectionException,
                          AniDbException
Returns the episode with the given Id.

Parameters:
episodeId - The episode Id.
Returns:
The episode.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_EPISODE

getEpisode

public Episode getEpisode(java.lang.String animeName,
                          long episodeNumber)
                   throws UdpConnectionException,
                          AniDbException
Returns the episode with the given anime name and episode number.

Parameters:
animeName - The anime name.
episodeNumber - The episode number.
Returns:
The episode.
Throws:
java.lang.IllegalArgumentException - If the anime name is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_EPISODE

getEpisode

public Episode getEpisode(long animeId,
                          long episodeNumber)
                   throws UdpConnectionException,
                          AniDbException
Returns the episode with the given anime Id and episode number.

Parameters:
animeId - The anime Id.
episodeNumber - The episode number.
Returns:
The episode.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_EPISODE

getFile

public File getFile(long fileId,
                    FileMask fileMask,
                    AnimeFileMask animeFileMask)
             throws UdpConnectionException,
                    AniDbException

Returns the file with the given Id.

Only the fields specified by the two masks will be filled.

Parameters:
fileId - The file Id.
fileMask - The file mask.
animeFileMask - The anime file mask.
Returns:
The file.
Throws:
java.lang.IllegalArgumentException - If the file mask is null.
java.lang.IllegalArgumentException - If the anime file mask is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_FILE

getFiles

public java.util.List<File> getFiles(long size,
                                     java.lang.String ed2kHash,
                                     FileMask fileMask,
                                     AnimeFileMask animeFileMask)
                              throws UdpConnectionException,
                                     AniDbException

Returns the files with the given size and ed2k hash.

Only the fields specified by the two masks will be filled.

Parameters:
size - The size.
ed2kHash - The ed2k hash.
fileMask - The file mask.
animeFileMask - The anime file mask.
Returns:
The files.
Throws:
java.lang.IllegalArgumentException - If the size is less than 1.
java.lang.IllegalArgumentException - If the ed2k hash is null.
java.lang.IllegalArgumentException - If the file mask is null.
java.lang.IllegalArgumentException - If the anime file mask is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_FILE

getFiles

public java.util.List<File> getFiles(java.lang.String animeName,
                                     java.lang.String groupName,
                                     long episodeNumber,
                                     FileMask fileMask,
                                     AnimeFileMask animeFileMask)
                              throws UdpConnectionException,
                                     AniDbException

Returns the files with the given anime name, group name and episode number.

Only the fields specified by the two masks will be filled.

Parameters:
animeName - The anime name.
groupName - The group name.
episodeNumber - The episode number.
fileMask - The file mask.
animeFileMask - The anime file mask.
Returns:
The files.
Throws:
java.lang.IllegalArgumentException - If the anime name is null.
java.lang.IllegalArgumentException - If the group name is null.
java.lang.IllegalArgumentException - If the file mask is null.
java.lang.IllegalArgumentException - If the anime file mask is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_FILE

getFiles

public java.util.List<File> getFiles(java.lang.String animeName,
                                     long groupId,
                                     long episodeNumber,
                                     FileMask fileMask,
                                     AnimeFileMask animeFileMask)
                              throws UdpConnectionException,
                                     AniDbException

Returns the files with the given anime name, group Id and episode number.

Only the fields specified by the two masks will be filled.

Parameters:
animeName - The anime name.
groupId - The group Id.
episodeNumber - The episode number.
fileMask - The file mask.
animeFileMask - The anime file mask.
Returns:
The files.
Throws:
java.lang.IllegalArgumentException - If the anime name is null.
java.lang.IllegalArgumentException - If the file mask is null.
java.lang.IllegalArgumentException - If the anime file mask is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_FILE

getFiles

public java.util.List<File> getFiles(long animeId,
                                     java.lang.String groupName,
                                     long episodeNumber,
                                     FileMask fileMask,
                                     AnimeFileMask animeFileMask)
                              throws UdpConnectionException,
                                     AniDbException

Returns the files with the given anime Id, group name and episode number.

Only the fields specified by the two masks will be filled.

Parameters:
animeId - The anime Id.
groupName - The group name.
episodeNumber - The episode number.
fileMask - The file mask.
animeFileMask - The anime file mask.
Returns:
The files.
Throws:
java.lang.IllegalArgumentException - If the group name is null.
java.lang.IllegalArgumentException - If the file mask is null.
java.lang.IllegalArgumentException - If the anime file mask is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_FILE

getFiles

public java.util.List<File> getFiles(long animeId,
                                     long groupId,
                                     long episodeNumber,
                                     FileMask fileMask,
                                     AnimeFileMask animeFileMask)
                              throws UdpConnectionException,
                                     AniDbException

Returns the files with the given anime Id, group Id and episode number.

Only the fields specified by the two masks will be filled.

Parameters:
animeId - The anime Id.
groupId - The group Id.
episodeNumber - The episode number.
fileMask - The file mask.
animeFileMask - The anime file mask.
Returns:
The files.
Throws:
java.lang.IllegalArgumentException - If the file mask is null.
java.lang.IllegalArgumentException - If the anime file mask is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_FILE

getGroup

public Group getGroup(long groupId)
               throws UdpConnectionException,
                      AniDbException
Returns the group with the given group Id.

Parameters:
groupId - The group Id.
Returns:
The group.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_GROUP

getGroup

public Group getGroup(java.lang.String groupName)
               throws UdpConnectionException,
                      AniDbException
Returns the group with the given group name or short name.

Parameters:
groupName - The group name or short name.
Returns:
The group.
Throws:
java.lang.IllegalArgumentException - If the group name is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_GROUP

getGroupStatus

public java.util.List<GroupStatus> getGroupStatus(long animeId)
                                           throws UdpConnectionException,
                                                  AniDbException

Returns a list of the group status for the anime with the given anime Id.

Parameters:
animeId - The anime Id.
Returns:
The list of the group status.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_GROUPS_FOUND, UdpReturnCodes.NO_SUCH_ANIME

getGroupStatus

public java.util.List<GroupStatus> getGroupStatus(long animeId,
                                                  GroupStatusState state)
                                           throws UdpConnectionException,
                                                  AniDbException

Returns a list of the group status for the anime with the given anime Id and the given state.

Parameters:
animeId - The anime Id.
state - The state.
Returns:
The list of the group status.
Throws:
java.lang.IllegalArgumentException - If the state is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_GROUPS_FOUND, UdpReturnCodes.NO_SUCH_ANIME

getCreator

public Creator getCreator(long creatorId)
                   throws UdpConnectionException,
                          AniDbException
Returns the creator with the given creator Id.

Parameters:
creatorId - The creator Id.
Returns:
The creator.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_CREATOR

getCharacter

public Character getCharacter(long characterId)
                       throws UdpConnectionException,
                              AniDbException
Returns the character with the given character Id.

Parameters:
characterId - The character Id.
Returns:
The character.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_CHARACTER

getNotifyList

public java.util.List<NotificationListEntry> getNotifyList()
                                                    throws UdpConnectionException,
                                                           AniDbException

Returns a list of entries of all pending (not acknowledged) new private message and new file notifications.

Buddy events cannot be acknowledged.

Returns:
The list.
Throws:
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.

getNotification

public Notification getNotification(NotificationListEntry listEntry)
                             throws UdpConnectionException,
                                    AniDbException
Returns the notification for the given list entry.

Parameters:
listEntry - The list entry.
Returns:
The notification.
Throws:
java.lang.IllegalArgumentException - If the list entry is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_MESSAGE, UdpReturnCodes.NO_SUCH_NOTIFY

getNotification

public Notification getNotification(java.lang.String type,
                                    long id)
                             throws UdpConnectionException,
                                    AniDbException
Returns the notification for the given type and Id.

Parameters:
type - The type.
id - The Id.
Returns:
The notification.
Throws:
java.lang.IllegalArgumentException - If the type is null or the given type isn't supported.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_MESSAGE, UdpReturnCodes.NO_SUCH_NOTIFY

acknowledgeNotification

public void acknowledgeNotification(NotificationListEntry listEntry)
                             throws UdpConnectionException,
                                    AniDbException
Acknowledges the notification for the given list entry.

Parameters:
listEntry - The list entry.
Throws:
java.lang.IllegalArgumentException - If the list entry is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ENTRY_M, UdpReturnCodes.NO_SUCH_ENTRY_N

acknowledgeNotification

public void acknowledgeNotification(java.lang.String type,
                                    long id)
                             throws UdpConnectionException,
                                    AniDbException
Acknowledges the notification for the given type and Id.

Parameters:
type - The type.
id - The Id.
Throws:
java.lang.IllegalArgumentException - If the type is null or the given type isn't supported.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_ENTRY_M, UdpReturnCodes.NO_SUCH_ENTRY_N

sendMessage

public void sendMessage(java.lang.String userName,
                        java.lang.String title,
                        java.lang.String body)
                 throws UdpConnectionException,
                        AniDbException
Sends a message to the user with the given user name.

Parameters:
userName - The user name.
title - The title.
body - The body.
Throws:
java.lang.IllegalArgumentException - If the user name is null.
java.lang.IllegalArgumentException - If the title is null or has more than 50 chars.
java.lang.IllegalArgumentException - If the body is null or has more than 900 chars.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.SENDMSG_SUCCESSFUL, UdpReturnCodes.NO_SUCH_USER, UdpReturnCodes.LOGIN_FIRST

getUserId

public long getUserId(java.lang.String userName)
               throws UdpConnectionException,
                      AniDbException
Returns the user Id for the user with the given user name.

Parameters:
userName - The user name.
Returns:
The user Id.
Throws:
java.lang.IllegalArgumentException - If the user name is null.
UdpConnectionException - If a connection problem occured.
AniDbException - If a problem with AniDB occured.
See Also:
UdpReturnCodes.NO_SUCH_USER