activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r677302 [1/4] - in /activemq/sandbox/xindice-stripped: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/xindice/ src/main/java/org/apache/xindice/core/ src/main/java/org/apache/xindice/c...
Date Wed, 16 Jul 2008 15:18:22 GMT
Author: chirino
Date: Wed Jul 16 08:18:20 2008
New Revision: 677302

URL: http://svn.apache.org/viewvc?rev=677302&view=rev
Log:
adding a stripped down version of xindice for research purposes

Added:
    activemq/sandbox/xindice-stripped/README
    activemq/sandbox/xindice-stripped/pom.xml   (with props)
    activemq/sandbox/xindice-stripped/src/
    activemq/sandbox/xindice-stripped/src/main/
    activemq/sandbox/xindice-stripped/src/main/java/
    activemq/sandbox/xindice-stripped/src/main/java/org/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBException.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBObject.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/FaultCodes.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Entry.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Key.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/NodeSet.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Record.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/RecordSet.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Value.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/package.html
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/BTree.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/BTreeCallback.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/BTreeCorruptException.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/BTreeException.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/BTreeFiler.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/BTreeNotFoundException.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/FSFiler.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/Filer.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/FilerException.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/HashFiler.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/MemFiler.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/Paged.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/SizeableMemFiler.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/Streamable.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/filer/package.html
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/package.html
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/util/
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/util/FileCache.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/util/IntrospectionSupport.java   (with props)
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/util/LockManager.java
    activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/util/package.html
    activemq/sandbox/xindice-stripped/src/main/resources/
    activemq/sandbox/xindice-stripped/src/test/
    activemq/sandbox/xindice-stripped/src/test/java/
    activemq/sandbox/xindice-stripped/src/test/java/org/
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/filer/
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/filer/BTreeFilerTest.java
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/filer/FSFilerTest.java
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/filer/FilerTestBase.java
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/filer/HashFilerTest.java
    activemq/sandbox/xindice-stripped/src/test/java/org/apache/xindice/core/filer/MemFilerTest.java
    activemq/sandbox/xindice-stripped/src/test/resources/

Added: activemq/sandbox/xindice-stripped/README
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/README?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/README (added)
+++ activemq/sandbox/xindice-stripped/README Wed Jul 16 08:18:20 2008
@@ -0,0 +1,18 @@
+=======================================================================
+ Some Q&A to explain this module.
+=======================================================================
+
+Q: What is this?
+A: This is basically Apache Xindice stripped down to the low level
+   indexing logic.
+   
+Q: Why did you strip it down?
+A: To make it simpler to understand so that it's logic can more easily 
+   be ported.
+   
+Q: Why do you want to port it's logic
+A: Because ActiveMQ data stores need to index data, and it might
+   provide a better indexing implementation than what we currently have. 
+   
+Q: What Apache Xindice version is this code based on?
+A: http://svn.apache.org/repos/asf/xml/xindice/trunk revision 676934

