001: /*
002: *
003: * JMoney - A Personal Finance Manager
004: * Copyright (c) 2002 Johann Gyger <johann.gyger@switzerland.org>
005: * Copyright (c) 2004 Nigel Westbury <westbury@users.sourceforge.net>
006: *
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License as published by
010: * the Free Software Foundation; either version 2 of the License, or
011: * (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package net.sf.jmoney.model2;
025:
026: import net.sf.jmoney.JMoneyPlugin;
027:
028: /**
029: * The data model for an bank account.
030: */
031: public class BankAccount extends CurrencyAccount {
032:
033: protected String bank = null;
034:
035: protected String accountNumber = null;
036:
037: protected Long minBalance = null;
038:
039: /**
040: * The full constructor for a BankAccount object. This constructor is called
041: * only be the datastore when loading data from the datastore. The properties
042: * passed to this constructor must be valid because datastores should only pass back
043: * values that were previously saved from a CapitalAccount object. So, for example,
044: * we can be sure that a non-null name and currency are passed to this constructor.
045: *
046: * @param name the name of the account
047: */
048: public BankAccount(IObjectKey objectKey, ListKey parent,
049: String name, IListManager<CapitalAccount> subAccounts,
050: String abbreviation, String comment,
051: IObjectKey currencyKey, long startBalance, String bank,
052: String accountNumber, Long minBalance,
053: IValues extensionValues) {
054: super (objectKey, parent, name, subAccounts, abbreviation,
055: comment, currencyKey, startBalance, extensionValues);
056:
057: this .bank = bank;
058: this .accountNumber = accountNumber;
059: this .minBalance = minBalance;
060: }
061:
062: /**
063: * The default constructor for a BankAccount object. This constructor is called
064: * when a new BankAccount object is created. The properties are set to default
065: * values. The list properties are set to empty lists. The parameter list for this
066: * constructor is the same as the full constructor except that there are no parameters
067: * for the scalar properties.
068: */
069: public BankAccount(IObjectKey objectKey, ListKey parent) {
070: super (objectKey, parent);
071:
072: // Overwrite the default name with our own default name.
073: this .name = JMoneyPlugin
074: .getResourceString("Account.newAccount");
075:
076: this .bank = null;
077: this .accountNumber = null;
078: this .minBalance = null;
079: }
080:
081: // TODO: remove this. If we could get the property set, typed
082: // with the correct type as the generic parameter, then that would
083: // be great. Otherwise this method is no use because we can get
084: // the property set from the map.
085: @Override
086: protected String getExtendablePropertySetId() {
087: return "net.sf.jmoney.bankAccount";
088: }
089:
090: /**
091: * @return the bank name of this account.
092: */
093: public String getBank() {
094: return bank;
095: }
096:
097: /**
098: * @return the account number of this account.
099: */
100: public String getAccountNumber() {
101: return accountNumber;
102: }
103:
104: /**
105: * @return the minimal balance of this account.
106: */
107: public Long getMinBalance() {
108: return minBalance;
109: }
110:
111: /**
112: * @param aBank the name of this account.
113: */
114: public void setBank(String aBank) {
115: String oldBank = this .bank;
116: this .bank = aBank;
117:
118: // Notify the change manager.
119: processPropertyChange(BankAccountInfo.getBankAccessor(),
120: oldBank, aBank);
121: }
122:
123: /**
124: * Sets the account number of this account.
125: * @param anAccountNumber the account number
126: */
127: public void setAccountNumber(String anAccountNumber) {
128: String oldAccountNumber = this .accountNumber;
129: this .accountNumber = anAccountNumber;
130:
131: // Notify the change manager.
132: processPropertyChange(BankAccountInfo
133: .getAccountNumberAccessor(), oldAccountNumber,
134: anAccountNumber);
135: }
136:
137: /**
138: * @param m the minimal balance which may be null.
139: */
140: public void setMinBalance(Long m) {
141: Long oldMinBalance = this .minBalance;
142: this .minBalance = m;
143:
144: // Notify the change manager.
145: processPropertyChange(BankAccountInfo.getMinBalanceAccessor(),
146: oldMinBalance, m);
147: }
148: }
|