FileDocCategorySizeDatePackage
AccountNode.javaAPI DocExample4102Mon Aug 28 22:01:38 BST 2000com.imaginary.bank.ui

AccountNode

public class AccountNode extends Object implements TreeNode

Fields Summary
private com.imaginary.bank.AccountFacade
account
private ArrayList
children
private TreeNode
parent
Constructors Summary
public AccountNode(TreeNode prnt)


       
        super();
        parent = prnt;
    
public AccountNode(TreeNode prnt, com.imaginary.bank.AccountFacade acct)

        super();
        parent = prnt;
        account = acct;
    
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 intgetIndex(javax.swing.tree.TreeNode chld)

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

        return parent;
    
public booleanisLeaf()

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

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

        if( account == null ) {
            return "Accounts";
        }
        else {
            TellerApp.notifyWait();
            try {
                return ("" + account.getNumber());
            }
            catch( RemoteException e ) {
                e.printStackTrace();
                return "ERROR";
            }
            finally {
                TellerApp.notifyResume();
            }
        }