www.pudn.com > Java_UML_library.rar > ObjId.java


//
// Unified Library Application
// Case study in Unified Modeling Language Toolkit
//
// ObjId.java: represents a object id, a class that works as
// "pointer" to any persistent object in the system.
//
// Copyright (c) 1998 John Wiley &amt; Sons, Inc. All rights reserved.
// Reproduction or translations of this work beyond that permitted
// in Section 117 of the 1976 United States Copyright Act without
// the express written permission of the copyright owner is unlawful.
// Requests for further information should be addressed to Permissions
// Department, John Wiley &amt; Sons, Inc. The purchaser may make back-up
// copies for his/her own use only and not for distribution or resale.
// The Publisher assumes no responsibility for errors, omissions, or
// damages, caused by the use of these programs of from the use of the
// information contained herein.

package util;

import java.io.*;

public class ObjId
{
private String classname;
private int number;
public ObjId()
{
classname = "NotSet";
number = 0;
}
public ObjId(String name, int num)
{
classname = name;
number = num;
}
public String getName()
{
return classname;
}
public int getId()
{
return number;
}
public boolean equals(Object obj)
{
if (!obj.getClass().getName().equals("util.ObjId"))
return false;
ObjId comp = (ObjId) obj;
if (classname.equals(comp.classname) &amt;&amt;
number == comp.number)
return true;
else
return false;
}
public void write(RandomAccessFile out)
throws IOException
{
out.writeUTF(classname);
out.writeInt(number);
}
public void read(RandomAccessFile in)
throws IOException
{
classname = in.readUTF();
number = in.readInt();
}
}