net.anidb.udp
Class UdpConnectionFactory

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

public class UdpConnectionFactory
extends java.lang.Object

Creates and organizes UDP connections to AniDB.

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

Field Summary
static java.lang.String HOST
          The standard host.
static int MAJOR_VERSION
          The major version of the Java AniDB API.
static int MINOR_VERSION
          The minor version of the Java AniDB API.
static int PORT
          The standard remote port.
static int TIMEOUT
          The connection timeout.
 
Method Summary
 UdpConnection connect(int localPort)
          Build a connection with the given local port.
 UdpConnection connect(int localPort, java.lang.String host, int remotePort)
          Build a connection with the given values.
 UdpConnection connect(int localPort, java.lang.String host, int remotePort, int timeout, boolean floodProtection)
          Build a connection with the given values.
static UdpConnectionFactory getInstance()
          Returns a instance of the class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HOST

public static final java.lang.String HOST
The standard host.

See Also:
Constant Field Values

PORT

public static final int PORT
The standard remote port.

See Also:
Constant Field Values

TIMEOUT

public static final int TIMEOUT
The connection timeout.

See Also:
Constant Field Values

MAJOR_VERSION

public static final int MAJOR_VERSION
The major version of the Java AniDB API.

See Also:
Constant Field Values

MINOR_VERSION

public static final int MINOR_VERSION
The minor version of the Java AniDB API.

See Also:
Constant Field Values
Method Detail

getInstance

public static UdpConnectionFactory getInstance()
Returns a instance of the class.

Returns:
The instance.

connect

public UdpConnection connect(int localPort,
                             java.lang.String host,
                             int remotePort,
                             int timeout,
                             boolean floodProtection)
                      throws UdpConnectionException

Build a connection with the given values.

For further information for the timeout see DatagramSocket.setSoTimeout(int).

Parameters:
localPort - The local port.
host - The host, normally HOST.
remotePort - The remote port, normally PORT.
timeout - The timeout in milliseconds.
floodProtection - The state of the flood protection.
Returns:
The connection.
Throws:
java.lang.IllegalArgumentException - If the local port is equal or less than 1024.
java.lang.IllegalArgumentException - If the host is null.
java.lang.IllegalArgumentException - If the timeout is less than 0.
UdpConnectionException - If a connection problem occured.
See Also:
UdpConnection.UdpConnection(DatagramSocket, boolean)

connect

public UdpConnection connect(int localPort,
                             java.lang.String host,
                             int remotePort)
                      throws UdpConnectionException

Build a connection with the given values.

For the timeout the standard value will be used.

The flood protection will be enabled.

Parameters:
localPort - The local port.
host - The host, normally HOST.
remotePort - The remote port, normally PORT.
Returns:
The connection.
Throws:
java.lang.IllegalArgumentException - If the local port is equal or less than 1024.
java.lang.IllegalArgumentException - If the host is null.
UdpConnectionException - If a connection problem occured.
See Also:
UdpConnection.UdpConnection(DatagramSocket, boolean)

connect

public UdpConnection connect(int localPort)
                      throws UdpConnectionException

Build a connection with the given local port.

For the host, the remote port and the timeout the standard values will be used.

The flood protection will be enabled.

Parameters:
localPort - The local port.
Returns:
The connection.
Throws:
java.lang.IllegalArgumentException - If the local port is equal or less than 1024.
UdpConnectionException - If a connection problem occured.
See Also:
UdpConnection.UdpConnection(DatagramSocket, boolean)