📄 keygenerator.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: KeyGenerator.java,v 1.5 2002/09/18 06:54:15 per_nyfelt Exp $
package org.ozoneDB.core;
import org.ozoneDB.Setup;
import org.ozoneDB.util.LogWriter;
/**
* @author <a href="http://www.softwarebuero.de/">SMB</a>
* @version $Revision: 1.5 $Date: 2002/09/18 06:54:15 $
*/
public final class KeyGenerator extends ServerComponent {
private long idCount = 0;
private long idBorder = -1;
private long idRange = 5000;
public KeyGenerator( Env env ) {
super( env );
}
public void startup() throws Exception {
env.logWriter.newEntry( this, "startup...", LogWriter.INFO );
}
public void shutdown() throws Exception {
env.logWriter.newEntry( this, "shutdown...", LogWriter.INFO );
}
public void save() throws Exception {
}
public long nextID() {
return nextID( 1 );
}
public synchronized long nextID( long range ) {
if (idCount + range >= idBorder) {
try {
idCount = env.state.longProperty( Setup.XOID, -1 );
if (idCount == -1) {
throw new Exception( "Unable to access the " + Setup.XOID + " property." );
}
idBorder = idCount + range + idRange;
env.state.setLongProperty( Setup.XOID, idBorder );
setChanged();
} catch (Exception e) {
env.fatalError( /*null*/this, "nextID(): " + e.toString(), e );
}
}
long result = idCount;
idCount += range;
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -