|
From: <pe...@us...> - 2003-10-01 17:35:57
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv31145/src/java/org/neuclear/ledger
Modified Files:
Book.java Ledger.java PostedHeldTransaction.java
PostedTransaction.java Transaction.java TransactionItem.java
UnPostedHeldTransaction.java UnPostedTransaction.java
Log Message:
Made as much as possible immutable for security and reliability reasons.
The only thing that isnt immutable are the items and balance of the
UnpostedTransaction
Index: Book.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Book.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Book.java 20 Sep 2003 23:16:18 -0000 1.1.1.1
--- Book.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 3,6 ****
--- 3,11 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:18 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 188,194 ****
! private String book;
! private String name;
! private Ledger ledger;
}
--- 193,199 ----
! private final String book;
! private final String name;
! private final Ledger ledger;
}
Index: Ledger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Ledger.java 20 Sep 2003 23:16:19 -0000 1.1.1.1
--- Ledger.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 3,6 ****
--- 3,11 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:19 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 260,265 ****
}
! private String name;
! private String id;
/**
--- 265,270 ----
}
! private final String name;
! private final String id;
/**
Index: PostedHeldTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/PostedHeldTransaction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PostedHeldTransaction.java 20 Sep 2003 23:16:17 -0000 1.1.1.1
--- PostedHeldTransaction.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 13,22 ****
public PostedHeldTransaction(UnPostedHeldTransaction orig, String xid) throws InvalidTransactionException {
super(orig, xid);
! this.data=orig;
}
public Date getExpiryTime() {
! return data.getExpiryTime();
}
! private UnPostedHeldTransaction data;
/**
--- 13,22 ----
public PostedHeldTransaction(UnPostedHeldTransaction orig, String xid) throws InvalidTransactionException {
super(orig, xid);
! this.expiryTime=orig.getExpiryTime();
}
public Date getExpiryTime() {
! return expiryTime;
}
! final private Date expiryTime;
/**
Index: PostedTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/PostedTransaction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PostedTransaction.java 20 Sep 2003 23:16:18 -0000 1.1.1.1
--- PostedTransaction.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 7,10 ****
--- 7,15 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:18 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 34,37 ****
--- 39,43 ----
import java.util.Date;
import java.util.Iterator;
+ import java.util.List;
/**
* This class defines the type of Transactions that have been posted. They are therefore immutable.
***************
*** 47,53 ****
*/
PostedTransaction(UnPostedTransaction orig,String xid) throws InvalidTransactionException {
! super(orig.getLedger());
! this.data = orig;
this.xid=xid;
}
--- 53,59 ----
*/
PostedTransaction(UnPostedTransaction orig,String xid) throws InvalidTransactionException {
! super(orig.getLedger(),orig.getTransactionTime(),orig.getComment());
this.xid=xid;
+ this.items=orig.getItemArray();
}
***************
*** 122,137 ****
! public Date getTransactionTime() {
! return data.getTransactionTime();
! }
! public String getComment() {
! return data.getComment();
! }
! public Iterator getItems() {
! return data.getItems();
}
--- 128,147 ----
! public Iterator getItems() {
! return new Iterator() {
! int i=0;
! public boolean hasNext() {
! return i<items.length;
! }
+ public Object next() {
+ return items[i++];
+ }
+ public void remove() {
! }
! };
}
***************
*** 139,144 ****
return xid;
}
! private UnPostedTransaction data;
! private String xid;
}
--- 149,154 ----
return xid;
}
! private final TransactionItem[] items;
! private final String xid;
}
Index: Transaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Transaction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Transaction.java 20 Sep 2003 23:16:18 -0000 1.1.1.1
--- Transaction.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 3,6 ****
--- 3,11 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:18 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 42,49 ****
public abstract class Transaction {
! Transaction(Ledger ledger) throws InvalidTransactionException {
if (ledger==null)
throw new InvalidTransactionException(ledger,"Transaction must have an associated ledger");
this.ledger=ledger;
}
--- 47,56 ----
public abstract class Transaction {
! Transaction(Ledger ledger,Date transactionTime,String comment) throws InvalidTransactionException {
if (ledger==null)
throw new InvalidTransactionException(ledger,"Transaction must have an associated ledger");
this.ledger=ledger;
+ this.transactionTime=transactionTime;
+ this.comment=comment;
}
***************
*** 90,97 ****
! public abstract Date getTransactionTime();
! public abstract String getComment();
public abstract Iterator getItems();
--- 97,108 ----
! public Date getTransactionTime() {
! return transactionTime;
! }
! public String getComment() {
! return comment;
! }
public abstract Iterator getItems();
***************
*** 101,105 ****
}
! private Ledger ledger;
}
--- 112,118 ----
}
! final private Ledger ledger;
! private final Date transactionTime;
! private final String comment;
}
Index: TransactionItem.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/TransactionItem.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** TransactionItem.java 20 Sep 2003 23:16:18 -0000 1.1.1.1
--- TransactionItem.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 7,10 ****
--- 7,15 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:18 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 31,35 ****
}
! private Book book;
! private double amount;
}
--- 36,40 ----
}
! private final Book book;
! private final double amount;
}
Index: UnPostedHeldTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/UnPostedHeldTransaction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** UnPostedHeldTransaction.java 20 Sep 2003 23:16:18 -0000 1.1.1.1
--- UnPostedHeldTransaction.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 8,11 ****
--- 8,16 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:18 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 71,74 ****
}
! private Date expiryTime;
}
--- 76,79 ----
}
! private final Date expiryTime;
}
Index: UnPostedTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/UnPostedTransaction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** UnPostedTransaction.java 20 Sep 2003 23:16:18 -0000 1.1.1.1
--- UnPostedTransaction.java 1 Oct 2003 17:35:53 -0000 1.2
***************
*** 8,11 ****
--- 8,16 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/01 17:35:53 pelle
+ * Made as much as possible immutable for security and reliability reasons.
+ * The only thing that isnt immutable are the items and balance of the
+ * UnpostedTransaction
+ *
* Revision 1.1.1.1 2003/09/20 23:16:18 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 56,60 ****
}
UnPostedTransaction(Ledger ledger, String comment, Date transactionTime, boolean posted) throws InvalidTransactionException {
! super(ledger);
// if (amount<0)
// throw new TransactionException("Negative Transactions are not allowed");
--- 61,65 ----
}
UnPostedTransaction(Ledger ledger, String comment, Date transactionTime, boolean posted) throws InvalidTransactionException {
! super(ledger,transactionTime,comment);
// if (amount<0)
// throw new TransactionException("Negative Transactions are not allowed");
***************
*** 62,67 ****
throw new InvalidTransactionException(ledger,"Transaction must have a Transaction Time");
- this.transactionTime=transactionTime;
- this.comment=comment;
balance=0;
items=new LinkedList();
--- 67,70 ----
***************
*** 78,82 ****
getLedger().beginLinkedTransaction();
postTransaction=postTransaction();
- posted=true;
getLedger().endLinkedTransactions();
} else
--- 81,84 ----
***************
*** 105,124 ****
}
- public Date getTransactionTime() {
- return transactionTime;
- }
-
- public String getComment() {
- return comment;
- }
-
public Iterator getItems() {
return items.iterator();
}
! public final boolean isPosted() {
! return posted;
}
/**
* Adds an item to an unposted Transaction.
--- 107,123 ----
}
public Iterator getItems() {
return items.iterator();
}
+ TransactionItem [] getItemArray() {
+ TransactionItem itemarray[]=new TransactionItem[items.size()];
+ for (int i = 0; i < items.size(); i++) {
+ itemarray[0] = (org.neuclear.ledger.TransactionItem) items.get(i);
! }
! return itemarray;
}
+
/**
* Adds an item to an unposted Transaction.
***************
*** 134,139 ****
*/
public synchronized double addItem(Book book,double amount) throws InvalidTransactionException {
- if (isPosted())
- throw new InvalidTransactionException(getLedger(),"This Transaction has already been posted. You can no longer add items to it.");
if (book==null)
throw new InvalidTransactionException(getLedger(),"You must supply a valid Book");
--- 133,136 ----
***************
*** 144,151 ****
return balance;
}
! private Date transactionTime;
! private String comment;
private List items;
private double balance;
- private boolean posted;
}
--- 141,146 ----
return balance;
}
!
private List items;
private double balance;
}
|