FileDocCategorySizeDatePackage
CustomerNode.javaAPI DocExample4427Mon Aug 28 22:01:14 BST 2000com.imaginary.bank.ui

CustomerNode

public class CustomerNode extends Object implements TreeNode

Fields Summary
private com.imaginary.bank.CustomerFacade
customer
private ArrayList
children
private TreeNode
parent
Constructors Summary
public CustomerNode(TreeNode prnt)


       
        super();
        parent = prnt;
    
public CustomerNode(TreeNode prnt, com.imaginary.bank.CustomerFacade cust)

        super();
        parent = prnt;
        customer = cust;
    
Methods Summary
public java.util.Enumerationchildren()

        return new RootNode.IteratorEnumeration(children.iterator());
    
public booleangetAllowsChildren()

        return !isLeaf();
    
public javax.swing.tree.TreeNodegetChildAt(int ind)

        return (TreeNode)getChildren().get(ind);
    
public intgetChildCount()

        return getChildren().size();
    
private synchronized java.util.ArrayListgetChildren()

        if( children == null ) {
            load();
        }
        return children;
    
public com.imaginary.bank.CustomerFacadegetCustomer()

        return customer;
    
public intgetIndex(javax.swing.tree.TreeNode chld)

        return getChildren().indexOf(chld);
    
public javax.swing.tree.TreeNodegetParent()

        return parent;
    
public booleanisLeaf()

        if( parent instanceof AccountNode ) {
            return true;
        }
        else {
            return false;
        }
    
private voidload()

        TellerApp.notifyWait();
        try {
            if( customer == null ) {
                CustomerHome home;
                
                children = new ArrayList();
                try {
                    String[] pre = { "firstName", "lastName" };
                    SearchCriteria sc;
                    Iterator it;
                    
                    home = (CustomerHome)BaseHome.getInstance(Identifier.currentIdentifier(),
                                                              Customer.class);
                    sc = new SearchCriteria(pre);
                    it = home.find(Identifier.currentIdentifier(), sc).iterator();
                    while( it.hasNext() ) {
                        CustomerFacade cust = (CustomerFacade)it.next();
                        
                        children.add(new CustomerNode(this, cust));
                    }
                }
                catch( RemoteException e ) {
                    e.printStackTrace();
                    return;
                }
                catch( FindException e ) {
                    e.printStackTrace();
                    return;
                }
                catch( TransactionException e ) {
                    e.printStackTrace();
                    return;
                }
            }
            else {
                Iterator it;
                
                children = new ArrayList();
                try {
                    it = customer.getAccounts().iterator();
                }
                catch( RemoteException e ) {
                    e.printStackTrace();
                    return;
                }
                while( it.hasNext() ) {
                    AccountFacade acct = (AccountFacade)it.next();
                    
                    children.add(new AccountNode(this, acct));
                }
            }
        }
        finally {
            TellerApp.notifyResume();
        }
    
public java.lang.StringtoString()

        if( customer == null ) {
            return "Customers";
        }
        else {
            try {
                TellerApp.notifyWait();
                return (customer.getLastName() + ", " +
                        customer.getFirstName());
            }
            catch( RemoteException e ) {
                e.printStackTrace();
                return "ERROR";
            }
            finally {
                TellerApp.notifyResume();
            }
        }