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

📄 cmsuser.java

📁 java 编写的程序
💻 JAVA
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src/com/opencms/file/CmsUser.java,v $
* Date   : $Date: 2002/04/05 06:37:48 $
* Version: $Revision: 1.30 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001  The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package com.opencms.file;

import java.util.*;
import com.opencms.core.*;


 /**
 * This class describes the Cms user object and the methods to access it.
 *
 * @author Michael Emmerich
 * @version $Revision: 1.30 $ $Date: 2002/04/05 06:37:48 $
 */

public class CmsUser implements I_CmsConstants, Cloneable {

    /**
     * The login-name of the user.
     */
    private String m_name = "";

    /**
     * The Id of this user.
     */
    private int m_id=C_UNKNOWN_ID;

    /**
     * The password of the user.
     */
    private String m_password = "";


    /**
     * The password of the user.
     */
    private String m_recoveryPassword = "";

    /**
     * The description of the user.
     */
    private String m_description = "";

     /**
     * A storage for additional user information.
     */
    private Hashtable m_additionalInfo = null;

    /**
     * The default group of this user.
     */
    private CmsGroup m_defaultGroup= null;

    /**
     * The default group ID of this user.
     */
    private int m_defaultGroupId= C_UNKNOWN_INT;

    /**
     * The section of the user.
     */
    private String m_section=null;


    /**
     * The flags of the user.
     */
    private int m_flags = C_FLAG_ENABLED;

    /**
     * The email of the user.
     */
    private String m_email = "";

    /**
     * The lastused date.
     */
    private long m_lastused = C_UNKNOWN_LONG;

    /**
     * The firstname of the user.
     */
    private String m_firstname = "";

    /**
     * The lastname of the user.
     */
    private String m_lastname = "";

    /**
     * The address of the user.
     */
    private String m_address = "";


    /**
     * The last login of the user.
     */
    private long m_lastlogin = C_UNKNOWN_LONG;

    /**
     * Defines if the user is a webuser or a systemuser.
     * C_USER_TYPE_SYSTEMUSER for systemuser (incl. guest).
     * C_USER_TYPE_WEBUSER for webuser.
     */
    private int m_type = C_UNKNOWN_INT;


