KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > Permissions


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: Permissions.java,v 1.3 2002/09/18 06:54:15 per_nyfelt Exp $
8

9 package org.ozoneDB.core;
10
11 import org.ozoneDB.DxLib.DxObject;
12 import org.ozoneDB.OzoneInterface;
13
14 import java.io.*;
15
16
17 /**
18  * Ownership and access rights of a database object (aka ObjectContainer).
19  *
20  *
21  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
22  * @version $Revision: 1.3 $Date: 2002/09/18 06:54:15 $
23  */

24 public final class Permissions extends DxObject implements Externalizable {
25
26     final static long serialVersionUID = 2;
27     final static byte subSerialVersionUID = 1;
28
29     protected int ownerID;
30
31     protected byte data;
32
33
34     /**
35      * Constructor for readObject().
36      */

37     public Permissions() {
38     }
39
40
41     /**
42      * Constructor. Owner wird nicht neu erzeugt damit nur die user in
43      * der user-tabelle im ObjectSpace existieren.
44      */

45     public Permissions( User _owner, int _data ) {
46         ownerID = _owner.id;
47         data = (byte)_data;
48     }
49
50
51     public void setOwner( User user ) {
52         ownerID = user.id;
53     }
54
55
56     public Object JavaDoc clone() {
57         Permissions obj = new Permissions();
58         obj.ownerID = ownerID;
59         obj.data = data;
60         return obj;
61     }
62
63
64     public int hashCode() {
65         int msb = data;
66         msb = msb << 24;
67         return ownerID | msb;
68     }
69
70
71     public boolean equals( Object JavaDoc obj ) {
72         if (obj != null && obj instanceof Permissions) {
73             Permissions rhs = (Permissions)obj;
74             if (ownerID == rhs.ownerID && data == rhs.data) {
75                 return true;
76             }
77         }
78         return false;
79     }
80
81
82     public void writeExternal( ObjectOutput out ) throws IOException {
83         out.writeByte( subSerialVersionUID );
84
85         out.writeInt( ownerID );
86         out.writeByte( data );
87     }
88
89
90     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException JavaDoc {
91         byte streamVersionUID = in.readByte();
92
93         ownerID = in.readInt();
94         data = in.readByte();
95     }
96
97
98     public boolean groupRead() {
99         return (data & OzoneInterface.GroupRead) > 0;
100     }
101
102
103     public boolean groupLock() {
104         return (data & OzoneInterface.GroupLock) > 0;
105     }
106
107
108     public boolean allRead() {
109         return (data & OzoneInterface.AllRead) > 0;
110     }
111
112
113     public boolean allLock() {
114         return (data & OzoneInterface.AllLock) > 0;
115     }
116 }
117
Popular Tags