RemoteTermIdReference.java from Texai at Krugle
Show RemoteTermIdReference.java syntax highlighted
/*
* RemoteTermIdReference.java
*
* Created on April 23, 2007, 12:31 PM
*
* Description: Provides a means to reference KB objects in remote partitions. Primitive int's
* are used as local term ids in order to save space and increase performance.
*
* Copyright (C) April 23, 2007 Stephen L. Reed.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.texai.kb.entity;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;
import com.sleepycat.persist.model.Relationship;
import com.sleepycat.persist.model.SecondaryKey;
import java.util.UUID;
import org.texai.util.ByteUtils;
/**
*
* @author reed
*/
@Entity
public class RemoteTermIdReference {
/** the local database term ID */
@PrimaryKey
private int termId; // NOPMD
/** the UUID bytes which identity the remote KB partition */
private byte[] kbPartitionUUIDBytes; // NOPMD
/** the UUID bytes which identify the term within the remote KB partition */
private byte[] uuidBytes; // NOPMD
/** Creates a new instance of RemoteTermIdReference */
public RemoteTermIdReference() {
super();
}
/** Creates a new instance of RemoteTermIdReference.
*
* @param termId the local database term ID
* @param kbPartitionUUID the UUID which identifies the remote KB partition
* @param uuid the UUID which identifies the term within the remote KB partition
*/
public RemoteTermIdReference(
final int termId,
final UUID kbPartitionUUID,
final UUID uuid) {
super();
//Preconditions
assert termId != 0 : "termId must not be 0";
assert kbPartitionUUID != null : "kbPartitionUUID must not be null";
assert uuid != null : "uuid must not be null";
this.termId = termId;
this.kbPartitionUUIDBytes = ByteUtils.toBytes(kbPartitionUUID);
this.uuidBytes = ByteUtils.toBytes(uuid);
}
/** Gets the local database term ID.
*
* @return the local database term ID
*/
public int getTermId() {
return termId;
}
/** Gets the UUID which identifies the remote KB partition.
*
* @return the UUID which identifies the remote KB partition
*/
public UUID getKBPartitionUUID() {
return UUID.nameUUIDFromBytes(kbPartitionUUIDBytes);
}
/** Gets the UUID which identifies the term within the remote KB partition.
*
* @return the UUID which identifies the term within the remote KB partition
*/
public UUID getUUID() {
return UUID.nameUUIDFromBytes(uuidBytes);
}
}
See more files for this project here