activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r677944 [7/11] - in /activemq/sandbox/kahadb: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/kahadb/ src/main/java/org/apache/kahadb/impl/ src/main/java/org/apache/kahadb/impl/async/ s...
Date Fri, 18 Jul 2008 15:49:52 GMT
Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayInputStream.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayInputStream.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayInputStream.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Very similar to the java.io.ByteArrayInputStream but this version is not
+ * thread safe.
+ */
+public class ByteArrayInputStream extends InputStream {
+
+    byte buffer[];
+    int limit;
+    int pos;
+    int mark;
+
+    public ByteArrayInputStream(byte data[]) {
+        this(data, 0, data.length);
+    }
+
+    public ByteArrayInputStream(ByteSequence sequence) {
+        this(sequence.getData(), sequence.getOffset(), sequence.getLength());
+    }
+
+    public ByteArrayInputStream(byte data[], int offset, int size) {
+        this.buffer = data;
+        this.mark = offset;
+        this.pos = offset;
+        this.limit = offset + size;
+    }
+
+    public int read() throws IOException {
+        if (pos < limit) {
+            return buffer[pos++] & 0xff;
+        } else {
+            return -1;
+        }
+    }
+
+    public int read(byte[] b) throws IOException {
+        return read(b, 0, b.length);
+    }
+
+    public int read(byte b[], int off, int len) {
+        if (pos < limit) {
+            len = Math.min(len, limit - pos);
+            if (len > 0) {
+                System.arraycopy(buffer, pos, b, off, len);
+                pos += len;
+            }
+            return len;
+        } else {
+            return -1;
+        }
+    }
+
+    public long skip(long len) throws IOException {
+        if (pos < limit) {
+            len = Math.min(len, limit - pos);
+            if (len > 0) {
+                pos += len;
+            }
+            return len;
+        } else {
+            return -1;
+        }
+    }
+
+    public int available() {
+        return limit - pos;
+    }
+
+    public boolean markSupported() {
+        return true;
+    }
+
+    public void mark(int markpos) {
+        mark = pos;
+    }
+
+    public void reset() {
+        pos = mark;
+    }
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayOutputStream.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayOutputStream.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteArrayOutputStream.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.io.OutputStream;
+
+
+/**
+ * Very similar to the java.io.ByteArrayOutputStream but this version 
+ * is not thread safe and the resulting data is returned in a ByteSequence
+ * to avoid an extra byte[] allocation.
+ */
+public class ByteArrayOutputStream extends OutputStream {
+
+    byte buffer[];
+    int size;
+
+    public ByteArrayOutputStream() {
+        this(1028);
+    }
+    public ByteArrayOutputStream(int capacity) {
+        buffer = new byte[capacity];
+    }
+
+    public void write(int b) {
+        int newsize = size + 1;
+        checkCapacity(newsize);
+        buffer[size] = (byte) b;
+        size = newsize;
+    }
+
+    public void write(byte b[], int off, int len) {
+        int newsize = size + len;
+        checkCapacity(newsize);
+        System.arraycopy(b, off, buffer, size, len);
+        size = newsize;
+    }
+    
+    /**
+     * Ensures the the buffer has at least the minimumCapacity specified. 
+     * @param i
+     */
+    private void checkCapacity(int minimumCapacity) {
+        if (minimumCapacity > buffer.length) {
+            byte b[] = new byte[Math.max(buffer.length << 1, minimumCapacity)];
+            System.arraycopy(buffer, 0, b, 0, size);
+            buffer = b;
+        }
+    }
+
+    public void reset() {
+        size = 0;
+    }
+
+    public ByteSequence toByteSequence() {
+        return new ByteSequence(buffer, 0, size);
+    }
+    
+    public byte[] toByteArray() {
+        byte rc[] = new byte[size];
+        System.arraycopy(buffer, 0, rc, 0, size);
+        return rc;
+    }
+    
+    public int size() {
+        return size;
+    }
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteSequence.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteSequence.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteSequence.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/ByteSequence.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kahadb.util;
+
+public class ByteSequence {
+
+    public byte[] data;
+    public int offset;
+    public int length;
+
+    public ByteSequence(byte data[]) {
+        this.data = data;
+        this.offset = 0;
+        this.length = data.length;
+    }
+
+    public ByteSequence(byte data[], int offset, int length) {
+        this.data = data;
+        this.offset = offset;
+        this.length = length;
+    }
+
+    public byte[] getData() {
+        return data;
+    }
+
+    public int getLength() {
+        return length;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public void setData(byte[] data) {
+        this.data = data;
+    }
+
+    public void setLength(int length) {
+        this.length = length;
+    }
+
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+
+    public void compact() {
+        if (length != data.length) {
+            byte t[] = new byte[length];
+            System.arraycopy(data, offset, t, 0, length);
+            data = t;
+            offset = 0;
+        }
+    }
+
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayInputStream.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayInputStream.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayInputStream.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,312 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UTFDataFormatException;
+
+/**
+ * Optimized ByteArrayInputStream that can be used more than once
+ * 
+ * @version $Revision: 1.1.1.1 $
+ */
+public final class DataByteArrayInputStream extends InputStream implements DataInput {
+    private byte[] buf;
+    private int pos;
+    private int offset;
+
+    /**
+     * Creates a <code>StoreByteArrayInputStream</code>.
+     * 
+     * @param buf the input buffer.
+     */
+    public DataByteArrayInputStream(byte buf[]) {
+        this.buf = buf;
+        this.pos = 0;
+        this.offset = 0;
+    }
+
+    /**
+     * Creates a <code>StoreByteArrayInputStream</code>.
+     * 
+     * @param sequence the input buffer.
+     */
+    public DataByteArrayInputStream(ByteSequence sequence) {
+        this.buf = sequence.getData();
+        this.offset = sequence.getOffset();
+        this.pos =  this.offset;
+    }
+
+    /**
+     * Creates <code>WireByteArrayInputStream</code> with a minmalist byte
+     * array
+     */
+    public DataByteArrayInputStream() {
+        this(new byte[0]);
+    }
+
+    /**
+     * @return the size
+     */
+    public int size() {
+        return pos - offset;
+    }
+
+    /**
+     * @return the underlying data array
+     */
+    public byte[] getRawData() {
+        return buf;
+    }
+
+    /**
+     * reset the <code>StoreByteArrayInputStream</code> to use an new byte
+     * array
+     * 
+     * @param newBuff
+     */
+    public void restart(byte[] newBuff) {
+        buf = newBuff;
+        pos = 0;
+    }
+
+    /**
+     * reset the <code>StoreByteArrayInputStream</code> to use an new
+     * ByteSequence
+     * 
+     * @param sequence
+     */
+    public void restart(ByteSequence sequence) {
+        this.buf = sequence.getData();
+        this.pos = sequence.getOffset();
+    }
+
+    /**
+     * re-start the input stream - reusing the current buffer
+     * 
+     * @param size
+     */
+    public void restart(int size) {
+        if (buf == null || buf.length < size) {
+            buf = new byte[size];
+        }
+        restart(buf);
+    }
+
+    /**
+     * Reads the next byte of data from this input stream. The value byte is
+     * returned as an <code>int</code> in the range <code>0</code> to
+     * <code>255</code>. If no byte is available because the end of the
+     * stream has been reached, the value <code>-1</code> is returned.
+     * <p>
+     * This <code>read</code> method cannot block.
+     * 
+     * @return the next byte of data, or <code>-1</code> if the end of the
+     *         stream has been reached.
+     */
+    public int read() {
+        return (pos < buf.length) ? (buf[pos++] & 0xff) : -1;
+    }
+
+    /**
+     * Reads up to <code>len</code> bytes of data into an array of bytes from
+     * this input stream.
+     * 
+     * @param b the buffer into which the data is read.
+     * @param off the start offset of the data.
+     * @param len the maximum number of bytes read.
+     * @return the total number of bytes read into the buffer, or
+     *         <code>-1</code> if there is no more data because the end of the
+     *         stream has been reached.
+     */
+    public int read(byte b[], int off, int len) {
+        if (b == null) {
+            throw new NullPointerException();
+        }
+        if (pos >= buf.length) {
+            return -1;
+        }
+        if (pos + len > buf.length) {
+            len = buf.length - pos;
+        }
+        if (len <= 0) {
+            return 0;
+        }
+        System.arraycopy(buf, pos, b, off, len);
+        pos += len;
+        return len;
+    }
+
+    /**
+     * @return the number of bytes that can be read from the input stream
+     *         without blocking.
+     */
+    public int available() {
+        return buf.length - pos;
+    }
+
+    public void readFully(byte[] b) {
+        read(b, 0, b.length);
+    }
+
+    public void readFully(byte[] b, int off, int len) {
+        read(b, off, len);
+    }
+
+    public int skipBytes(int n) {
+        if (pos + n > buf.length) {
+            n = buf.length - pos;
+        }
+        if (n < 0) {
+            return 0;
+        }
+        pos += n;
+        return n;
+    }
+
+    public boolean readBoolean() {
+        return read() != 0;
+    }
+
+    public byte readByte() {
+        return (byte)read();
+    }
+
+    public int readUnsignedByte() {
+        return read();
+    }
+
+    public short readShort() {
+        int ch1 = read();
+        int ch2 = read();
+        return (short)((ch1 << 8) + (ch2 << 0));
+    }
+
+    public int readUnsignedShort() {
+        int ch1 = read();
+        int ch2 = read();
+        return (ch1 << 8) + (ch2 << 0);
+    }
+
+    public char readChar() {
+        int ch1 = read();
+        int ch2 = read();
+        return (char)((ch1 << 8) + (ch2 << 0));
+    }
+
+    public int readInt() {
+        int ch1 = read();
+        int ch2 = read();
+        int ch3 = read();
+        int ch4 = read();
+        return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0);
+    }
+
+    public long readLong() {
+        long rc = ((long)buf[pos++] << 56) + ((long)(buf[pos++] & 255) << 48) + ((long)(buf[pos++] & 255) << 40) + ((long)(buf[pos++] & 255) << 32);
+        return rc + ((long)(buf[pos++] & 255) << 24) + ((buf[pos++] & 255) << 16) + ((buf[pos++] & 255) << 8) + ((buf[pos++] & 255) << 0);
+    }
+
+    public float readFloat() throws IOException {
+        return Float.intBitsToFloat(readInt());
+    }
+
+    public double readDouble() throws IOException {
+        return Double.longBitsToDouble(readLong());
+    }
+
+    public String readLine() {
+        int start = pos;
+        while (pos < buf.length) {
+            int c = read();
+            if (c == '\n') {
+                break;
+            }
+            if (c == '\r') {
+                c = read();
+                if (c != '\n' && c != -1) {
+                    pos--;
+                }
+                break;
+            }
+        }
+        return new String(buf, start, pos);
+    }
+
+    public String readUTF() throws IOException {
+        int length = readUnsignedShort();
+        char[] characters = new char[length];
+        int c;
+        int c2;
+        int c3;
+        int count = 0;
+        int total = pos + length;
+        while (pos < total) {
+            c = (int)buf[pos] & 0xff;
+            if (c > 127) {
+                break;
+            }
+            pos++;
+            characters[count++] = (char)c;
+        }
+        while (pos < total) {
+            c = (int)buf[pos] & 0xff;
+            switch (c >> 4) {
+            case 0:
+            case 1:
+            case 2:
+            case 3:
+            case 4:
+            case 5:
+            case 6:
+            case 7:
+                pos++;
+                characters[count++] = (char)c;
+                break;
+            case 12:
+            case 13:
+                pos += 2;
+                if (pos > length) {
+                    throw new UTFDataFormatException("bad string");
+                }
+                c2 = (int)buf[pos - 1];
+                if ((c2 & 0xC0) != 0x80) {
+                    throw new UTFDataFormatException("bad string");
+                }
+                characters[count++] = (char)(((c & 0x1F) << 6) | (c2 & 0x3F));
+                break;
+            case 14:
+                pos += 3;
+                if (pos > length) {
+                    throw new UTFDataFormatException("bad string");
+                }
+                c2 = (int)buf[pos - 2];
+                c3 = (int)buf[pos - 1];
+                if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80)) {
+                    throw new UTFDataFormatException("bad string");
+                }
+                characters[count++] = (char)(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
+                break;
+            default:
+                throw new UTFDataFormatException("bad string");
+            }
+        }
+        return new String(characters, 0, count);
+    }
+}

Propchange: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayInputStream.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,254 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UTFDataFormatException;
+
+/**
+ * Optimized ByteArrayOutputStream
+ * 
+ * @version $Revision: 1.1.1.1 $
+ */
+public final class DataByteArrayOutputStream extends OutputStream implements DataOutput {
+    private static final int DEFAULT_SIZE = 2048;
+    private byte buf[];
+    private int pos;
+
+    /**
+     * Creates a new byte array output stream, with a buffer capacity of the
+     * specified size, in bytes.
+     * 
+     * @param size the initial size.
+     * @exception IllegalArgumentException if size is negative.
+     */
+    public DataByteArrayOutputStream(int size) {
+        if (size < 0) {
+            throw new IllegalArgumentException("Invalid size: " + size);
+        }
+        buf = new byte[size];
+    }
+
+    /**
+     * Creates a new byte array output stream.
+     */
+    public DataByteArrayOutputStream() {
+        this(DEFAULT_SIZE);
+    }
+
+    /**
+     * start using a fresh byte array
+     * 
+     * @param size
+     */
+    public void restart(int size) {
+        buf = new byte[size];
+        pos = 0;
+    }
+
+    /**
+     * start using a fresh byte array
+     */
+    public void restart() {
+        restart(DEFAULT_SIZE);
+    }
+
+    /**
+     * Get a ByteSequence from the stream
+     * 
+     * @return the byte sequence
+     */
+    public ByteSequence toByteSequence() {
+        return new ByteSequence(buf, 0, pos);
+    }
+
+    /**
+     * Writes the specified byte to this byte array output stream.
+     * 
+     * @param b the byte to be written.
+     */
+    public void write(int b) {
+        int newcount = pos + 1;
+        ensureEnoughBuffer(newcount);
+        buf[pos] = (byte)b;
+        pos = newcount;
+    }
+
+    /**
+     * Writes <code>len</code> bytes from the specified byte array starting at
+     * offset <code>off</code> to this byte array output stream.
+     * 
+     * @param b the data.
+     * @param off the start offset in the data.
+     * @param len the number of bytes to write.
+     */
+    public void write(byte b[], int off, int len) {
+        if (len == 0) {
+            return;
+        }
+        int newcount = pos + len;
+        ensureEnoughBuffer(newcount);
+        System.arraycopy(b, off, buf, pos, len);
+        pos = newcount;
+    }
+
+    /**
+     * @return the underlying byte[] buffer
+     */
+    public byte[] getData() {
+        return buf;
+    }
+
+    /**
+     * reset the output stream
+     */
+    public void reset() {
+        pos = 0;
+    }
+
+    /**
+     * Set the current position for writing
+     * 
+     * @param offset
+     */
+    public void position(int offset) {
+        ensureEnoughBuffer(offset);
+        pos = offset;
+    }
+
+    public int size() {
+        return pos;
+    }
+
+    public void writeBoolean(boolean v) {
+        ensureEnoughBuffer(pos + 1);
+        buf[pos++] = (byte)(v ? 1 : 0);
+    }
+
+    public void writeByte(int v) {
+        ensureEnoughBuffer(pos + 1);
+        buf[pos++] = (byte)(v >>> 0);
+    }
+
+    public void writeShort(int v) {
+        ensureEnoughBuffer(pos + 2);
+        buf[pos++] = (byte)(v >>> 8);
+        buf[pos++] = (byte)(v >>> 0);
+    }
+
+    public void writeChar(int v) {
+        ensureEnoughBuffer(pos + 2);
+        buf[pos++] = (byte)(v >>> 8);
+        buf[pos++] = (byte)(v >>> 0);
+    }
+
+    public void writeInt(int v) {
+        ensureEnoughBuffer(pos + 4);
+        buf[pos++] = (byte)(v >>> 24);
+        buf[pos++] = (byte)(v >>> 16);
+        buf[pos++] = (byte)(v >>> 8);
+        buf[pos++] = (byte)(v >>> 0);
+    }
+
+    public void writeLong(long v) {
+        ensureEnoughBuffer(pos + 8);
+        buf[pos++] = (byte)(v >>> 56);
+        buf[pos++] = (byte)(v >>> 48);
+        buf[pos++] = (byte)(v >>> 40);
+        buf[pos++] = (byte)(v >>> 32);
+        buf[pos++] = (byte)(v >>> 24);
+        buf[pos++] = (byte)(v >>> 16);
+        buf[pos++] = (byte)(v >>> 8);
+        buf[pos++] = (byte)(v >>> 0);
+    }
+
+    public void writeFloat(float v) throws IOException {
+        writeInt(Float.floatToIntBits(v));
+    }
+
+    public void writeDouble(double v) throws IOException {
+        writeLong(Double.doubleToLongBits(v));
+    }
+
+    public void writeBytes(String s) {
+        int length = s.length();
+        for (int i = 0; i < length; i++) {
+            write((byte)s.charAt(i));
+        }
+    }
+
+    public void writeChars(String s) {
+        int length = s.length();
+        for (int i = 0; i < length; i++) {
+            int c = s.charAt(i);
+            write((c >>> 8) & 0xFF);
+            write((c >>> 0) & 0xFF);
+        }
+    }
+
+    public void writeUTF(String str) throws IOException {
+        int strlen = str.length();
+        int encodedsize = 0;
+        int c;
+        for (int i = 0; i < strlen; i++) {
+            c = str.charAt(i);
+            if ((c >= 0x0001) && (c <= 0x007F)) {
+                encodedsize++;
+            } else if (c > 0x07FF) {
+                encodedsize += 3;
+            } else {
+                encodedsize += 2;
+            }
+        }
+        if (encodedsize > 65535) {
+            throw new UTFDataFormatException("encoded string too long: " + encodedsize + " bytes");
+        }
+        ensureEnoughBuffer(pos + encodedsize + 2);
+        writeShort(encodedsize);
+        int i = 0;
+        for (i = 0; i < strlen; i++) {
+            c = str.charAt(i);
+            if (!((c >= 0x0001) && (c <= 0x007F))) {
+                break;
+            }
+            buf[pos++] = (byte)c;
+        }
+        for (; i < strlen; i++) {
+            c = str.charAt(i);
+            if ((c >= 0x0001) && (c <= 0x007F)) {
+                buf[pos++] = (byte)c;
+            } else if (c > 0x07FF) {
+                buf[pos++] = (byte)(0xE0 | ((c >> 12) & 0x0F));
+                buf[pos++] = (byte)(0x80 | ((c >> 6) & 0x3F));
+                buf[pos++] = (byte)(0x80 | ((c >> 0) & 0x3F));
+            } else {
+                buf[pos++] = (byte)(0xC0 | ((c >> 6) & 0x1F));
+                buf[pos++] = (byte)(0x80 | ((c >> 0) & 0x3F));
+            }
+        }
+    }
+
+    private void ensureEnoughBuffer(int newcount) {
+        if (newcount > buf.length) {
+            byte newbuf[] = new byte[Math.max(buf.length << 1, newcount)];
+            System.arraycopy(buf, 0, newbuf, 0, pos);
+            buf = newbuf;
+        }
+    }
+}

Propchange: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/HexSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/HexSupport.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/HexSupport.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/HexSupport.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+/**
+ * Used to convert to hex from byte arrays and back.
+ * 
+ * @version $Revision: 1.2 $
+ */
+public final class HexSupport {
+    
+    private static final String[] HEX_TABLE = new String[]{
+        "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
+        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f",
+        "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f",
+        "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f",
+        "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f",
+        "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f",
+        "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f",
+        "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f",
+        "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f",
+        "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f",
+        "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af",
+        "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf",
+        "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf",
+        "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df",
+        "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef",
+        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff",
+    };
+    private static final int[] INT_OFFSETS = new int[]{
+    	24,16,8,0
+    };
+    
+    private HexSupport() {
+    }
+    
+    /**
+     * @param hex
+     * @return
+     */
+    public static byte[] toBytesFromHex(String hex) {
+        byte rc[] = new byte[hex.length() / 2];
+        for (int i = 0; i < rc.length; i++) {
+            String h = hex.substring(i * 2, i * 2 + 2);
+            int x = Integer.parseInt(h, 16);
+            rc[i] = (byte) x;
+        }
+        return rc;
+    }
+
+    /**
+     * @param bytes
+     * @return
+     */
+    public static String toHexFromBytes(byte[] bytes) {
+        StringBuffer rc = new StringBuffer(bytes.length * 2);
+        for (int i = 0; i < bytes.length; i++) {
+            rc.append(HEX_TABLE[0xFF & bytes[i]]);
+        }
+        return rc.toString();
+    }
+
+    /**
+     * 
+     * @param value 
+     * @param trim if the leading 0's should be trimmed off.
+     * @return
+     */
+    public static String toHexFromInt(int value, boolean trim) {
+        StringBuffer rc = new StringBuffer(INT_OFFSETS.length*2);
+        for (int i = 0; i < INT_OFFSETS.length; i++) {
+        	int b = 0xFF & (value>>INT_OFFSETS[i]);
+        	if( !(trim && b == 0) ) { 
+        		rc.append(HEX_TABLE[b]);
+        		trim=false;
+        	}
+        }
+        return rc.toString();
+    }
+
+}

Propchange: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/HexSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOExceptionSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOExceptionSupport.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOExceptionSupport.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOExceptionSupport.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.io.IOException;
+
+public final class IOExceptionSupport {
+
+    private IOExceptionSupport() {
+    }
+
+    public static IOException create(String msg, Throwable cause) {
+        IOException exception = new IOException(msg);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static IOException create(String msg, Exception cause) {
+        IOException exception = new IOException(msg);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static IOException create(Throwable cause) {
+        IOException exception = new IOException(cause.getMessage());
+        exception.initCause(cause);
+        return exception;
+    }
+
+    public static IOException create(Exception cause) {
+        IOException exception = new IOException(cause.getMessage());
+        exception.initCause(cause);
+        return exception;
+    }
+
+}

Propchange: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOExceptionSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOHelper.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOHelper.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOHelper.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/IOHelper.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,187 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @version $Revision: 661435 $
+ */
+public final class IOHelper {
+    protected static final int MAX_DIR_NAME_LENGTH;
+    protected static final int MAX_FILE_NAME_LENGTH;
+    private static final int DEFAULT_BUFFER_SIZE = 4096;
+    private IOHelper() {
+    }
+
+    public static String getDefaultDataDirectory() {
+        return getDefaultDirectoryPrefix() + "activemq-data";
+    }
+
+    public static String getDefaultStoreDirectory() {
+        return getDefaultDirectoryPrefix() + "amqstore";
+    }
+
+    /**
+     * Allows a system property to be used to overload the default data
+     * directory which can be useful for forcing the test cases to use a target/
+     * prefix
+     */
+    public static String getDefaultDirectoryPrefix() {
+        try {
+            return System.getProperty("org.apache.activemq.default.directory.prefix", "");
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    /**
+     * Converts any string into a string that is safe to use as a file name.
+     * The result will only include ascii characters and numbers, and the "-","_", and "." characters.
+     *
+     * @param name
+     * @return
+     */
+    public static String toFileSystemDirectorySafeName(String name) {
+        return toFileSystemSafeName(name, true, MAX_DIR_NAME_LENGTH);
+    }
+    
+    public static String toFileSystemSafeName(String name) {
+        return toFileSystemSafeName(name, false, MAX_FILE_NAME_LENGTH);
+    }
+    
+    /**
+     * Converts any string into a string that is safe to use as a file name.
+     * The result will only include ascii characters and numbers, and the "-","_", and "." characters.
+     *
+     * @param name
+     * @param dirSeparators 
+     * @param maxFileLength 
+     * @return
+     */
+    public static String toFileSystemSafeName(String name,boolean dirSeparators,int maxFileLength) {
+        int size = name.length();
+        StringBuffer rc = new StringBuffer(size * 2);
+        for (int i = 0; i < size; i++) {
+            char c = name.charAt(i);
+            boolean valid = c >= 'a' && c <= 'z';
+            valid = valid || (c >= 'A' && c <= 'Z');
+            valid = valid || (c >= '0' && c <= '9');
+            valid = valid || (c == '_') || (c == '-') || (c == '.') || (c=='#')
+                    ||(dirSeparators && ( (c == '/') || (c == '\\')));
+
+            if (valid) {
+                rc.append(c);
+            } else {
+                // Encode the character using hex notation
+                rc.append('#');
+                rc.append(HexSupport.toHexFromInt(c, true));
+            }
+        }
+        String result = rc.toString();
+        if (result.length() > maxFileLength) {
+            result = result.substring(result.length()-maxFileLength,result.length());
+        }
+        return result;
+    }
+    
+    public static boolean deleteFile(File fileToDelete) {
+        if (fileToDelete == null || !fileToDelete.exists()) {
+            return true;
+        }
+        boolean result = deleteChildren(fileToDelete);
+        result &= fileToDelete.delete();
+        return result;
+    }
+    
+    public static boolean deleteChildren(File parent) {
+        if (parent == null || !parent.exists()) {
+            return false;
+        }
+        boolean result = true;
+        if (parent.isDirectory()) {
+            File[] files = parent.listFiles();
+            if (files == null) {
+                result = false;
+            } else {
+                for (int i = 0; i < files.length; i++) {
+                    File file = files[i];
+                    if (file.getName().equals(".")
+                            || file.getName().equals("..")) {
+                        continue;
+                    }
+                    if (file.isDirectory()) {
+                        result &= deleteFile(file);
+                    } else {
+                        result &= file.delete();
+                    }
+                }
+            }
+        }
+       
+        return result;
+    }
+    
+    
+    public static void moveFile(File src, File targetDirectory) throws IOException {
+        if (!src.renameTo(new File(targetDirectory, src.getName()))) {
+            throw new IOException("Failed to move " + src + " to " + targetDirectory);
+        }
+    }
+    
+    public static void copyFile(File src, File dest) throws IOException {
+        FileInputStream fileSrc = new FileInputStream(src);
+        FileOutputStream fileDest = new FileOutputStream(dest);
+        copyInputStream(fileSrc, fileDest);
+    }
+    
+    public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+        int len = in.read(buffer);
+        while (len >= 0) {
+            out.write(buffer, 0, len);
+            len = in.read(buffer);
+        }
+        in.close();
+        out.close();
+    }
+    
+    static {
+        MAX_DIR_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumDirNameLength","200")).intValue();  
+        MAX_FILE_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumFileNameLength","64")).intValue();             
+    }
+
+    
+    public static void mkdirs(File dir) throws IOException {
+        if (dir.exists()) {
+            if (!dir.isDirectory()) {
+                throw new IOException("Failed to create directory '" + dir +"', regular file already existed with that name");
+            }
+            
+        } else {
+            if (!dir.mkdirs()) {
+                throw new IOException("Failed to create directory '" + dir+"'");
+            }
+        }
+    }
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LRUCache.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LRUCache.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LRUCache.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LRUCache.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * A Simple LRU Cache
+ * 
+ * @version $Revision$
+ * @param <K>
+ * @param <V>
+ */
+
+public class LRUCache<K, V> extends LinkedHashMap<K, V> {
+    private static final long serialVersionUID = -342098639681884413L;
+    protected int maxCacheSize = 10000;
+
+    /**
+     * Default constructor for an LRU Cache The default capacity is 10000
+     */
+    public LRUCache() {
+        this(0,10000, 0.75f, true);
+    }
+
+    /**
+     * Constructs a LRUCache with a maximum capacity
+     * 
+     * @param maximumCacheSize
+     */
+    public LRUCache(int maximumCacheSize) {
+        this(0, maximumCacheSize, 0.75f, true);
+    }
+
+    /**
+     * Constructs an empty <tt>LRUCache</tt> instance with the specified
+     * initial capacity, maximumCacheSize,load factor and ordering mode.
+     * 
+     * @param initialCapacity the initial capacity.
+     * @param maximumCacheSize
+     * @param loadFactor the load factor.
+     * @param accessOrder the ordering mode - <tt>true</tt> for access-order,
+     *                <tt>false</tt> for insertion-order.
+     * @throws IllegalArgumentException if the initial capacity is negative or
+     *                 the load factor is non-positive.
+     */
+
+    public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) {
+        super(initialCapacity, loadFactor, accessOrder);
+        this.maxCacheSize = maximumCacheSize;
+    }
+
+    /**
+     * @return Returns the maxCacheSize.
+     */
+    public int getMaxCacheSize() {
+        return maxCacheSize;
+    }
+
+    /**
+     * @param maxCacheSize The maxCacheSize to set.
+     */
+    public void setMaxCacheSize(int maxCacheSize) {
+        this.maxCacheSize = maxCacheSize;
+    }
+
+    protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
+        return size() > maxCacheSize;
+    }
+}

Propchange: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LRUCache.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+/**
+ * Provides a base class for you to extend when you want object to maintain a
+ * doubly linked list to other objects without using a collection class.
+ * 
+ * @author chirino
+ */
+public class LinkedNode {
+
+    protected LinkedNode next = this;
+    protected LinkedNode prev = this;
+    protected boolean tail = true;
+
+    public LinkedNode getHeadNode() {
+        if (isHeadNode()) {
+            return this;
+        }
+        if (isTailNode()) {
+            return next;
+        }
+        LinkedNode rc = prev;
+        while (!rc.isHeadNode()) {
+            rc = rc.prev;
+        }
+        return rc;
+    }
+
+    public LinkedNode getTailNode() {
+        if (isTailNode()) {
+            return this;
+        }
+        if (isHeadNode()) {
+            return prev;
+        }
+        LinkedNode rc = next;
+        while (!rc.isTailNode()) {
+            rc = rc.next;
+        }
+        return rc;
+    }
+
+    public LinkedNode getNext() {
+        return tail ? null : next;
+    }
+
+    public LinkedNode getPrevious() {
+        return prev.tail ? null : prev;
+    }
+
+    public boolean isHeadNode() {
+        return prev.isTailNode();
+    }
+
+    public boolean isTailNode() {
+        return tail;
+    }
+
+    /**
+     * @param rightHead the node to link after this node.
+     * @return this
+     */
+    public LinkedNode linkAfter(LinkedNode rightHead) {
+
+        if (rightHead == this) {
+            throw new IllegalArgumentException("You cannot link to yourself");
+        }
+        if (!rightHead.isHeadNode()) {
+            throw new IllegalArgumentException("You only insert nodes that are the first in a list");
+        }
+
+        LinkedNode rightTail = rightHead.prev;
+
+        if (tail) {
+            tail = false;
+        } else {
+            rightTail.tail = false;
+        }
+
+        rightHead.prev = this; // link the head of the right side.
+        rightTail.next = next; // link the tail of the right side
+        next.prev = rightTail; // link the head of the left side
+        next = rightHead; // link the tail of the left side.
+
+        return this;
+    }
+
+    /**
+     * @param leftHead the node to link after this node.
+     * @return
+     * @return this
+     */
+    public LinkedNode linkBefore(LinkedNode leftHead) {
+
+        if (leftHead == this) {
+            throw new IllegalArgumentException("You cannot link to yourself");
+        }
+        if (!leftHead.isHeadNode()) {
+            throw new IllegalArgumentException("You only insert nodes that are the first in a list");
+        }
+
+        // The left side is no longer going to be a tail..
+        LinkedNode leftTail = leftHead.prev;
+        leftTail.tail = false;
+
+        leftTail.next = this; // link the tail of the left side.
+        leftHead.prev = prev; // link the head of the left side.
+        prev.next = leftHead; // link the tail of the right side.
+        prev = leftTail; // link the head of the right side.
+
+        return leftHead;
+    }
+
+    /**
+     * Removes this node out of the linked list it is chained in.
+     */
+    public void unlink() {
+        // If we are allready unlinked...
+        if (prev == this) {
+            reset();
+            return;
+        }
+
+        if (tail) {
+            prev.tail = true;
+        }
+
+        // Update the peers links..
+        next.prev = prev;
+        prev.next = next;
+
+        // Update our links..
+        reset();
+    }
+    
+    public void reset() {
+        next = this;
+        prev = this;
+        tail = true;
+    }
+
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.util.HashMap;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * @version $Revision$
+ */
+public final class Scheduler {
+
+    
+
+	public static final Timer CLOCK_DAEMON = new Timer("ActiveMQ Scheduler", true);
+    private static final HashMap<Runnable, TimerTask> TIMER_TASKS = new HashMap<Runnable, TimerTask>();
+
+    private Scheduler() {
+    }
+
+    public static synchronized void executePeriodically(final Runnable task, long period) {
+    	TimerTask timerTask = new SchedulerTimerTask(task);
+        CLOCK_DAEMON.scheduleAtFixedRate(timerTask, period, period);
+        TIMER_TASKS.put(task, timerTask);
+    }
+
+    public static synchronized void cancel(Runnable task) {
+    	TimerTask ticket = TIMER_TASKS.remove(task);
+        if (ticket != null) {
+            ticket.cancel();
+            CLOCK_DAEMON.purge();//remove cancelled TimerTasks
+        }
+    }
+
+    public static void executeAfterDelay(final Runnable task, long redeliveryDelay) {
+    	TimerTask timerTask = new SchedulerTimerTask(task);
+        CLOCK_DAEMON.schedule(timerTask, redeliveryDelay);
+    }
+    
+    public static void shutdown() {
+        CLOCK_DAEMON.cancel();
+    }
+
+}

Propchange: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/SchedulerTimerTask.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/SchedulerTimerTask.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/SchedulerTimerTask.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/SchedulerTimerTask.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kahadb.util;
+
+import java.util.TimerTask;
+
+/**
+ * A TimeTask for a Runnable object
+ *
+ */
+public class SchedulerTimerTask extends TimerTask {
+    private final Runnable task;
+
+    public SchedulerTimerTask(Runnable task) {
+        this.task = task;
+    }
+
+    public void run() {
+        this.task.run();                         
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/FaultCodes.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/FaultCodes.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/FaultCodes.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/FaultCodes.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,281 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id: FaultCodes.java 564427 2007-08-09 23:45:48Z vgritsenko $
+ */
+
+package org.apache.kahadb.xindice;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * FaultCodes defines the Xindice specific fault codes and associated error
+ * messages.
+ *
+ * @version $Revision: 564427 $, $Date: 2007-08-09 19:45:48 -0400 (Thu, 09 Aug 2007) $
+ */
+public abstract class FaultCodes {
+
+    public static final int UNKNOWN_ERROR = 0;
+    public static final int VENDOR_ERROR = 1;
+    public static final int NOT_IMPLEMENTED = 2;
+    public static final int WRONG_CONTENT_TYPE = 3;
+    public static final int PERMISSION_DENIED = 4;
+    public static final int INVALID_URI = 5;
+    public static final int NO_SUCH_SERVICE = 100;
+    public static final int NO_SUCH_COLLECTION = 200;
+    public static final int INVALID_COLLECTION = 201;
+    public static final int COLLECTION_CLOSED = 202;
+    public static final int NO_SUCH_RESOURCE = 300;
+    public static final int INVALID_RESOURCE = 301;
+    public static final int UNKNOWN_RESOURCE_TYPE = 302;
+    public static final int NO_SUCH_DATABASE = 400;
+    public static final int INVALID_DATABASE = 401;
+    
+    /**
+     * Defines maximum possible fault code
+     */
+    public static final int MAX_CODE  = 10000;
+
+    private static final Map<Integer, String> faultMessages = new HashMap<Integer, String>();
+
+    public static final int GEN  =    0;
+    public static final int OBJ  =  100;
+    public static final int COL  =  200;
+    public static final int IDX  =  300;
+    public static final int TRX  =  400;
+    public static final int DBE  =  500;
+    public static final int QRY  =  600;
+    public static final int SEC  =  700;
+    public static final int URI  =  800;
+    public static final int JAVA = 2000;
+
+    public static final int GEN_UNKNOWN        =  0;
+    public static final int GEN_GENERAL_ERROR  = 40;
+    public static final int GEN_CRITICAL_ERROR = 70;
+    public static final int GEN_FATAL_ERROR    = 90;
+
+    public static final int COL_COLLECTION_NOT_FOUND = 200;
+    public static final int COL_DOCUMENT_NOT_FOUND   = 201;
+    public static final int COL_DUPLICATE_COLLECTION = 240;
+    public static final int COL_NULL_RESULT          = 241;
+    public static final int COL_NO_FILER             = 242;
+    public static final int COL_NO_INDEXMANAGER      = 242;
+    public static final int COL_DOCUMENT_MALFORMED   = 243;
+    public static final int COL_CANNOT_STORE         = 244;
+    public static final int COL_CANNOT_RETRIEVE      = 245;
+    public static final int COL_COLLECTION_READ_ONLY = 246;
+    public static final int COL_COLLECTION_CLOSED    = 247;
+    public static final int COL_DUPLICATE_RESOURCE   = 248;
+    public static final int COL_CANNOT_CREATE        = 270;
+    public static final int COL_CANNOT_DROP          = 271;
+    public static final int COL_INVALID_RESULT       = 277;
+
+    public static final int IDX_VALUE_NOT_FOUND      = 300;
+    public static final int IDX_INDEX_NOT_FOUND      = 301;
+    public static final int IDX_MATCHES_NOT_FOUND    = 340;
+    public static final int IDX_DUPLICATE_INDEX      = 341;
+    public static final int IDX_NOT_SUPPORTED        = 370;
+    public static final int IDX_STYLE_NOT_FOUND      = 371;
+    public static final int IDX_CORRUPTED            = 372;
+    public static final int IDX_CANNOT_CREATE        = 373;
+
+    public static final int TRX_DOC_LOCKED           = 400;
+    public static final int TRX_NO_CONTEXT           = 440;
+    public static final int TRX_NOT_ACTIVE           = 441;
+    public static final int TRX_NOT_SUPPORTED        = 470;
+
+    public static final int DBE_NO_PARENT            = 500;
+    public static final int DBE_CANNOT_DROP          = 570;
+    public static final int DBE_CANNOT_CREATE        = 571;
+    public static final int DBE_CANNOT_READ          = 572;
+
+    public static final int QRY_NULL_RESULT          = 600;
+    public static final int QRY_COMPILATION_ERROR    = 640;
+    public static final int QRY_PROCESSING_ERROR     = 641;
+    public static final int QRY_NOT_SUPPORTED        = 670;
+    public static final int QRY_STYLE_NOT_FOUND      = 671;
+
+    public static final int SEC_INVALID_USER         = 770;
+    public static final int SEC_INVALID_GROUP        = 771;
+    public static final int SEC_INVALID_ACCESS       = 772;
+    public static final int SEC_INVALID_CREDENTIALS  = 773;
+
+    public static final int URI_EMPTY                = 800;
+    public static final int URI_NULL                 = 801;
+    public static final int URI_PARSE_ERROR          = 820;
+
+    public static final int JAVA_RUNTIME_ERROR       = 2070;
+
+
+    private FaultCodes() {
+    }
+
+    static {
+        // General errors 0 series
+        putCodeMessage(GEN_UNKNOWN, "Unknown");
+        putCodeMessage(GEN_GENERAL_ERROR, "General Error");
+        putCodeMessage(GEN_CRITICAL_ERROR, "Critical Error");
+        putCodeMessage(GEN_FATAL_ERROR, "Fatal Error");
+
+        // Collection-related errors 200 series
+        putCodeMessage(COL_COLLECTION_NOT_FOUND, "Collection Not Found");
+        putCodeMessage(COL_DOCUMENT_NOT_FOUND, "Collection Document Not Found");
+        putCodeMessage(COL_DUPLICATE_COLLECTION, "Collection Duplicated");
+        putCodeMessage(COL_NULL_RESULT, "Collection Null Result");
+        putCodeMessage(COL_NO_FILER, "Collection No Filer");
+        putCodeMessage(COL_NO_INDEXMANAGER, "Collection No IndexManager");
+        putCodeMessage(COL_DOCUMENT_MALFORMED, "Collection Document Malformed");
+        putCodeMessage(COL_CANNOT_STORE, "Collection Cannot Store");
+        putCodeMessage(COL_CANNOT_RETRIEVE, "Collection Cannot Retrieve");
+        putCodeMessage(COL_COLLECTION_READ_ONLY, "Collection Read-only");
+        putCodeMessage(COL_COLLECTION_CLOSED, "Collection Closed");
+        putCodeMessage(COL_DUPLICATE_RESOURCE, "Resource Duplicated");
+        putCodeMessage(COL_CANNOT_CREATE, "Collection Cannot Create");
+        putCodeMessage(COL_CANNOT_DROP, "Collection Cannot Drop");
+        putCodeMessage(COL_INVALID_RESULT, "Collection Invalid Result");
+
+        // Index-related errors 300 series
+        putCodeMessage(IDX_VALUE_NOT_FOUND, "Index Value Not Found");
+        putCodeMessage(IDX_INDEX_NOT_FOUND, "Index Not Found");
+        putCodeMessage(IDX_MATCHES_NOT_FOUND, "Index Matches Not Found");
+        putCodeMessage(IDX_DUPLICATE_INDEX, "Index Duplicate Index");
+        putCodeMessage(IDX_NOT_SUPPORTED, "Index Not Supported");
+        putCodeMessage(IDX_STYLE_NOT_FOUND, "Index Style Not Found");
+        putCodeMessage(IDX_CORRUPTED, "Index Corrupted");
+        putCodeMessage(IDX_CANNOT_CREATE, "Index Cannot Create");
+        
+        // Transaction-related errors 400 series
+        putCodeMessage(TRX_DOC_LOCKED, "Transaction Document Locked");
+        putCodeMessage(TRX_NO_CONTEXT, "Transaction No Context");
+        putCodeMessage(TRX_NOT_ACTIVE, "Transaction Not Active");
+        putCodeMessage(TRX_NOT_SUPPORTED, "Transaction Not Supported");
+
+        // Database-related errors 500 series
+        putCodeMessage(DBE_NO_PARENT, "Database No Parent");
+        putCodeMessage(DBE_CANNOT_DROP, "Database Cannot Drop");
+        putCodeMessage(DBE_CANNOT_CREATE, "Database Cannot Create");
+        putCodeMessage(DBE_CANNOT_READ, "Database Cannot Read");
+
+        // Query-related errors 600 series
+        putCodeMessage(QRY_NULL_RESULT, "Query Null Result");
+        putCodeMessage(QRY_COMPILATION_ERROR, "Query Compilation Error");
+        putCodeMessage(QRY_PROCESSING_ERROR, "Query Processing Error");
+        putCodeMessage(QRY_NOT_SUPPORTED, "Query Not Supported");
+        putCodeMessage(QRY_STYLE_NOT_FOUND, "Query Style Not Found");
+
+        // Security-related errors 700 series
+        putCodeMessage(SEC_INVALID_USER, "Security Invalid User");
+        putCodeMessage(SEC_INVALID_GROUP, "Security Invalid Group");
+        putCodeMessage(SEC_INVALID_ACCESS, "Security Invalid Access");
+        putCodeMessage(SEC_INVALID_CREDENTIALS, "Security Invalid Credentials");
+        
+        // URI-related errors 800 series
+        putCodeMessage(URI_EMPTY, "URI Empty");
+        putCodeMessage(URI_NULL, "URI Null");
+        putCodeMessage(URI_PARSE_ERROR, "URI Parse Error");
+
+        // Java-related errors 2000 series
+        putCodeMessage(JAVA_RUNTIME_ERROR, "Java Runtime Error");
+    }
+
+    private static void putCodeMessage(int code, String message) {
+        faultMessages.put(new Integer(code), message);
+    }
+
+
+
+    /**
+     * getMessage returns a textual form for the specified fault code.
+     *
+     * @param code The Fault Code
+     * @return It's textual form
+     */
+    public static String getMessage(int code) {
+        String msg = faultMessages.get(new Integer(code));
+        return msg != null ? msg : "";
+    }
+
+    /**
+     * getFaultCodeType examines the provided exception to determine
+     * the general fault code that is associated with it.  General
+     * fault codes are reduced from actual fault codes to be one of
+     * the GEN_ prefixed fault code values.
+     *
+     * @param e The Exception to examine
+     * @return The General Fault Code
+     */
+    public static int getFaultCodeType(Exception e) {
+        int code = 0;
+        if (e instanceof IndexException) {
+            code = ((IndexException) e).faultCode;
+        }
+
+        // Strip it to the General series
+        code = code % 100;
+        // Narrow to a General value
+        code = code - (code % 10);
+        return code;
+    }
+
+    /**
+     * getFaultCodeSeries examines the provided exception to
+     * determine the fault code series that is associated with it.
+     * Series are reduced from actual fault codes to be one of
+     * the fault code prefixes (ex: COL, DB, SEC).
+     *
+     * @param e The Exception to examine
+     * @return The Fault Code Series
+     */
+    public static int getFaultCodeSeries(Exception e) {
+        int code = 0;
+        if (e instanceof IndexException) {
+            code = ((IndexException) e).faultCode;
+        }
+
+        // Strip it to the series
+        code = code - (code % 100);
+        return code;
+    }
+
+    /**
+     * getFaultCode examines the provided exception to determine
+     * the fault code that is associated with it.
+     *
+     * @param e The Exception to examine
+     * @return The Fault Code
+     */
+    public static int getFaultCode(Exception e) {
+        if (e instanceof IndexException) {
+            return ((IndexException) e).faultCode;
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * getFaultMessage examines the provided exception to determine
+     * the fault message that is associated with it.
+     *
+     * @param e The Exception to examine
+     * @return The Fault Message
+     */
+    public static String getFaultMessage(Exception e) {
+        return getMessage(getFaultCode(e));
+    }
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Index.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Index.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Index.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Index.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id: Filer.java 541516 2007-05-25 02:46:51Z vgritsenko $
+ */
+
+package org.apache.kahadb.xindice;
+
+import java.io.File;
+
+
+/**
+ * Filer is the low-level file management interface for Xindice.  A Filer object
+ * is implemented in order to provide a data source to the Xindice Collection
+ * class.  Filers are developed to perform transparent storage and retrieval to
+ * and from heterogenous data sources (such as FTP, HTTP, RDBMS, etc...)
+ *
+ * @version $Revision: 541516 $, $Date: 2007-05-24 22:46:51 -0400 (Thu, 24 May 2007) $
+ */
+public interface Index {
+    
+    /**
+     * Persistently creates this object.
+     *
+     * @throws IndexException if operation failed
+     */
+    boolean create() throws IndexException;
+
+    /**
+     * open opens the DBObject
+     *
+     * @return Whether or not the DBObject was opened
+     * @throws IndexException if operation failed
+     */
+    boolean open() throws IndexException;
+
+    /**
+     * isOpened returns whether or not the DBObject is opened for business.
+     *
+     * @return The open status of the DBObject
+     */
+    boolean isOpened();
+
+    /**
+     * exists returns whether or not a physical representation of this
+     * DBObject actually exists.  In the case of a HashFiler, this would
+     * check for the file, and in the case of an FTPFiler, it might
+     * perform a connection check.
+     *
+     * @return Whether or not the physical resource exists
+     * @throws IndexException if operation failed
+     */
+    boolean exists() throws IndexException;
+
+    /**
+     * drop instructs the DBObjectimplementation to remove itself from
+     * existence.  The DBObject's parent is responsible for removing any
+     * references to the DBObject in its own context.
+     *
+     * @return Whether or not the DBObject was dropped
+     * @throws IndexException if operation failed
+     */
+    boolean drop() throws IndexException;
+
+    /**
+     * close closes the DBObject
+     *
+     * @return Whether or not the DBObject was closed
+     * @throws IndexException if operation failed
+     */
+    boolean close() throws IndexException;
+
+    /**
+     * getName retrieves the contextually important name of the object
+     *
+     * @return The object's name
+     */
+    String getName();
+    
+    /**
+     * setLocation tells the Filer where to store its data.
+     *
+     * @param root The root under which to store data
+     * @param location The name to use for storing data
+     */
+    void setLocation(File root, String location);
+
+    /**
+     * readRecord returns a Record from the Filer based on the specified
+     * Key.
+     *
+     * @param key The Record's Key
+     * @return The returned Record
+     */
+    Record readRecord(Key key) throws IndexException;
+
+    /**
+     * readRecord returns a Record from the Filer based on the specified
+     * Key containing filer meta information and value.
+     *
+     * @param key The Record's Key
+     * @param metaOnly if true, resulting record contains only meta information
+     * @return The returned Record
+     */
+    Record readRecord(Key key, boolean metaOnly) throws IndexException;
+
+    /**
+     * writeRecord writes a Value to the Filer based on the specified Key.
+     *
+     * @param key The Record's Key
+     * @param value The Record's Value
+     * @return Written Record
+     */
+    Record writeRecord(Key key, Value value) throws IndexException;
+
+    /**
+     * deleteRecord removes a Record from the Filer based on the
+     * specified Key.
+     *
+     * @param key The Record's Key
+     * @return Whether or not the Record was deleted
+     */
+    boolean deleteRecord(Key key) throws IndexException;
+
+    /**
+     * getRecordCount returns the number of Records in the Filer.
+     *
+     * @return The Record count
+     */
+    long getRecordCount() throws IndexException;
+
+    /**
+     * getRecordSet returns a RecordSet object for the current Filer.
+     *
+     * @return The Filer Enumerator
+     */
+    RecordSet getRecordSet() throws IndexException;
+
+    /**
+     * flush forcefully flushes any unwritten buffers to disk.
+     */
+    void flush() throws IndexException;
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/IndexException.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/IndexException.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/IndexException.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/IndexException.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id: DBException.java 564998 2007-08-12 02:51:49Z vgritsenko $
+ */
+
+package org.apache.kahadb.xindice;
+
+
+
+/**
+ * A IndexException is thrown by the Index if an exception occurs whlie working
+ * with database objects.
+ *
+ * @version $Revision: 564998 $, $Date: 2007-08-11 22:51:49 -0400 (Sat, 11 Aug 2007) $
+ */
+public class IndexException extends Exception {
+    public final int faultCode;
+
+    public IndexException() {
+        this(FaultCodes.GEN_UNKNOWN, "", null);
+    }
+
+    public IndexException(int faultCode) {
+        this(faultCode, "", null);
+    }
+
+    public IndexException(int faultCode, String message) {
+        this(faultCode, message, null);
+    }
+
+    public IndexException(int faultCode, String message, Throwable cause) {
+        super(message, cause);
+        this.faultCode = faultCode;
+    }
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Key.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Key.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Key.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Key.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id: Key.java 571943 2007-09-02 10:48:02Z vgritsenko $
+ */
+
+package org.apache.kahadb.xindice;
+
+/**
+ * Key extends Value by providing a hash value for the Key.
+ *
+ * @version $Revision: 571943 $, $Date: 2007-09-02 06:48:02 -0400 (Sun, 02 Sep 2007) $
+ */
+public final class Key extends Value {
+    private int hash;
+
+    public Key(Value value) {
+        super(value);
+    }
+
+    public Key(byte[] data) {
+        super(data);
+    }
+
+    public Key(byte[] data, int pos, int len) {
+        super(data, pos, len);
+    }
+
+    public Key(String data) {
+        super(data);
+    }
+    
+    @Override
+    public int hashCode() {
+        if( hash == 0 ) {
+            hash = super.hashCode();
+        }
+        return hash;
+    }
+    
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Record.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Record.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Record.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/Record.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id: Record.java 571953 2007-09-02 11:04:38Z vgritsenko $
+ */
+
+package org.apache.kahadb.xindice;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Record is a container for key/value pairs for a record in the database.
+ *
+ * @version $Revision: 571953 $, $Date: 2007-09-02 07:04:38 -0400 (Sun, 02 Sep 2007) $
+ */
+public final class Record {
+    private final Key key;
+    private final Value value;
+
+
+    public Record(Key key, Value value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    /**
+     * getKey returns the Record's Key.
+     *
+     * @return The Record's Key
+     */
+    public Key getKey() {
+        return key;
+    }
+
+    /**
+     * getValue returns the Record's Value.
+     *
+     * @return The Record's Value
+     */
+    public Value getValue() {
+        return value;
+    }
+
+}

Added: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/RecordSet.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/RecordSet.java?rev=677944&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/RecordSet.java (added)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/xindice/RecordSet.java Fri Jul 18 08:49:48 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id: RecordSet.java 541508 2007-05-25 01:54:12Z vgritsenko $
+ */
+
+package org.apache.kahadb.xindice;
+
+
+/**
+ * RecordSet is an interface for iterating over a set of Records.
+ * It is almost always returned by Filers.
+ *
+ * @version $Revision: 541508 $, $Date: 2007-05-24 21:54:12 -0400 (Thu, 24 May 2007) $
+ */
+public interface RecordSet {
+
+    /**
+     * hasMoreRecords returns whether or not there are any Records
+     * left in the set.
+     *
+     * @return Whether there are any more Records
+     */
+    boolean hasMoreRecords() throws IndexException;
+
+    /**
+     * getNextRecord returns the next Record in the set.
+     *
+     * @return The next Record
+     */
+    Record getNextRecord() throws IndexException;
+
+    /**
+     * getNextKey returns the next Record's Key, and skips the
+     * RecordSet ahead to the next Record.
+     *
+     * @return The next Key
+     */
+    Key getNextKey() throws IndexException;
+
+    /**
+     * getNextValue returns the next Record's Value, and skips the
+     * RecordSet ahead to the next Record.
+     *
+     * @return The next Value
+     */
+    Value getNextValue() throws IndexException;
+}



Mime
View raw message