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

📄 account.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public final void setExpirationDate (Date value) {        if (value != null) {            mExpirationDate = value;        }    }    //-------------------------------------------------------------------------    /** Reset the password expiration to a new date.     *     * @param   value     *      New password expiration date. A <code>null</code> value will not     *      reset the expiration date.     */    public final void setPasswordExpirationDate (Date value) {        if (value != null) {            mExpirationDate = value;        }    }    //-------------------------------------------------------------------------    /** Reset the last login date.     *     * @param   value     *      Last login date. A <code>null</code> value will not reset the login     *      date.     */    public final void setLastLoginDate (Date value) {        if (value != null) {            mLastLoginDate = value;        }    }    //-------------------------------------------------------------------------    /** Enable or disable the account.     *     * @param   activation     *      <code>true</code> will activate the account and <code>false</code>     *      will disactivate the account.     */    public final void setActivation (boolean value) {        mActivated = value;    }    //-------------------------------------------------------------------------    /**     * Return a string representation of the account's content.     *     * @return     *      Account's string representation.     */    public String toString()    {        StringBuffer result = new StringBuffer ();        result.append ("Account internal data :");        result.append ("  - user key           = [");        result.append (mUserKey);        result.append ("]");        result.append ("  - site key           = [");        result.append (mSiteKey);        result.append ("]");        result.append ("  - Creation date      = ");        result.append (dateString (mCreationDate));        result.append ("\n");        result.append ("  - Expiration date    = ");        result.append (dateString (mExpirationDate));        result.append ("\n");        result.append ("  - Password Exp. date = ");        result.append (dateString (mPasswordExpirationDate));        result.append ("\n");        result.append ("  - Last login date    = ");        result.append (dateString (mLastLoginDate));        result.append ("\n");        result.append ("  - activation         = ");        result.append (mActivated ? "ACTIVATED" : "DISABLED");        result.append ("\n");        return result.toString();    }    //-------------------------------------------------------------------------    /**     * Return the string representaiton of the specified date.     *     * @return     *      String representing the date.     */    private String dateString (Date date)    {        String result = "-null-";        if (date != null) {            result = (date.toString() + " ("+Long.toString(date.getTime())+")");        }        return result;    }    //-------------------------------------------------------------------------    // Foux     17 Apr. 2001    /**     * Create a new account.     *     * @param   userKey     *      The user unique identification key.     * @param   siteKey     *      The site unique identification key.     * @param   expDate     *      User account expiration date. Specify <code>null</code> if the     *      account does not expire.     * @param   pwdExpDate     *      User password expiration date. Specify <code>null</code> if the user     *      has not password expiration applied on his account.     * @param   activated     *      Account activation. <code>true</code> if the account is activated or     *      <code>false</code> if it's not.     *     * @return     *      Return a valid Account reference if the account could be     *      successfully created.     *     * @exception   JahiaDatabaseException     *      Throws this exception on any database failure.     */    static public synchronized Account createAccount            (String userKey, String siteKey, Date expDate, Date pwdExpDate,             boolean activated)        throws  JahiaDatabaseException,                AccountExistException    {        Account account = mDBUtils.loadAccount (userKey, siteKey);        if (account != null) {            throw new AccountExistException (userKey, siteKey);        }        // Get the current date.        Date creationDate = new Date ();        // Create the new account object        account = new Account (userKey, siteKey, creationDate, expDate,                               pwdExpDate, null, activated);        // insert the new account into the database.        if (account != null) {            if (!mDBUtils.insertAccount (account)) {                account = null;            }        }        return account;    }    //-------------------------------------------------------------------------    // Foux     17 Apr. 2001    /**     * Lookup the account for the specified user related to the specified site     * identification number.     *     * @param   userKey     *      The user unique identification key.     * @param   siteKey     *      The site unique identification key.     *     * @return     *      Return a reference to the account object.     *     * @exception   AccountNotFoundException     *      Throws this exception if the specified has no account for the     *      specified site.     *     * @exception   JahiaDatabaseException     *      Throws this exception on any database failure.     */    static public Account getAccount (String userKey, String siteKey)        throws  AccountNotFoundException,                JahiaDatabaseException    {        Account account = mDBUtils.loadAccount (userKey, siteKey);        if (account == null) {            throw new AccountNotFoundException (userKey, siteKey);        }        return account;    }    //-------------------------------------------------------------------------    // Foux     17 Apr. 2001    /**     * Delete the specified account.     *     * @param   account     *      Reference to the account to be updated.     *     * @return     *      Return <code>true</code> if the account could be successfully     *      deleted, or false if the specified account was <code>null</code>.     *     * @exception   JahiaDatabaseException     *      Throws this exception on any database failure.     */    static public synchronized boolean deleteAccount (Account account)        throws  JahiaDatabaseException    {        if (account != null) {            return mDBUtils.deleteAccount (account);        }        return false;    }    //-------------------------------------------------------------------------    // Foux     17 Apr. 2001    /**     * Update to the database the account's internal data. Only the expiration     * date, the last login date and the activation data will be updated, all     * the other data have no sens to be updated because they cannot change.     *     * @param   account     *      Reference to the account to be updated.     *     * @return     *      Return <code>true</code> if the account could be successfully     *      updated, or false if the specified account was <code>null</code>.     *     * @exception   JahiaDatabaseException     *      Throws this exception on any database failure.     */    public synchronized boolean updatdeAccount ()        throws  JahiaDatabaseException    {        return mDBUtils.updateAccount (this);    }}

⌨️ 快捷键说明

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