📄 objectid.java
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Core License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id: ObjectID.java,v 1.4 2002/08/27 08:32:25 per_nyfelt Exp $
package org.ozoneDB.core;
import java.io.*;
import org.ozoneDB.DxLib.DxCompatible;
import org.ozoneDB.DxLib.DxObject;
public class ObjectID extends DxObject implements Externalizable,Comparable {
final static long serialVersionUID = 2;
final static byte subSerialVersionUID = 1;
private long value = -1;
public ObjectID() {
}
/**
* Constructor from a string representation aka a handle.
*
*/
public ObjectID(String handle) {
value = Long.parseLong(handle);
}
public ObjectID(long v) {
value = v;
}
public final long value() {
return value;
}
public final int hashCode() {
//wenn diese 32 bits keinen unterschied mehr bringen,
//wird mit equals() weiter verglichen
return (int) value;
}
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj != null && obj instanceof ObjectID) {
return value == ((ObjectID) obj).value;
}
return false;
}
public final boolean isLess(DxCompatible obj) {
if (obj instanceof ObjectID) {
return value < ((ObjectID) obj).value;
}
return false;
}
public int compareTo(Object o) {
return compareTo((ObjectID) o);
}
/**
Compares this ObjectID to the given ObjectID. This is useful for ozone objects which
need a sort order but may not be equals. (E.g. for use in a {@link java.util.SortedSet}.)
@return
!=0 for ObjectIDs which are not equal
0 for ObjectIDs which are equal
*/
public int comparTo(ObjectID o) {
long diff = value()-o.value();
return diff>0?1:diff<0?-1:0;
}
public Object clone() {
return new ObjectID(value);
}
public final void writeExternal(ObjectOutput out) throws IOException {
// env.logWriter.newEntry ("write: " + getClass().toString() + " " + value, LogWriter.DEBUG);
out.writeByte(subSerialVersionUID);
out.writeLong(value);
}
public final void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
byte streamVersionUID = in.readByte();
value = in.readLong();
// env.logWriter.newEntry ("read: " + getClass().toString() + " " + value, LogWriter.DEBUG);
}
/**
* The value of the ObjectID as String. Do not change this, the name
* of the cluster files depend on it.
*/
public String toString() {
return String.valueOf(value);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -