[Webfunds-commits] java/webfunds/sox DepositRequest.java
Ian Grigg
iang@cypherpunks.ai
Fri, 6 Apr 2001 19:48:54 -0400 (AST)
iang 01/04/06 19:48:54
Modified: webfunds/sox DepositRequest.java
Log:
additional support for AbstractPayment examples and versions
Revision Changes Path
1.28 +31 -3 java/webfunds/sox/DepositRequest.java
Index: DepositRequest.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/DepositRequest.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- DepositRequest.java 2000/11/30 13:57:30 1.27
+++ DepositRequest.java 2001/04/06 23:48:53 1.28
@@ -1,13 +1,21 @@
/*
- * $Id: DepositRequest.java,v 1.27 2000/11/30 13:57:30 iang Exp $
+ * $Id: DepositRequest.java,v 1.28 2001/04/06 23:48:53 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
*/
package webfunds.sox;
-import java.io.*;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
/**
* This class represents a deposit request, used
* by a SOX client to deposit a payment into an account.
@@ -37,6 +45,7 @@
protected int version;
public int getVersion() { return version; }
+ public void setVersion(int v) { version = v; }
public static final String name = "SOX.Deposit";
public String getName() { return name ; }
@@ -201,7 +210,10 @@
{
super(requestId, acc);
+// I can notch this up once the Issuers are all upgraded
this.version = DEPOSIT_LOCAL_VERS;
+ if ( ! (payment instanceof Payment) )
+ this.version = DEPOSIT_WITHDRAW;
this.payment = payment;
this.depositId = depositId;
@@ -323,6 +335,11 @@
dos.writeByte(typeOfPayment & 0x7F);
dos.writeByte(protocolState & 0x7F);
writeByteArray(dos, payBuf);
+ /*
+ * In a proto payment withdrawal, add the ProtoPayment.
+ * If we were withdrawing a SOX cheque this would be wrong.
+ * (Not implemented.)
+ */
if (typeOfPayment != PaymentFactory.NONE)
{
writeByteArray(dos, protoBuf);
@@ -424,6 +441,7 @@
if ( (object == null) || !(object instanceof DepositRequest) )
return false;
+// ?? huh? no-op?
if (!super.equals((Request) object))
return false ;
@@ -493,6 +511,7 @@
s += "\n\tProto: "+proto+"\n";
}
}
+ s += "\t--------- END DR\n";
return s;
}
@@ -504,7 +523,6 @@
public static DepositRequest example()
{
- Payment pay = Payment.example();
String reqId = Utils.exampleString();
AccountId ac = AccountId.example();
String depId = Utils.exampleString();
@@ -514,9 +532,19 @@
byte bite = Utils.exampleByte();
if ((bite & 0x01) == 0x01)
+ {
+ AbstractPayment pay = Payment.example();
+ req = new DepositRequest(reqId, ac, pay, depId, desc);
+ }
+ else if ((bite & 0x02) == 0x02)
+ {
+ AbstractPayment pay = Payment.example();
req = new DepositRequest(reqId, ac, pay, depId, desc);
+ req.version = DEPOSIT_WITHDRAW; // try the latest version
+ }
else
{
+ AbstractPayment pay = PaymentFactory.example();
TokenPayment proto = TokenPayment.example();
req = new DepositRequest(reqId, ac, pay, proto, depId, desc);
req.setTypeOfPayment(proto.getType());