
rationals.utils.MsgQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HermiT Show documentation
Show all versions of HermiT Show documentation
HermiT is reasoner for ontologies written using the Web
Ontology Language (OWL). Given an OWL file, HermiT can determine whether or
not the ontology is consistent, identify subsumption relationships between
classes, and much more.
This is the maven build of HermiT and is designed for people who wish to use
HermiT from within the OWL API. It is not officially supported by the HermiT
development team, but was built initially for use with the Clojure-OWL
library. It is built using the HermiT source tree without modification.
There have been some additions to the test source tree to account for
differences between the maven and ant environment; these are small and
(hopefully) maintainable.
The version number of this package is a composite of the HermiT version and
an value representing releases of this packaged version. So, 1.3.7.1 is the
first release of the mavenized version of HermiT based on the 1.3.7 release
of HermiT.
This package includes the Jautomata library
(http://jautomata.sourceforge.net/), and builds with it directly. This
library appears to be no longer under active development, and so a "fork"
seems appropriate. No development is intended or anticipated on this code
base.
The newest version!
package rationals.utils;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.NoSuchElementException;
/**
* @author bailly
* @version $Id: MsgQueue.java 2 2006-08-24 14:41:48Z oqube $
*/
public class MsgQueue implements Serializable {
/** private list for queueing */
private LinkedList list = new LinkedList();
/** counter of enqueued objects */
private int count = 0;
/** lock object */
private transient Object lock = new Object();
/////////////////////////////////////////////////
// CONSTRUCTOR
//////////////////////////////////////////////////
//////////////////////////////////////////////:
// PUBLIC METHODS
///////////////////////////////////////////////
/**
* Dequeu first message
*
* this method is blocking
*
* @return first message in list or null
*/
public Object dequeue() {
try {
synchronized (lock) {
return list.removeFirst();
}
} catch (NoSuchElementException nsex) {
return null;
}
}
/**
* Adds all elements of collection in order of
* iterator for collection
*
* @param col a Collection
*/
public void addAll(Collection coll) {
Iterator it = coll.iterator();
while (it.hasNext()) {
enqueue((Object) it.next());
}
}
/**
* Enqueue message at end
*
* @param msg message to enqueue
*/
public void enqueue(Object msg) {
synchronized (lock) {
list.addLast(msg);
}
count++;
}
/**
* Get all messages in the list as an array of messages
*
* @return an array of Object objects or null
*/
public Object[] dequeueAll() {
Object[] ary = new Object[0];
synchronized (lock) {
ary = (Object[]) list.toArray(ary);
list.clear();
}
return ary;
}
/**
* get number of messages in queue
*
* @return number of messages
*/
public int getSize() {
synchronized(lock) {
return list.size();
}
}
/**
* Get number of messages which have been enqueued
* @return total number of messages of queue
*/
public int getCount() {
return count;
}
/**
* removes all messages m queue
*/
public void flush() {
synchronized (lock) {
list.clear();
}
}
/**
* ReadObject implementation
*/
private void readObject(java.io.ObjectInputStream stream)
throws java.io.IOException, ClassNotFoundException {
try {
// first, call default serialization mechanism
stream.defaultReadObject();
lock = new Object();
} catch (java.io.NotActiveException ex) {
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy