1 9 package org.ozoneDB.core; 10 11 import java.io.*; 12 import org.ozoneDB.DxLib.*; 13 14 15 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 name; 32 33 protected String passwd; 34 35 36 public User() { 37 } 38 39 public User( String _name, int _id ) { 40 this( _name, _name, _id ); 41 } 42 43 public User( String _name, String _passwd, int _id ) { 44 name = _name; 45 passwd = _passwd; 46 id = _id; 47 } 48 49 public String name() { 50 return name; 51 } 52 53 54 public Integer id() { 55 return new Integer ( id ); 56 } 57 58 protected int getID() { 59 return id; 60 } 61 62 public String password() { 63 return passwd; 64 } 65 66 public boolean equals( Object 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 clone() { 78 User user = new User(); 79 user.name = name; 80 user.id = -1; 81 return user; 82 } 83 84 85 public String toString() { 86 return new String ( "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 { 99 byte streamVersionUID = in.readByte(); 100 name = (String )in.readObject(); 101 id = in.readInt(); 102 passwd = (String )in.readObject(); 103 } 104 } 105 | Popular Tags |