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

📄 permissions.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: Permissions.java,v 1.3 2002/09/18 06:54:15 per_nyfelt Exp $

package org.ozoneDB.core;

import org.ozoneDB.DxLib.DxObject;
import org.ozoneDB.OzoneInterface;

import java.io.*;


/**
 * Ownership and access rights of a database object (aka ObjectContainer).
 *
 *
 * @author <a href="http://www.softwarebuero.de/">SMB</a>
 * @version $Revision: 1.3 $Date: 2002/09/18 06:54:15 $
 */
public final class Permissions extends DxObject implements Externalizable {

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

    protected int ownerID;

    protected byte data;


    /**
     * Constructor for readObject().
     */
    public Permissions() {
    }


    /**
     * Constructor. Owner wird nicht neu erzeugt damit nur die user in
     * der user-tabelle im ObjectSpace existieren.
     */
    public Permissions( User _owner, int _data ) {
        ownerID = _owner.id;
        data = (byte)_data;
    }


    public void setOwner( User user ) {
        ownerID = user.id;
    }


    public Object clone() {
        Permissions obj = new Permissions();
        obj.ownerID = ownerID;
        obj.data = data;
        return obj;
    }


    public int hashCode() {
        int msb = data;
        msb = msb << 24;
        return ownerID | msb;
    }


    public boolean equals( Object obj ) {
        if (obj != null && obj instanceof Permissions) {
            Permissions rhs = (Permissions)obj;
            if (ownerID == rhs.ownerID && data == rhs.data) {
                return true;
            }
        }
        return false;
    }


    public void writeExternal( ObjectOutput out ) throws IOException {
        out.writeByte( subSerialVersionUID );

        out.writeInt( ownerID );
        out.writeByte( data );
    }


    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
        byte streamVersionUID = in.readByte();

        ownerID = in.readInt();
        data = in.readByte();
    }


    public boolean groupRead() {
        return (data & OzoneInterface.GroupRead) > 0;
    }


    public boolean groupLock() {
        return (data & OzoneInterface.GroupLock) > 0;
    }


    public boolean allRead() {
        return (data & OzoneInterface.AllRead) > 0;
    }


    public boolean allLock() {
        return (data & OzoneInterface.AllLock) > 0;
    }
}

⌨️ 快捷键说明

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