KickJava   Java API By Example, From Geeks To Geeks.

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


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: User.java,v 1.2 2002/06/08 00:49:38 mediumnet Exp $
8

9 package org.ozoneDB.core;
10
11 import java.io.*;
12 import org.ozoneDB.DxLib.*;
13
14
15 /**
16  * This class represents an ozone user. Users can be identified by
17  * its name or ID. A user can be a member of one or more user groups.
18  *
19  *
20  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
21  * @version $Revision: 1.2 $Date: 2002/06/08 00:49:38 $
22  * @see Group
23  */

24 public final class User extends DxObject implements Externalizable {
25     
26     protected final static long serialVersionUID = 2;
27     protected final static byte subSerialVersionUID = 1;
28     
29     protected int id;
30     
31     protected String JavaDoc name;
32     
33     protected String JavaDoc passwd;
34     
35     
36     public User() {
37     }
38     
39     public User( String JavaDoc _name, int _id ) {
40         this( _name, _name, _id );
41     }
42     
43     public User( String JavaDoc _name, String JavaDoc _passwd, int _id ) {
44         name = _name;
45         passwd = _passwd;
46         id = _id;
47     }
48     
49     public String JavaDoc name() {
50         return name;
51     }
52     
53     
54     public Integer JavaDoc id() {
55         return new Integer JavaDoc( id );
56     }
57
58     protected int getID() {
59         return id;
60     }
61     
62     public String JavaDoc password() {
63         return passwd;
64     }
65     
66     public boolean equals( Object JavaDoc obj ) {
67         if (this == obj) {
68             return true;
69         }
70         if (obj instanceof User && obj != null) {
71             return id == ((User)obj).id;
72         }
73         return false;
74     }
75     
76     
77     public Object JavaDoc clone() {
78         User user = new User();
79         user.name = name;
80         user.id = -1;
81         return user;
82     }
83     
84     
85     public String JavaDoc toString() {
86         return new String JavaDoc( "OzoneUser: " + name.toString() );
87     }
88     
89     
90     public void writeExternal( ObjectOutput out ) throws IOException {
91         out.writeByte( subSerialVersionUID );
92         out.writeObject( name );
93         out.writeInt( id );
94         out.writeObject( passwd );
95     }
96     
97     
98     public synchronized void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException JavaDoc {
99         byte streamVersionUID = in.readByte();
100         name = (String JavaDoc)in.readObject();
101         id = in.readInt();
102         passwd = (String JavaDoc)in.readObject();
103     }
104 }
105
Popular Tags