1 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 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 37 public Permissions() { 38 } 39 40 41 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 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 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 { 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 |