⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 accountdaomock.java

📁 Chinaxp 论坛源代码
💻 JAVA
字号:
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group.  All rights reserved. * */package org.redsoft.forum.dao.mock;import java.util.Collection;import java.util.List;import java.util.Vector;import org.redsoft.forum.dao.Account;import org.redsoft.forum.dao.AccountDAO;import org.redsoft.forum.exception.AccountAlreadyExistException;import org.redsoft.forum.exception.AccountNotFoundException;/** * Mock AccountDAO * * @@author <a href="mailto:chjxm@msn.com">cinc</a> * * @@version $Id: AccountDAOmock.java,v 1.5 2004/04/10 19:56:59 cinc Exp $ */public class AccountDAOmock implements AccountDAO {    protected static List list = null;    public AccountDAOmock() {        if ( list == null ) {            list = new Vector();            Account account = new Account( "User1", "111111", "user@domain.org" );            list.add( account );        }    }    public void addAccount(Account account) throws AccountAlreadyExistException {        try {            findByUserName( account.getUserName() );            throw new AccountAlreadyExistException();        } catch (AccountNotFoundException e) {}        list.add( account );    }    public void updateAccount(Account account) throws AccountNotFoundException {    }    public Account findByUserName(String userName)            throws AccountNotFoundException {        for (int index = 0; index < list.size(); index++) {            Account account = (Account) list.get(index);            if ( account.getUserName().equals( userName) ) {                return account;            }        }        throw new AccountNotFoundException();    }    public void removeAccount(String userName) {        try {            list.remove( findByUserName(userName) );        } catch (AccountNotFoundException e) {        }    }    public Collection findColumnWriters() {        return list;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -