webfunds.sox
Class Reply

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.Reply
Direct Known Subclasses:
DepositReply, MailReply, NymReply, RegisterReply, TimeSyncReply

public abstract class Reply
extends Encodable

This class is the abstract base class for all reply classes.

See Also:
Serialized Form

Field Summary
protected  int errorNumber
          If the request failed, an error number will be assigned.
protected  java.lang.String errorText
          At the server's discretion, explanatory strings may be returned.
protected  int req_version
          Initialised to the Request version number.
protected  java.lang.String requestId
          An identifier for the request, used to pair up replys with requests when used over connectionless transport layers.
protected  int sub_version
          Initialised to the extending request version number.
 
Constructor Summary
protected Reply(Request request)
          Create a reply
protected Reply(Request request, byte[] replyData)
          Construct a reply object from a byte array that was previously returned from the encode() method of a reply object.
protected Reply(Request request, java.io.InputStream is)
          Construct a reply object from an input stream that was previously constructed from the encode() output of a reply object.
protected Reply(Request request, int errNum)
          Create a reply, with an error number.
 
Method Summary
 void addErrorText(java.lang.String s)
          Append a new error.
 void decode(java.io.InputStream is)
          Update this reply object with the data read from an inputstream, where the data on the stream was previously written using the encode() method of a reply object.
 void encode(java.io.OutputStream os)
          Encode a reply to an output stream, suitable for using with ReplyPacket to send remote servers (which use the decode() method to re-construct the object).
 boolean equals(java.lang.Object obj)
           
 int getErrorNumber()
          Get the error code.
 java.lang.String getErrorText()
          Get the string that the server returned.
 java.lang.String getRequestId()
          Get the identifier for the request which this is a reply for., Note: although a java String is used, this identifier should only contain 8-bit ascii characters.
 java.lang.String toString()
          Convert this object to a human readable string
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, main, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

req_version

protected int req_version
Initialised to the Request version number.

sub_version

protected int sub_version
Initialised to the extending request version number.

requestId

protected java.lang.String requestId
An identifier for the request, used to pair up replys with requests when used over connectionless transport layers. Note: although we use a java String, this identifier should only contain 8-bit ascii characters.

errorNumber

protected int errorNumber
If the request failed, an error number will be assigned. Some error numbers can be used to take remedial action, such as registering a key that is not currently registered. Most cannot be dealt with at run time, only by the server operator or programmer.

errorText

protected java.lang.String errorText
At the server's discretion, explanatory strings may be returned. If not, the Errors.java file also supplies strings for the various error codes in errorNumber. Sometimes, a string is supplied even when errorNumber == 0, where there is an interesting condition. This can be ignored.
Constructor Detail

Reply

protected Reply(Request request,
                int errNum)
Create a reply, with an error number.
Parameters:
request - the request to which this is a reply
errNum - the error number

Reply

protected Reply(Request request)
Create a reply
Parameters:
request - the request to which this is a reply

Reply

protected Reply(Request request,
                byte[] replyData)
         throws SOXPacketException
Construct a reply object from a byte array that was previously returned from the encode() method of a reply object. This is the usual method of constructing a reply object for SOX clients, and is done using data received from the server. The reply is expected to be for the supplied request and is required so that the correct version of the reply can be invoked.
Parameters:
request - the request that elicited this reply
replyData - the previously encoded reply

Reply

protected Reply(Request request,
                java.io.InputStream is)
         throws SOXPacketException
Construct a reply object from an input stream that was previously constructed from the encode() output of a reply object. This is only currently used by testing routines.
Parameters:
replyData - the previously encoded reply
Method Detail

getRequestId

public java.lang.String getRequestId()
Get the identifier for the request which this is a reply for., Note: although a java String is used, this identifier should only contain 8-bit ascii characters.

getErrorText

public java.lang.String getErrorText()
Get the string that the server returned.
Returns:
a string possibly empty (errorNumber == 0) but never null

addErrorText

public void addErrorText(java.lang.String s)
Append a new error. Only useful for the server.

getErrorNumber

public int getErrorNumber()
Get the error code.
Returns:
an error code, 0 for Success, positive for all known conditions, -1 for unknown error (bug).

decode

public void decode(java.io.InputStream is)
            throws SOXPacketException
Update this reply object with the data read from an inputstream, where the data on the stream was previously written using the encode() method of a reply object. This method is usually used by subclasses to decode the request-id field.
Overrides:
decode in class Encodable
Parameters:
is - the stream from which to read the reply

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Encode a reply to an output stream, suitable for using with ReplyPacket to send remote servers (which use the decode() method to re-construct the object). This method is usually used by subclasses to decode the request-id field.
Overrides:
encode in class Encodable
Parameters:
os - the stream on which to send the output
Returns:
byte[] the reply in encoded form

toString

public java.lang.String toString()
Convert this object to a human readable string
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object