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

📄 group.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Core License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id: Group.java,v 1.2 2002/08/27 08:32:25 per_nyfelt Exp $

package org.ozoneDB.core;

import org.ozoneDB.DxLib.*;
import java.io.*;


/**
 * This class represent an ozone user group. A group can be identified by
 * its name.
 *
 *
 * @author <a href="http://www.softwarebuero.de/">SMB</a>
 * @version $Revision: 1.2 $Date: 2002/08/27 08:32:25 $
 * @see User
 * @see UserManager
 */
public final class Group extends DxObject implements Externalizable {

    protected final static long serialVersionUID = 2;
    protected final static byte subSerialVersionUID = 1;

    protected String name;

    protected int id;

    protected DxSet users;


    public Group() {
        users = new DxHashSet();
    }


    public Group( String _name, int _id ) {
        name = _name;
        id = _id;
        users = new DxHashSet();
    }


    public String name() {
        return name;
    }


    public Integer id() {
        return new Integer( id );
    }


    public DxCollection userIDs() {
        return users;
    }


    public boolean addUser( User user ) {
        return users.add( new Integer( user.id ) );
    }


    public boolean containsUser( User user ) {
        return users.contains( new Integer( user.id ) );
    }


    public boolean removeUser( User user ) {
        return users.remove( new Integer( user.id ) );
    }


    public boolean isEmpty() {
        return users.isEmpty();
    }


    public int usersCount() {
        return users.count();
    }


    public boolean equals( Object obj ) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof Group && obj != null) {
            return id == ((Group)obj).id;
        }
        return false;
    }


    public Object clone() {
        Group group = (Group)super.clone();
        group.name = name;
        group.id = -1;
        return group;
    }


    public String toString() {
        return new String( "Group '" + name.toString() + "'" );
    }


    public void writeExternal( ObjectOutput out ) throws IOException {
        out.writeByte( subSerialVersionUID );
        out.writeObject( name );
        out.writeInt( id );
        out.writeObject( users );
    }


    public synchronized void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
        byte streamVersionUID = in.readByte();
        name = (String)in.readObject();
        id = in.readInt();
        users = (DxSet)in.readObject();
    }

}

⌨️ 快捷键说明

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