anon.infoservice
Class ListenerInterface

java.lang.Object
  extended by anon.infoservice.ListenerInterface
All Implemented Interfaces:
ImmutableListenerInterface, IXMLEncodable
Direct Known Subclasses:
ProxyInterface

public class ListenerInterface
extends java.lang.Object
implements ImmutableListenerInterface, IXMLEncodable

Saves the information about a network server.


Field Summary
private  boolean m_bUseInterface
          This describes, whether we can reach this interface or not.
private  int m_iInetPort
          This is the representation of the port of the ListenerInterface.
private  int m_iProtocolType
          This describes the protocol type.
private  java.lang.String m_strHostname
          This is the host of this interface (hostname or IP).
static int PORT_MAX_VALUE
           
static int PORT_MIN_VALUE
           
 
Fields inherited from interface anon.infoservice.ImmutableListenerInterface
PROTOCOL_STR_TYPE_HTTP, PROTOCOL_STR_TYPE_HTTPS, PROTOCOL_STR_TYPE_RAW_TCP, PROTOCOL_STR_TYPE_SOCKS, PROTOCOL_STR_TYPE_UNKNOWN, PROTOCOL_TYPE_HTTP, PROTOCOL_TYPE_HTTPS, PROTOCOL_TYPE_RAW_TCP, PROTOCOL_TYPE_SOCKS, PROTOCOL_TYPE_UNKNOWN
 
Fields inherited from interface anon.util.IXMLEncodable
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_VERSION
 
Constructor Summary
ListenerInterface(org.w3c.dom.Element listenerInterfaceNode)
          Creates a new ListenerInterface from XML description (ListenerInterface node).
ListenerInterface(java.lang.String a_hostname, int a_port)
          Creates a new ListenerInterface from a hostname / IP address and a port.
ListenerInterface(java.lang.String a_hostname, int a_port, int a_protocol)
          Creates a new ListenerInterface from a hostname / IP address, a port and a protocol information.
 
Method Summary
 boolean equals(ListenerInterface a_listenerInterface)
          Tests if two ListenerInterface instances are equal.
 java.lang.String getHost()
          Get the host (hostname or IP) of this interface as a String.
 int getPort()
          Get the port of this interface.
 int getProtocol()
          Gets the protocol of this ListenerInterface.
 java.lang.String getProtocolAsString()
          Gets the protocol of this ListenerInterface as String.
static java.lang.String getXMLElementName()
          Gets the name of the corresponding xml element.
 boolean isValid()
          Get the validity of this interface.
static boolean isValidHostname(java.lang.String a_hostname)
          Returns if the given host name is valid.
static boolean isValidIP(java.lang.String a_ipAddress)
          Returns if the given IP address is valid.
static boolean isValidPort(int a_port)
          Returns if the given port is valid.
static boolean isValidProtocol(int a_protocol)
          Returns if the given protocol is valid web protocol and can be recognized by recognizeProtocol().
static boolean isValidProtocol(java.lang.String a_protocol)
          Returns if the given protocol is valid web protocol and can be recognized by recognizeProtocol().
protected static int recognizeProtocol(int a_protocol)
          Transforms a given protocol into a valid protocol if recognized.
protected static int recognizeProtocol(java.lang.String a_protocol)
          Transforms a given protocol into a valid protocol if recognized.
 void setHostname(java.lang.String a_strHostname)
          Sets the host name.
 void setPort(int a_port)
          Sets the port number.
 void setProtocol(int a_protocol)
          Sets the protocol.
 void setProtocol(java.lang.String a_protocol)
          Sets the protocol.
 void setUseInterface(boolean a_bUseInterface)
          Sets if this interface is used or not.
 java.lang.String toString()
           
 java.util.Vector toVector()
          Creates a Vector of listeners with only the current listener.
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Creates an XML node without signature for this ListenerInterface..
protected  org.w3c.dom.Element toXmlElementInternal(org.w3c.dom.Document doc, java.lang.String a_strXmlElementName)
          Creates an XML node without signature for this ListenerInterface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PORT_MIN_VALUE

public static final int PORT_MIN_VALUE
See Also:
Constant Field Values

PORT_MAX_VALUE

public static final int PORT_MAX_VALUE
See Also:
Constant Field Values

m_strHostname

private java.lang.String m_strHostname
This is the host of this interface (hostname or IP).


m_iInetPort

private int m_iInetPort
This is the representation of the port of the ListenerInterface.


m_iProtocolType

private int m_iProtocolType
This describes the protocol type.


m_bUseInterface

private boolean m_bUseInterface
This describes, whether we can reach this interface or not. If we can't get a connection to this interface, we set it to false and so there are no more connection trys. The interface still remains in the database because others may get a connection to this interface (causes can be firewalls, another network, ...). This is only meaningful for non-local (remote) interfaces.

Constructor Detail

ListenerInterface

public ListenerInterface(org.w3c.dom.Element listenerInterfaceNode)
                  throws XMLParseException
Creates a new ListenerInterface from XML description (ListenerInterface node).

Parameters:
listenerInterfaceNode - The ListenerInterface node from an XML document.
Throws:
XMLParseException - if an error in the xml structure occurs

ListenerInterface

public ListenerInterface(java.lang.String a_hostname,
                         int a_port)
                  throws java.lang.IllegalArgumentException
Creates a new ListenerInterface from a hostname / IP address and a port. The protocol is set to HTTP/TCP.

Parameters:
a_hostname - The hostname or the IP address of this interface.
a_port - The port of this interface (1 <= port <= 65535).
Throws:
java.lang.IllegalArgumentException - if an illegal host name or port was given

ListenerInterface

public ListenerInterface(java.lang.String a_hostname,
                         int a_port,
                         int a_protocol)
                  throws java.lang.IllegalArgumentException
Creates a new ListenerInterface from a hostname / IP address, a port and a protocol information.

Parameters:
a_hostname - The hostname or the IP address of this interface.
a_port - The port of this interface (1 <= port <= 65535).
a_protocol - The protocol information. Invalid protocols are replaced by http.
Throws:
java.lang.IllegalArgumentException - if an illegal host name, port or protocol was given
Method Detail

getXMLElementName

public static java.lang.String getXMLElementName()
Gets the name of the corresponding xml element.

Returns:
the name of the corresponding xml element

isValidPort

public static boolean isValidPort(int a_port)
Returns if the given port is valid.

Parameters:
a_port - a port number
Returns:
true if the given port is valid; false otherwise

isValidProtocol

public static boolean isValidProtocol(java.lang.String a_protocol)
Returns if the given protocol is valid web protocol and can be recognized by recognizeProtocol().

Parameters:
a_protocol - a web protocol
Returns:
true if the given protocol is valid web protocol; false otherwise
See Also:
recognizeProtocol(String)

isValidProtocol

public static boolean isValidProtocol(int a_protocol)
Returns if the given protocol is valid web protocol and can be recognized by recognizeProtocol().

Parameters:
a_protocol - a web protocol
Returns:
true if the given protocol is valid web protocol; false otherwise
See Also:
recognizeProtocol(String)

isValidHostname

public static boolean isValidHostname(java.lang.String a_hostname)
Returns if the given host name is valid.

Parameters:
a_hostname - a host name
Returns:
true if the given host name is valid; false otherwise

isValidIP

public static boolean isValidIP(java.lang.String a_ipAddress)
Returns if the given IP address is valid.

Parameters:
a_ipAddress - an IP address
Returns:
true if the given IP address is valid; false otherwise

getProtocol

public int getProtocol()
Gets the protocol of this ListenerInterface.

Specified by:
getProtocol in interface ImmutableListenerInterface
Returns:
the protocol of this ListenerInterface

getProtocolAsString

public java.lang.String getProtocolAsString()
Gets the protocol of this ListenerInterface as String.

Returns:
the protocol of this ListenerInterface

getHost

public java.lang.String getHost()
Get the host (hostname or IP) of this interface as a String.

Specified by:
getHost in interface ImmutableListenerInterface
Returns:
The host of this interface.

getPort

public int getPort()
Get the port of this interface.

Specified by:
getPort in interface ImmutableListenerInterface
Returns:
The port of this interface.

equals

public boolean equals(ListenerInterface a_listenerInterface)
Tests if two ListenerInterface instances are equal.

Parameters:
a_listenerInterface - a ListenerInterface
Returns:
true if the two ListenerInterface instances are equal; false otherwise

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Creates an XML node without signature for this ListenerInterface..

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - The XML document, which is the environment for the created XML node.
Returns:
The ListenerInterface XML node.

setUseInterface

public void setUseInterface(boolean a_bUseInterface)
Sets if this interface is used or not. If it is not used, further connection retries are prevented.

Parameters:
a_bUseInterface - true if this interface is used; false otherwise

isValid

public boolean isValid()
Get the validity of this interface. If it is not valid, further connection retries are prevented.

Specified by:
isValid in interface ImmutableListenerInterface
Returns:
Whether this interface is valid or not.

recognizeProtocol

protected static int recognizeProtocol(java.lang.String a_protocol)
Transforms a given protocol into a valid protocol if recognized.

Parameters:
a_protocol - a protocol
Returns:
the protocol (my be transformed in some way) or PROTOCOL_TYPE_UNKNOWN if not recognized

recognizeProtocol

protected static int recognizeProtocol(int a_protocol)
Transforms a given protocol into a valid protocol if recognized.

Parameters:
a_protocol - a protocol
Returns:
the protocol (my be transformed in some way) or PROTOCOL_TYPE_UNKNOWN if not recognized

setProtocol

public void setProtocol(java.lang.String a_protocol)
Sets the protocol. If it is invalid, it is set to PROTOCOL_TYPE_RAW_TCP.

Parameters:
a_protocol - a protocol

setProtocol

public void setProtocol(int a_protocol)
Sets the protocol. If it is invalid, it is set to PROTOCOL_TYPE_RAW_TCP.

Parameters:
a_protocol - a protocol

setPort

public void setPort(int a_port)
Sets the port number.

Parameters:
a_port - a port number

setHostname

public void setHostname(java.lang.String a_strHostname)
Sets the host name.

Parameters:
a_strHostname - a host name

toVector

public java.util.Vector toVector()
Creates a Vector of listeners with only the current listener.

Returns:
a Vector of listeners with only the current listener

toXmlElementInternal

protected org.w3c.dom.Element toXmlElementInternal(org.w3c.dom.Document doc,
                                                   java.lang.String a_strXmlElementName)
Creates an XML node without signature for this ListenerInterface.

Parameters:
doc - The XML document, which is the environment for the created XML node.
a_strXmlElementName - the name of the xml element to create
Returns:
The ListenerInterface XML node.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object