001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Core License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: Permissions.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
008:
009: package org.ozoneDB.core;
010:
011: import java.util.*;
012: import java.io.*;
013: import org.ozoneDB.DxLib.*;
014: import org.ozoneDB.*;
015:
016: /**
017: * Ownership and access rights of a database object (aka ObjectContainer).
018: *
019: *
020: * @author <a href="http://www.softwarebuero.de/">SMB</a>
021: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
022: */
023: public final class Permissions extends DxObject implements
024: Externalizable {
025:
026: final static long serialVersionUID = 2;
027: final static byte subSerialVersionUID = 1;
028:
029: protected int ownerID;
030:
031: protected byte data;
032:
033: /**
034: * Constructor for readObject().
035: */
036: public Permissions() {
037: }
038:
039: /**
040: * Constructor. owner wird nicht neu erzeugt damit nur die user in
041: * der user-tabelle im ObjectSpace existieren.
042: */
043: public Permissions(User _owner, int _data) {
044: ownerID = _owner.id;
045: data = (byte) _data;
046: }
047:
048: public void setOwner(User user) {
049: ownerID = user.id;
050: }
051:
052: public Object clone() {
053: Permissions obj = new Permissions();
054: obj.ownerID = ownerID;
055: obj.data = data;
056: return obj;
057: }
058:
059: public int hashCode() {
060: int msb = data;
061: msb = msb << 24;
062: return ownerID | msb;
063: }
064:
065: public boolean equals(Object obj) {
066: if (obj != null && obj instanceof Permissions) {
067: Permissions rhs = (Permissions) obj;
068: if (ownerID == rhs.ownerID && data == rhs.data) {
069: return true;
070: }
071: }
072: return false;
073: }
074:
075: public void writeExternal(ObjectOutput out) throws IOException {
076: out.writeByte(subSerialVersionUID);
077:
078: out.writeInt(ownerID);
079: out.writeByte(data);
080: }
081:
082: public void readExternal(ObjectInput in) throws IOException,
083: ClassNotFoundException {
084: byte streamVersionUID = in.readByte();
085:
086: ownerID = in.readInt();
087: data = in.readByte();
088: }
089:
090: public boolean groupRead() {
091: return (data & OzoneInterface.GroupRead) > 0;
092: }
093:
094: public boolean groupLock() {
095: return (data & OzoneInterface.GroupLock) > 0;
096: }
097:
098: public boolean allRead() {
099: return (data & OzoneInterface.AllRead) > 0;
100: }
101:
102: public boolean allLock() {
103: return (data & OzoneInterface.AllLock) > 0;
104: }
105: }
|