Added: activemq/sandbox/xindice-stripped/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/pom.xml?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/pom.xml (added)
+++ activemq/sandbox/xindice-stripped/pom.xml Wed Jul 16 08:18:20 2008
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache</groupId>
+    <artifactId>apache</artifactId>
+    <version>4</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.activemq</groupId>
+  <artifactId>xindice-stripped</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: activemq/sandbox/xindice-stripped/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBException.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBException.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBException.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBException.java Wed Jul 16 08:18:20 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.xindice.core;
+
+
+/**
+ * A DBException is thrown by the database if an exception occurs in the
+ * managing (creating, dropping) database objects such as Collections,
+ * Indexes, and XMLObjects.
+ *
+ * @version $Revision: 564998 $, $Date: 2007-08-11 22:51:49 -0400 (Sat, 11 Aug 2007) $
+ */
+public class DBException extends Exception {
+    public final int faultCode;
+
+    public DBException() {
+        this(FaultCodes.GEN_UNKNOWN, "", null);
+    }
+
+    public DBException(int faultCode) {
+        this(faultCode, "", null);
+    }
+
+    public DBException(int faultCode, String message) {
+        this(faultCode, message, null);
+    }
+
+    public DBException(int faultCode, String message, Throwable cause) {
+        super(message, cause);
+        this.faultCode = faultCode;
+    }
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBObject.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBObject.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBObject.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/DBObject.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,86 @@
+/*
+ * 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: DBObject.java 564832 2007-08-11 04:18:09Z vgritsenko $
+ */
+
+package org.apache.xindice.core;
+
+/**
+ * DBObject is the interface implemented by all Xindice database objects.
+ * DBObjects are typically objects that can be managed using XML
+ * configuration information, which is typically stored in the system
+ * database.  XMLObjects are not considered DBObjects because of the
+ * steps involved in having to generate them, which is usually
+ * compilation of source code.
+ *
+ * @version $Revision: 564832 $, $Date: 2007-08-11 00:18:09 -0400 (Sat, 11 Aug 2007) $
+ */
+public interface DBObject {
+
+    /**
+     * create creates a new DBObject and any associated resources for the new
+     * DBObject, such as disk files, etc.
+     *
+     * @return Whether or not the DBObject was created
+     * @throws DBException if operation failed
+     */
+    boolean create() throws DBException;
+
+    /**
+     * open opens the DBObject
+     *
+     * @return Whether or not the DBObject was opened
+     * @throws DBException if operation failed
+     */
+    boolean open() throws DBException;
+
+    /**
+     * 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 DBException if operation failed
+     */
+    boolean exists() throws DBException;
+
+    /**
+     * 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 DBException if operation failed
+     */
+    boolean drop() throws DBException;
+
+    /**
+     * close closes the DBObject
+     *
+     * @return Whether or not the DBObject was closed
+     * @throws DBException if operation failed
+     */
+    boolean close() throws DBException;
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/FaultCodes.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/FaultCodes.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/FaultCodes.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/FaultCodes.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,354 @@
+/*
+ * 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.xindice.core;
+
+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 faultMessages = new HashMap();
+
+    private static final Map faultCodesToErrorCodesMap = new HashMap();
+
+    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");
+
+        addFaultCodeToErrorCodeMap(GEN_UNKNOWN, UNKNOWN_ERROR);
+        addFaultCodeToErrorCodeMap(GEN_GENERAL_ERROR, UNKNOWN_ERROR);
+        addFaultCodeToErrorCodeMap(GEN_CRITICAL_ERROR, UNKNOWN_ERROR);
+        addFaultCodeToErrorCodeMap(GEN_FATAL_ERROR, UNKNOWN_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");
+
+        addFaultCodeToErrorCodeMap(COL_COLLECTION_NOT_FOUND, NO_SUCH_COLLECTION);
+        addFaultCodeToErrorCodeMap(COL_DOCUMENT_NOT_FOUND, NO_SUCH_RESOURCE);
+        addFaultCodeToErrorCodeMap(COL_DUPLICATE_COLLECTION, INVALID_COLLECTION);
+        addFaultCodeToErrorCodeMap(COL_NULL_RESULT, INVALID_COLLECTION);
+        addFaultCodeToErrorCodeMap(COL_NO_FILER, INVALID_COLLECTION);
+        addFaultCodeToErrorCodeMap(COL_NO_INDEXMANAGER, INVALID_COLLECTION);
+        addFaultCodeToErrorCodeMap(COL_DOCUMENT_MALFORMED, INVALID_RESOURCE);
+        addFaultCodeToErrorCodeMap(COL_CANNOT_STORE, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(COL_CANNOT_RETRIEVE, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(COL_COLLECTION_READ_ONLY, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(COL_COLLECTION_CLOSED, COLLECTION_CLOSED);
+        addFaultCodeToErrorCodeMap(COL_CANNOT_CREATE, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(COL_CANNOT_DROP, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(COL_INVALID_RESULT, VENDOR_ERROR);
+
+        // 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");
+
+        addFaultCodeToErrorCodeMap(IDX_VALUE_NOT_FOUND, INVALID_RESOURCE);
+        addFaultCodeToErrorCodeMap(IDX_INDEX_NOT_FOUND, NO_SUCH_RESOURCE);
+        addFaultCodeToErrorCodeMap(IDX_MATCHES_NOT_FOUND, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(IDX_DUPLICATE_INDEX, INVALID_RESOURCE);
+        addFaultCodeToErrorCodeMap(IDX_NOT_SUPPORTED, NOT_IMPLEMENTED);
+        addFaultCodeToErrorCodeMap(IDX_STYLE_NOT_FOUND, NO_SUCH_RESOURCE);
+        addFaultCodeToErrorCodeMap(IDX_CORRUPTED, INVALID_RESOURCE);
+        addFaultCodeToErrorCodeMap(IDX_CANNOT_CREATE, VENDOR_ERROR);
+
+        // 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");
+
+        addFaultCodeToErrorCodeMap(TRX_DOC_LOCKED, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(TRX_NO_CONTEXT, INVALID_RESOURCE);
+        addFaultCodeToErrorCodeMap(TRX_NOT_ACTIVE, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(TRX_NOT_SUPPORTED, VENDOR_ERROR);
+
+        // 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");
+
+        addFaultCodeToErrorCodeMap(DBE_NO_PARENT, INVALID_DATABASE);
+        addFaultCodeToErrorCodeMap(DBE_CANNOT_DROP, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(DBE_CANNOT_CREATE, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(DBE_CANNOT_READ, VENDOR_ERROR);
+
+        // 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");
+
+        addFaultCodeToErrorCodeMap(QRY_NULL_RESULT, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(QRY_COMPILATION_ERROR, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(QRY_PROCESSING_ERROR, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(QRY_NOT_SUPPORTED, VENDOR_ERROR);
+        addFaultCodeToErrorCodeMap(QRY_STYLE_NOT_FOUND, VENDOR_ERROR);
+
+        // 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");
+
+        addFaultCodeToErrorCodeMap(SEC_INVALID_USER, PERMISSION_DENIED);
+        addFaultCodeToErrorCodeMap(SEC_INVALID_GROUP, PERMISSION_DENIED);
+        addFaultCodeToErrorCodeMap(SEC_INVALID_ACCESS, PERMISSION_DENIED);
+        addFaultCodeToErrorCodeMap(SEC_INVALID_CREDENTIALS, PERMISSION_DENIED);
+
+        // URI-related errors 800 series
+        putCodeMessage(URI_EMPTY, "URI Empty");
+        putCodeMessage(URI_NULL, "URI Null");
+        putCodeMessage(URI_PARSE_ERROR, "URI Parse Error");
+
+        addFaultCodeToErrorCodeMap(URI_EMPTY, INVALID_URI);
+        addFaultCodeToErrorCodeMap(URI_NULL, INVALID_URI);
+        addFaultCodeToErrorCodeMap(URI_PARSE_ERROR, INVALID_URI);
+
+        // 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);
+    }
+
+    private static void addFaultCodeToErrorCodeMap(int code, int errCode) {
+        faultCodesToErrorCodesMap.put(new Integer(code), new Integer(errCode));
+    }
+
+    /**
+     * getErrorCode returns the associated XML:DB error code for the
+     * specified Xindice fault code
+     *
+     * @param faultCode The Xindice fault code
+     * @return the associated XML:DB error code
+     */
+    public static int getErrorCode(int faultCode) {
+        Object err = faultCodesToErrorCodesMap.get(new Integer(faultCode));
+        if (err == null) {
+            return UNKNOWN_ERROR;
+        } else {
+            return ((Integer) err).intValue();
+        }
+    }
+
+    /**
+     * 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 = (String) 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 DBException) {
+            code = ((DBException) 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 DBException) {
+            code = ((DBException) 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 DBException) {
+            return ((DBException) 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/xindice-stripped/src/main/java/org/apache/xindice/core/data/Entry.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Entry.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Entry.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Entry.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,102 @@
+/*
+ * 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: Entry.java 594588 2007-11-13 17:21:25Z vgritsenko $
+ */
+
+package org.apache.xindice.core.data;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+/**
+ * Entry is a high-level representation of a database record, that includes
+ * its internal meta information.
+ *
+ * @version $Revision: 594588 $, $Date: 2007-11-13 12:21:25 -0500 (Tue, 13 Nov 2007) $
+ */
+public class Entry {
+
+    public static final byte UNKNOWN  = 0;
+    public static final byte DOCUMENT = 1;
+    public static final byte BINARY   = 2;
+    public static final byte OBJECT   = 3;
+
+    public static final String CREATED  = "created";
+    public static final String MODIFIED = "modified";
+
+    private final byte type;
+    private final Key key;
+    private final Object value;
+    private final Map meta;
+
+
+    public Entry(byte type, Key key, Object value, Map meta) {
+        this.type = type;
+        this.key = key;
+        this.value = value;
+        this.meta = meta;
+    }
+
+    public Entry(Key key, Document value, Map meta) {
+        this(DOCUMENT, key, value, meta);
+    }
+
+    public Entry(Key key, byte[] value, Map meta) {
+        this(BINARY, key, value, meta);
+    }
+
+    public Entry(Key key, Map meta) {
+        this(UNKNOWN, key, null, meta);
+    }
+
+
+    public byte getEntryType() {
+        return type;
+    }
+
+    public Key getKey() {
+        return key;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public Map getMeta() {
+        return meta;
+    }
+
+    public long getCreationTime() {
+        Long date = (Long) meta.get(CREATED);
+        return date != null ? date.longValue() : 0;
+    }
+
+    public long getModificationTime() {
+        Long date = (Long) meta.get(MODIFIED);
+        return date != null ? date.longValue() : 0;
+    }
+
+    public static Map createMetaMap(Record record) {
+        Map entryMeta = new HashMap(5);
+        entryMeta.put(Entry.CREATED,  record.getMetaData(Record.CREATED));
+        entryMeta.put(Entry.MODIFIED, record.getMetaData(Record.MODIFIED));
+        return Collections.unmodifiableMap(entryMeta);
+    }
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Key.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Key.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Key.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Key.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.xindice.core.data;
+
+/**
+ * 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 {
+
+    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);
+    }
+
+    public boolean equals(Value value) {
+        return hashCode() == value.hashCode() && compareTo(value) == 0;
+    }
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/NodeSet.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/NodeSet.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/NodeSet.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/NodeSet.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,45 @@
+/*
+ * 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: NodeSet.java 541508 2007-05-25 01:54:12Z vgritsenko $
+ */
+
+package org.apache.xindice.core.data;
+
+
+/**
+ * NodeSet is an interface for iterating over a set of Nodes.  NodeSets
+ * are generally returned by the QueryEngine.
+ *
+ * @version $Revision: 541508 $, $Date: 2007-05-24 21:54:12 -0400 (Thu, 24 May 2007) $
+ */
+public interface NodeSet {
+
+    /**
+     * hasMoreNodes returns whether or not there are any Nodes remaining
+     * in the NodeSet.
+     *
+     * @return Whether there are any more Nodes
+     */
+    boolean hasMoreNodes();
+
+    /**
+     * getNextNode returns the next Node from the NodeSet.
+     *
+     * @return The next Node
+     */
+    Object getNextNode();
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Record.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Record.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Record.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Record.java Wed Jul 16 08:18:20 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.
+ *
+ * $Id: Record.java 571953 2007-09-02 11:04:38Z vgritsenko $
+ */
+
+package org.apache.xindice.core.data;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Record is a container for key/value pairs and all meta data stored
+ * with this record in the database.
+ *
+ * @version $Revision: 571953 $, $Date: 2007-09-02 07:04:38 -0400 (Sun, 02 Sep 2007) $
+ */
+public final class Record {
+    public static final String CREATED  = "created";
+    public static final String MODIFIED = "modified";
+
+    public static final String OWNER = "owner";
+    public static final String GROUP = "group";
+
+    private final Key key;
+    private final Value value;
+    private final Map meta;
+
+
+    public Record(Key key, Value value) {
+        this.key = key;
+        this.value = value;
+        this.meta = Collections.EMPTY_MAP;
+    }
+
+    public Record(Key key, Value value, Map meta) {
+        this.key = key;
+        this.value = value;
+        this.meta = meta;
+    }
+
+    /**
+     * 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;
+    }
+
+    /**
+     * getMetaData returns metadata about the Value.
+     *
+     * @param name The property name
+     * @return The metadata value
+     */
+    public Object getMetaData(Object name) {
+        return meta.get(name);
+    }
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/RecordSet.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/RecordSet.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/RecordSet.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/RecordSet.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.xindice.core.data;
+
+import org.apache.xindice.core.DBException;
+
+/**
+ * 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 DBException;
+
+    /**
+     * getNextRecord returns the next Record in the set.
+     *
+     * @return The next Record
+     */
+    Record getNextRecord() throws DBException;
+
+    /**
+     * getNextKey returns the next Record's Key, and skips the
+     * RecordSet ahead to the next Record.
+     *
+     * @return The next Key
+     */
+    Key getNextKey() throws DBException;
+
+    /**
+     * getNextValue returns the next Record's Value, and skips the
+     * RecordSet ahead to the next Record.
+     *
+     * @return The next Value
+     */
+    Value getNextValue() throws DBException;
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Value.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Value.java?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Value.java (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/Value.java Wed Jul 16 08:18:20 2008
@@ -0,0 +1,314 @@
+/*
+ * 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: Value.java 594315 2007-11-12 22:10:44Z vgritsenko $
+ */
+
+package org.apache.xindice.core.data;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Value is the primary base class for all data storing objects.
+ * The content window of value objects are immutable, but the
+ * underlying byte array which was used for constructing the value might be not.
+ *
+ * @version $Revision: 594315 $, $Date: 2007-11-12 17:10:44 -0500 (Mon, 12 Nov 2007) $
+ */
+public class Value implements Comparable {
+
+    private final byte[] data;
+    private final int pos;
+    private final int len;
+    private int hash;
+
+    /**
+     * Usually there is no need to create a copy of the value, since it is
+     * an immutable object. This constructor is mainly used to create
+     * key objects.
+     *
+     * @param value the value object which data will be used to construct this
+     *        value. 
+     */
+    public Value(Value value) {
+        this.data = value.data;
+        this.pos = value.pos;
+        this.len = value.len;
+    }
+
+    public Value(byte[] data) {
+        this.data = data;
+        this.pos = 0;
+        this.len = data.length;
+    }
+
+    public Value(byte[] data, int pos, int len) {
+        if (pos >= data.length || pos < 0 || pos + len > data.length) {
+            throw new ArrayIndexOutOfBoundsException("Value cannot be created");
+        }
+
+        this.data = data;
+        this.pos = pos;
+        this.len = len;
+    }
+
+    public Value(String data) {
+        try {
+            this.data = data.getBytes("utf-8");
+            this.pos = 0;
+            this.len = this.data.length;
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("Java doesn't support UTF-8 encoding", e);
+        }
+    }
+
+    /**
+     * getLength retrieves the length of the data being stored by the Value.
+     *
+     * @return The Value length
+     */
+    public final int getLength() {
+        return len;
+    }
+
+    /**
+     * getData retrieves a copy of the data which is being stored
+     * by this value as a byte array.
+     *
+     * <p>Data copying is performed in order to ensure immutability of the Value.
+     * Avoid using this method if possible.
+     *
+     * @return The data
+     */
+    public final byte[] getData() {
+        byte[] b = new byte[len];
+        System.arraycopy(data, pos, b, 0, len);
+        return b;
+    }
+
+    //
+    // Data extraction
+    //
+
+    /**
+     * Returns the byte at the specified index.
+     *
+     * @param index byte index
+     * @return the byte at the specified index.
+     * @throws ArrayIndexOutOfBoundsException if index is negative number or
+     *         is not less that the length of Value data
+     */
+    public final byte byteAt(int index) {
+        if (index < 0 || index >= len) {
+            throw new ArrayIndexOutOfBoundsException(index);
+        }
+        return data[pos + index];
+    }
+
+    /**
+     * Returns the short value at the specified index.
+     *
+     * @param index short index
+     * @return the short at the specified index.
+     * @throws ArrayIndexOutOfBoundsException if index is negative number or
+     *         is not less that the length of the data array
+     */
+    public final short shortAt(int index) {
+        return (short) ((data[index += pos] << 8) | data[index + 1]);
+    }
+
+    /**
+     * Returns the int value at the specified index.
+     *
+     * @param index int index
+     * @return the int at the specified index.
+     * @throws ArrayIndexOutOfBoundsException if index is negative number or
+     *         is not less that the length of the data array
+     */
+    public final int intAt(int index) {
+        return (short) ((data[index += pos] << 24) | (data[index + 1] << 16) | (data[index + 2] << 8) | data[index + 3]);
+    }
+
+    /**
+     * Get a value that is part of this value object.
+     *
+     * @param start beginning index
+     * @param len length of the new value
+     * @return Value object
+     * @throws ArrayIndexOutOfBoundsException if start index is either negative
+     *         or isn't less then length of original Value
+     */
+    public final Value valueAt(int start, int len) {
+        return new Value(data, pos + start, len);
+    }
+
+    /**
+     * Get a key that is part of this value object.
+     *
+     * @param start beginning index
+     * @param len length of the new key
+     * @return Key object
+     * @throws ArrayIndexOutOfBoundsException if start index is either negative
+     *         or isn't less then length of original Value
+     */
+    public final Key keyAt(int start, int len) {
+        return new Key(data, pos + start, len);
+    }
+
+    //
+    // I/O
+    //
+
+    /**
+     * Return an InputStream for the value.
+     *
+     * @return An InputStream
+     */
+    public final InputStream getInputStream() {
+        return new ByteArrayInputStream(data, pos, len);
+    }
+
+    /**
+     * Stream the content of the value into an OutputStream.
+     *
+     * @param out the OutputStream
+     * @throws IOException if write failed
+     */
+    public final void streamTo(OutputStream out) throws IOException {
+        out.write(data, pos, len);
+    }
+
+    /**
+     * Copy contents of the value into supplied byte array.
+     *
+     * @param tdata byte array for the value
+     * @param tpos starting position
+     */
+    public final void copyTo(byte[] tdata, int tpos) {
+        System.arraycopy(data, pos, tdata, tpos, len);
+    }
+
+    /**
+     * Copy <code>len</code> bytes of value's content into supplied
+     * byte array.
+     *
+     * @param tdata byte array for the value
+     * @param tpos starting position
+     * @param len count of bytes to copy
+     */
+    public final void copyTo(byte[] tdata, int tpos, int len) {
+        System.arraycopy(data, pos, tdata, tpos, len);
+    }
+
+    //
+    // Comparisons
+    //
+
+    public final boolean startsWith(Value value) {
+        if (len < value.len) {
+            return false;
+        }
+
+        byte[] ddata = value.data;
+        int dpos = value.pos;
+
+        for (int i = 0; i < value.len; i++) {
+            if (data[i + pos] != ddata[i + dpos]) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public final int compareTo(Value value) {
+        byte[] ddata = value.data;
+        int dpos = value.pos;
+        int dlen = value.len;
+
+        int stop = len > dlen ? dlen : len;
+
+        for (int i = 0; i < stop; i++) {
+            byte b1 = data[pos + i];
+            byte b2 = ddata[dpos + i];
+
+            if (b1 != b2) {
+                // get unsigned value
+                int s1 = ((int) b1) & 0xFF;
+                int s2 = ((int) b2) & 0xFF;
+                return s1 > s2 ? (i + 1) : -(i + 1);
+            }
+        }
+
+        if (len == dlen) {
+            return 0;
+        } else {
+            return len > dlen ? stop + 1 : -(stop + 1);
+        }
+    }
+
+    public final int compareTo(Object obj) {
+        if (obj instanceof Value) {
+            return compareTo((Value) obj);
+        }
+
+        return compareTo(new Value(obj.toString()));
+    }
+
+    //
+    // Object
+    //
+
+    public int hashCode() {
+        // modeled after String.hashCode()
+        if (hash == 0) {
+            int tempHash = 0;
+            for (int i = 0; i < len; i++) {
+                tempHash = 31 * tempHash + data[pos + i];
+            }
+            this.hash = Math.abs(tempHash);
+        }
+        return hash;
+    }
+
+    public boolean equals(Value value) {
+        return len == value.len && compareTo(value) == 0;
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj instanceof Value) {
+            return equals((Value) obj);
+        }
+
+        return obj != null && equals(new Value(obj.toString()));
+    }
+
+    public final String toString() {
+        try {
+            return new String(data, pos, len, "utf-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("Java doesn't seem to support UTF-8!", e);
+        }
+    }
+}

Added: activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/package.html
URL: http://svn.apache.org/viewvc/activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/package.html?rev=677302&view=auto
==============================================================================
--- activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/package.html (added)
+++ activemq/sandbox/xindice-stripped/src/main/java/org/apache/xindice/core/data/package.html Wed Jul 16 08:18:20 2008
@@ -0,0 +1,28 @@
+<!--
+  - 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: package.html 511410 2007-02-25 02:47:42Z vgritsenko $
+  -->
+
+<html>
+  <title>Basic Data Types and Containers.</title>
+  <body>
+    <p>Defines and Implements several basic data types and container
+    interfaces, including Key, Value, DocumentSet and NodeSet.</p>
+ </body>
+</html>
+
+



Mime
View raw message