Java Cart .

Java Cart AccountBean java

package cart.sessionBeans;

import cart.Account;
import cart.AccountHolder;
import cart.Address;
import cart.Phone;
import cart.State;

/**
 *AccountBean handles all account data for a session
 *author - Lawrence Truett - FluffyCat.com
 *date - August 13, 2003 - San Diego, CA
 */
public class AccountBean {
    
    private Account account;
    
    private boolean newAccount = false;
    private boolean validData = true;
    private int accountBeanCount = 0;
    
    /** Creates a new instance of accountBean */
    public AccountBean() {}
    
    public AccountBean(Account accountIn) {
        setAccount(accountIn);
    }
    
    public void loadAccountBean() {accountBeanCount++;}
    
    public Account getAccount() {return account;}
    public void setAccount(Account accountIn) {account = accountIn;}
    
    public AccountHolder getAccountHolder() {
        return getAccount().getAccountHolder();
    }
    public void setAccountHolder(AccountHolder accountHolderIn) {
        getAccount().setAccountHolder(accountHolderIn);
    }
    
    public String getAccountHolderFirstName() {
        return getAccount().getAccountHolder().getFirstName();
    }
    public void setAccountHolderFirstName(String firstNameIn) {
        getAccount().getAccountHolder().setFirstName(firstNameIn);
    }
    public boolean isAccountHolderFirstNameValidEntry() {
        if (accountBeanCount < 2) {
            return true;
        }  else {
            return getAccount().getAccountHolder().isFirstNameValid();
        }
    }
    
    public String getAccountHolderLastName() {
        return getAccount().getAccountHolder().getLastName();
    }
    public void setAccountHolderLastName(String lastNameIn) {
        getAccount().getAccountHolder().setLastName(lastNameIn);
    }
    public boolean isAccountHolderLastNameValidEntry() {
        if (accountBeanCount < 2) {
            return true;
        }  else {
            return getAccount().getAccountHolder().isLastNameValid();
        }
    }
    
    public Phone getAccountHolderPhone() {
        return getAccount().getAccountHolder().getPhone();
    }
    public void setAccountHolderPhone(String phoneIn) {
        getAccount().getAccountHolder().setPhone(new Phone(phoneIn));
    }
    public boolean isAccountHolderPhoneValidEntry() {
        if (accountBeanCount < 2) {
            return getAccountHolderPhone().isValidOrNull();
        } else {
            return getAccountHolderPhone().isValid();
        }
    }
    
    public State getAccountHolderAddressState() {
        return getAccount().getAccountHolder().getAddress().getState();
    }
    public void setAccountHolderAddressState(String stateIn) {
        getAccount().getAccountHolder().
        getAddress().setState(new State(stateIn));
    }
    public boolean isAccountHolderAddressStateValidEntry() {
        if (accountBeanCount < 2) {
            return getAccountHolderAddressState().isValidOrNull();
        } else {
            return getAccountHolderAddressState().isValid();
        }
    }
    
    public boolean isNewAccount() {return this.newAccount;}
    public void setNewAccount(boolean newAccountIn) {
        newAccount = newAccountIn;
    }
    
    public boolean isValidData() {return this.validData;}
    public void setValidData(boolean validDataIn) {
        validData = validDataIn;
    }
}
To download source right-click here and "Save As...".
Comments
Sign in to be the first to comment on Java Cart AccountBean java.