|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.anidb.udp.UdpConnection
public class UdpConnection
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:
AUTH
, NOTIFY
and BUDDYLIST
.
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 |
NUMBER_OF_PACKETS_AFTER_START
The number of packets in the beginning. |
static int |
PROTOCOL_VERSION
The supported protocol version. |
static int |
TIME_BETWEEN_NORMAL_PACKETS
The time between normal packets in milliseconds. |
static int |
TIME_BETWEEN_STARTING_PACKETS
The time between the starting packets in milliseconds. |
Method Summary | |
---|---|
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,
AnimeMask mask)
Returns the anime with the given Id. |
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. |
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. |
java.lang.String |
getServerVersion()
Returns the server version. |
long |
getUptime()
Returns the UDP server uptime in milliseconds. |
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PROTOCOL_VERSION
public static final int NUMBER_OF_PACKETS_AFTER_START
public static final int TIME_BETWEEN_STARTING_PACKETS
public static final int TIME_BETWEEN_NORMAL_PACKETS
public static final java.lang.String CLIENT_NAME
public static final int CLIENT_VERSION
Method Detail |
---|
public boolean isOpen()
true
, if the connection is currently
open, otherwise false
.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.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.logout()
public boolean isLoggedIn()
true
, if the client is currently logged
in, otherwise false
.public void authenticate(java.lang.String username, java.lang.String password) throws UdpConnectionException, AniDbException
username
- The username.password
- The password.
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.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
public void authenticate(java.lang.String username, java.lang.String password, java.lang.String clientname, int clientversion) throws UdpConnectionException, AniDbException
username
- The username.password
- The password.clientname
- The name of the client.clientversion
- The version of the client.
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.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
public void logout() throws UdpConnectionException, AniDbException
Logs the client out.
If client is currently not logged in, an exception will be thrown.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.public void ping() throws UdpConnectionException, AniDbException
Sends a ping to a server.
If the server doesn't respond, an exception will be thrown.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.public java.lang.String getServerVersion() throws UdpConnectionException, AniDbException
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.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.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.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.
animeId
- The anime Id.mask
- The mask.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_ANIME
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.
animeName
- The anime name.mask
- The mask.
java.lang.IllegalArgumentException
- If the anime name is null
.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_ANIME
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.
animeId
- The anime Id.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_ANIME
,
UdpReturnCodes.NO_SUCH_ANIME_DESCRIPTION
public Episode getEpisode(long episodeId) throws UdpConnectionException, AniDbException
episodeId
- The episode Id.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_EPISODE
public Episode getEpisode(java.lang.String animeName, long episodeNumber) throws UdpConnectionException, AniDbException
animeName
- The anime name.episodeNumber
- The episode number.
java.lang.IllegalArgumentException
- If the anime name is null
.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_EPISODE
public Episode getEpisode(long animeId, long episodeNumber) throws UdpConnectionException, AniDbException
animeId
- The anime Id.episodeNumber
- The episode number.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_EPISODE
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.
fileId
- The file Id.fileMask
- The file mask.animeFileMask
- The anime file mask.
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.UdpReturnCodes.NO_SUCH_FILE
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.
size
- The size.ed2kHash
- The ed2k hash.fileMask
- The file mask.animeFileMask
- The anime file mask.
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.UdpReturnCodes.NO_SUCH_FILE
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.
animeName
- The anime name.groupName
- The group name.episodeNumber
- The episode number.fileMask
- The file mask.animeFileMask
- The anime file mask.
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.UdpReturnCodes.NO_SUCH_FILE
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.
animeName
- The anime name.groupId
- The group Id.episodeNumber
- The episode number.fileMask
- The file mask.animeFileMask
- The anime file mask.
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.UdpReturnCodes.NO_SUCH_FILE
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.
animeId
- The anime Id.groupName
- The group name.episodeNumber
- The episode number.fileMask
- The file mask.animeFileMask
- The anime file mask.
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.UdpReturnCodes.NO_SUCH_FILE
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.
animeId
- The anime Id.groupId
- The group Id.episodeNumber
- The episode number.fileMask
- The file mask.animeFileMask
- The anime file mask.
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.UdpReturnCodes.NO_SUCH_FILE
public Group getGroup(long groupId) throws UdpConnectionException, AniDbException
groupId
- The group Id.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_GROUP
public Group getGroup(java.lang.String groupName) throws UdpConnectionException, AniDbException
groupName
- The group name or short name.
java.lang.IllegalArgumentException
- If the group name is null
.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_GROUP
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.
animeId
- The anime Id.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_GROUPS_FOUND
,
UdpReturnCodes.NO_SUCH_ANIME
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.
animeId
- The anime Id.state
- The state.
java.lang.IllegalArgumentException
- If the state is null
.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_GROUPS_FOUND
,
UdpReturnCodes.NO_SUCH_ANIME
public Creator getCreator(long creatorId) throws UdpConnectionException, AniDbException
creatorId
- The creator Id.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_PRODUCER
public Character getCharacter(long characterId) throws UdpConnectionException, AniDbException
characterId
- The character Id.
UdpConnectionException
- If a connection problem occured.
AniDbException
- If a problem with AniDB occured.UdpReturnCodes.NO_SUCH_CHARACTER
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |