forward.client
Class ForwarderInformationGrabber

java.lang.Object
  extended by forward.client.ForwarderInformationGrabber

public class ForwarderInformationGrabber
extends java.lang.Object

This class provides some tools for the forwarding client to fetch and handle the information about a forwarder.


Field Summary
private  IImageEncodedCaptcha m_captcha
          This stores the captcha, if we have successfully parsed the forwarder information.
private  int m_errorCode
          This stores the error (if any) which occured, while the information was fetched or parsed.
static int RETURN_INFOSERVICE_ERROR
          This is the error code indicating that there was an error while fetching the data directly from the infoservice.
static int RETURN_NO_CAPTCHA_IMPLEMENTATION
          This error occurs, if we don't know the captcha format which is used by the fetched forwarder information structure.
static int RETURN_SUCCESS
          This is the error code indicating that everything was fine.
static int RETURN_UNKNOWN_ERROR
          This error code indicates, that there was an unexpected error, maybe the data fetched are in the wrong format.
 
Constructor Summary
ForwarderInformationGrabber()
          Creates a new ForwarderInformationGrabber and tries to fetch the information about a forwarder from the infoservices.
ForwarderInformationGrabber(java.lang.String a_xmlData)
          Creates a new ForwarderInformationGrabber instance and parses the supplied information structure.
 
Method Summary
private  int findCaptchaImplementation(org.w3c.dom.Element a_captchaEncodedNode)
          Finds the correct captcha implementation for the supplied captcha.
 IImageEncodedCaptcha getCaptcha()
          Returns the structure which includes the captcha with the forwarder information.
 int getErrorCode()
          Returns the error code which may occured while creating this instance of ForwarderInformationGrabber.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RETURN_SUCCESS

public static final int RETURN_SUCCESS
This is the error code indicating that everything was fine.

See Also:
Constant Field Values

RETURN_INFOSERVICE_ERROR

public static final int RETURN_INFOSERVICE_ERROR
This is the error code indicating that there was an error while fetching the data directly from the infoservice. This can happen, if we cannot reach any infoservice or if no infoservice knows any forwarder.

See Also:
Constant Field Values

RETURN_UNKNOWN_ERROR

public static final int RETURN_UNKNOWN_ERROR
This error code indicates, that there was an unexpected error, maybe the data fetched are in the wrong format.

See Also:
Constant Field Values

RETURN_NO_CAPTCHA_IMPLEMENTATION

public static final int RETURN_NO_CAPTCHA_IMPLEMENTATION
This error occurs, if we don't know the captcha format which is used by the fetched forwarder information structure.

See Also:
Constant Field Values

m_errorCode

private int m_errorCode
This stores the error (if any) which occured, while the information was fetched or parsed.


m_captcha

private IImageEncodedCaptcha m_captcha
This stores the captcha, if we have successfully parsed the forwarder information.

Constructor Detail

ForwarderInformationGrabber

public ForwarderInformationGrabber()
Creates a new ForwarderInformationGrabber and tries to fetch the information about a forwarder from the infoservices. Check the getErrorCode() method after the instance is constructed to see, if there occured any error. If no error occured, you can get the fetched information via the getCaptcha() method. The following error codes can occur: RETURN_SUCCESS, RETURN_INFOSERVICE_ERROR, RETURN_UNKNOWN_ERROR or RETURN_NO_CAPTCHA_IMPLEMENTATION.


ForwarderInformationGrabber

public ForwarderInformationGrabber(java.lang.String a_xmlData)
Creates a new ForwarderInformationGrabber instance and parses the supplied information structure. Check the getErrorCode() method after the instance is constructed to see, if there occured any error. If no error occured, you can get the parsed information via the getCaptcha() method. The following error codes can occur: RETURN_SUCCESS, RETURN_UNKNOWN_ERROR or RETURN_NO_CAPTCHA_IMPLEMENTATION.

Parameters:
a_xmlData - The XML structure with the JapForwarder node, like it is distribute from the infoservices with the getforwarder command.
Method Detail

getErrorCode

public int getErrorCode()
Returns the error code which may occured while creating this instance of ForwarderInformationGrabber. See the RETURN constants in this class.

Returns:
The error code of the constructor of this instance.

getCaptcha

public IImageEncodedCaptcha getCaptcha()
Returns the structure which includes the captcha with the forwarder information. The value may be null, if there occured an error while constucting this instance of ForwarderInformationGrabber. So check getErrorCode() always first.

Returns:
The structure with the information about a forwarder, secured by a captcha.

findCaptchaImplementation

private int findCaptchaImplementation(org.w3c.dom.Element a_captchaEncodedNode)
Finds the correct captcha implementation for the supplied captcha. We use the CaptchaDataFormat node of the supplied structure to search matching local implementations.

Parameters:
a_captchaEncodedNode - The CaptchaEncodedNode which holds all needed information.
Returns:
RETURN_SUCCESS, if we have found a matching implementation. Also the internal storage of the captcha is updated. RETURN_NO_CAPTCHA_IMPLEMENTATION, if we could not find a matching captcha implementation. RETURN_UNKNOWN_ERROR, if there occured an unexpected error, maybe because of invalid data in the supplied structure.