     /**
     * Constructor, creates a new Cms user object.
     *
     * @param id The id of the new user.
     * @param name The name of the new user.
     * @param description The description of the new user.
     */
    public CmsUser(int id, String name,String description) {
        m_id=id;
        m_name=name;
        m_description= description;
    }
    /**
     * Constructor, creates a new Cms user object.
     *
     * @param id The id of the new user.
     * @param name The name of the new user.
     * @param description The description of the new user.
     */
    public CmsUser (int id, String name, String password, String recoveryPassword, String description, String firstname,
                    String lastname, String email, long lastlogin, long lastused, int flags,
                    Hashtable additionalInfo, CmsGroup defaultGroup, String address,
                    String section, int typ) {

        m_id=id;
        m_name=name;
        m_password = password;
        m_recoveryPassword = recoveryPassword;
        m_description= description;
        m_firstname = firstname;
        m_lastname = lastname;
        m_email = email;
        m_lastlogin = lastlogin;
        m_lastused = lastused;
        m_flags  = flags;
        this.setDefaultGroup(defaultGroup);
        m_additionalInfo=additionalInfo;
        m_address = address;
        m_section = section;
        m_type = typ;
    }
    /**
    * Clones the CmsResource by creating a new CmsUser Object.
    * @return Cloned CmsUser.
    */
    public Object clone() {
        CmsUser user= new CmsUser(m_id,new String(m_name),new String(m_password),new String(m_recoveryPassword),
                                  new String (m_description),new String(m_firstname),
                                  new String(m_lastname),new String(m_email),m_lastlogin,
                                  m_lastused, m_flags, getAdditionalInfo(),
                                  m_defaultGroup, new String(m_address), new String(m_section),m_type);
        return user;
    }
    /**
     * Compares the overgiven object with this object.
     *
     * @return true, if the object is identically else it returns false.
     */
    public boolean equals(Object obj) {
        boolean equal=false;
        // check if the object is a CmsUser object
        if (obj instanceof CmsUser) {
            // same ID than the current user?
            if (((CmsUser)obj).getId() == m_id){
                equal = true;
            }
        }
        return equal;
    }
     /**
     * Returns the complete Hashtable with additional information about the user. <BR/>
     * Additional infos are for example emailadress, adress or surname...<BR/><BR/>
     *
     * The additional infos must be requested via the CmsObject.
     *
     *
     * Returns additional information about the user.
     *
     */
    public Hashtable getAdditionalInfo() {
        return  m_additionalInfo;
    }
    /**
     * Returns additional information about the user. <BR/>
     * Additional infos are for example emailadress, adress or surname...<BR/><BR/>
     *
     * The additional infos must be requested via the CmsObject.
     *
     *
     * @param key the key to the additional information.
     *
     * Returns additional information about the user. If the additional info
     * does not exists, it returns null.
     *
     */
    public Object getAdditionalInfo(String key) {
        Object value=null;
        value =m_additionalInfo.get(key);
        return value;
    }
    /**
     * Gets the address.
     *
     * @return the USER_ADDRESS, or null.
     */
    public String getAddress() {
         return m_address;
    }
    /**
     * Returns the default group object of this user.
     *
     * @return Default Group of the user
     */
    public CmsGroup getDefaultGroup() {
        return m_defaultGroup;
    }
     /**
     * Gets the defaultgroup id.
     *
     * @return the USER_DEFAULTGROUP_ID, or null.
     */
    public int getDefaultGroupId() {
        return m_defaultGroupId;
    }
    /**
     * Gets the description of this user.
     *
     * @return the description of this user.
     */
    public String getDescription() {
        return m_description;
    }
    /**
     * Decides, if this user is disabled.
     *
     * @return USER_FLAGS == C_FLAG_DISABLED
     */
    public boolean getDisabled() {
        boolean disabled=false;
        if (getFlags() == C_FLAG_DISABLED) {
            disabled=true;
        }
        return disabled;
    }
    /**
     * Gets the email.
     *
     * @return the USER_EMAIL, or null.
     */
    public String getEmail() {
        return m_email;
    }
    /**
     * Gets the firstname.
     *
     * @return the USER_FIRSTNAME, or null.
     */
    public String getFirstname() {
        return m_firstname ;
    }
     /**
     * Gets the flags.
     *
     * @return the USER_FLAGS, or C_UNKNOWN_INT.
     */
    public int getFlags() {
        return m_flags;
    }
    /**
     * Gets the id of this user.
     *
     * @return the id of this user.
     */
    public int getId() {
        return m_id;
    }
    /**
     * Gets the lastlogin.
     *
     * @return the USER_LASTLOGIN, or C_UNKNOWN_LONG.
     */
    public long getLastlogin() {
        return m_lastlogin;
    }
    /**
     * Gets the lastname.
     *
     * @return the USER_SURNAME, or null.
     */
    public String getLastname() {
        return m_lastname;
    }
    /**
     * Gets the lastlogin.
     *
     * @return the USER_LASTLOGIN, or C_UNKNOWN_LONG.
     */
    public long getLastUsed() {
        return m_lastused;
    }
    /**
     * Gets the login-name of the user.
     *
     * @return the login-name of the user.
     */
    public String getName() {
        return m_name;
    }
    /**
     * Gets the password.
     *
     * @return the USER_PASSWORD, or null.
     */
    public String getPassword() {
        return m_password;
    }
    /**
     * Gets the recovery password.
     *
     * @return the USER_RECOVERY_PASSWORD, or null.
     */
    public String getRecoveryPassword() {
        return m_recoveryPassword;
    }
    /**
     * Gets the section of the user.
     *
     * @return the USER_SECTION, or null.
     */
    public String getSection() {
        return m_section;
    }
     /**
     * Gets the type of the user (webuser or a systemuser).
     * C_USER_TYPE_SYSTEMUSER for systemuser (incl. guest).
     * C_USER_TYPE_WEBUSER for webuser.
     *
     * @return the type, or C_UNKNOWN_INT.
     */
    public int getType() {
        return m_type;
    }
     /**
     * Sets additional information about the user. <BR/>
     * Additional infos are for example emailadress, adress or surname...<BR/><BR/>
     *
     *
     * @param key The key to the additional information.
     * @param obj The additinoal information value.
     *
     */
    public void setAdditionalInfo(String key, Object obj)  {
        m_additionalInfo.put(key,obj);
    }
     /**
     * Sets the  complete Hashtable with additional information about the user. <BR/>
     * Additional infos are for example emailadress, adress or surname...<BR/><BR/>
     *
     * This method has package-visibility for security-reasons.
     * It is required to because of the use of two seprate databases for user data and
     * additional user data.
     *
     */
    void setAdditionalInfo(Hashtable additionalInfo) {
        m_additionalInfo=additionalInfo;
    }
     /**
     * Sets the address.
     *
     * @param value The user adress.
     */
    public void setAddress(String value) {
        m_address = value;
    }
    /**
     * Sets the default group object of this user.
     *
     * @param defaultGroup The default group of this user.
     */
    public void setDefaultGroup(CmsGroup defaultGroup) {
        m_defaultGroup = defaultGroup;
        m_defaultGroupId = defaultGroup.getId();
    }
    /**
     * Sets the description of this user.
     *
     * @param the description of this user.
     */
    public void setDescription(String value) {
        m_description = value;
    }
    /**
     * Disables the user flags by setting them to C_FLAG_DISABLED.
     */
    public void  setDisabled() {
        setFlags(C_FLAG_DISABLED);
    }
    /**
     * Sets the email.
     *
     * @param The new email adress.
     */
    public void setEmail(String value) {
        m_email = value;
    }
    /**
     * Enables the user flags by setting them to C_FLAG_ENABLED.
     */
    public void  setEnabled() {
        setFlags(C_FLAG_ENABLED);
    }
    /**
     * Sets the firstname.
     *
     * @param the USER_FIRSTNAME.
     */
    public void setFirstname(String firstname) {
        m_firstname = firstname;
    }
    /**
     * Sets the flags.
     *
     * @param value The new user flags.
     */
     void setFlags(int value) {
         m_flags = value;
     }
    /**
     * Sets the lastlogin.
     *
     * @param value The new user section.
     */
    public void setLastlogin(long value) {
        m_lastlogin = value;
    }
    /**
     * Gets the lastname.
     *
     * @return the USER_SURNAME, or null.
     */
    public void setLastname(String lastname) {
        m_lastname = lastname;
    }
    /**
     * Sets the lastlogin.
     *
     * @param value The new user section.
     */
    void setLastUsed(long value) {
        m_lastused = value;
    }
    /**
     * Sets the password.
     *
     * @param The new password.
     */
    public void setPassword(String value) {
        m_password = value;
    }
     /**
     * Sets the section of the user.
     *
     * @param value The new user section.
     */
    public void setSection(String value) {
        m_section = value;
    }
    /**
     * Sets the typ.
     *
     * @param value The new user typ.
     */
     void setType(int value) {
         m_type = value;
     }
    /**
     * Returns a string-representation for this object.
     * This can be used for debugging.
     *
     * @return string-representation for this object.
     */
    public String toString() {
        StringBuffer output=new StringBuffer();
        output.append("[User]:");
        output.append(m_name);
        output.append(" , Id=");
        output.append(m_id);
        output.append(" , flags=");
        output.append(getFlags());
        output.append(" , type=");
        output.append(getType());
        output.append(" :");
        output.append(m_description);
        return output.toString();
    }
}

⌨️ 快捷键说明

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