kstaken     2003/02/07 09:09:06

  Added:       java/scratchpad/solemnis README build.xml
               java/scratchpad/solemnis/src/org/apache/xindice/core/file
                        Page.java PageFile.java PageFileTest.java
                        PageKey.java PageManager.java PageTestSuite.java
  Log:
  Some experimental code
  
  Revision  Changes    Path
  1.1                  xml-xindice/java/scratchpad/solemnis/README
  
  Index: README
  ===================================================================
  This directory contains experiments that may or may not find their way into a 
  future version of Xindice. It is not intended to be a standalone useful 
project.
  
  
  
  
  1.1                  xml-xindice/java/scratchpad/solemnis/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    - Build file for the solemnis Scratchpad Project.
    -
    - This script should be started with the following command line :
    -
    -     ant <target>
    -
    - Jakarta Ant can be downloaded from <http://jakarta.apache.org/ant>
    -
    - Run "ant -projecthelp" to get a list of available targets.
    -
    - Version: $Revision: 1.1 $ $Date: 2003/02/07 17:09:06 $
    - Author: Vladimir R. Bossicard ([EMAIL PROTECTED])
    -->
  
  <project name="xml-xindice-solemnis" default="compile" basedir=".">
  
     <property name="xindice.classes" value="../classes" />
  
     <property name="src.dir" value="src"/>
     <property name="jar.dir" value="lib"/>
     <property name="src.build.dir" value="classes"/>
     <property name="dist.dir" value="dist"/>
  
     <property name="compile.debug" value="on"/>
     <property name="compile.optimize" value="off"/>
     <property name="compile.nowarn" value="off"/>
     <property name="compile.deprecation" value="on"/>
     <property name="compile.verbose" value="off"/>
  
     <!-- Scratchpad classpath -->
     <path id="project.class.path">
        <pathelement location="${src.build.dir}"/>      
        <fileset dir="../../lib">
           <include name="*.jar"/>
        </fileset>
     </path>
  
     <target name="init">
        <tstamp/>
        <mkdir dir="${src.build.dir}"/>
        <mkdir dir="${dist.dir}"/>
     </target>
  
     <target name="compile"
             depends="init">
        <javac srcdir="${src.dir}"
               destdir="${src.build.dir}"
               debug="${compile.debug}"
               optimize="${compile.optimize}"
               nowarn="${compile.nowarn}"
               deprecation="${compile.deprecation}"
               verbose="${compile.verbose}">
           <!--classpath>
              <fileset dir="${jar.dir}">
                 <include name="*.jar"/>
              </fileset>
              <fileset dir="../../lib">
                 <include name="*.jar"/>
              </fileset>
              <fileset dir="../../dist">
                 <include name="*.jar"/>
              </fileset>
           </classpath-->
        </javac>
     </target>
  
      <target name="test"
              depends="compile">
          <junit fork="yes" printsummary="yes" haltonfailure="no">
              <jvmarg 
value="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog"
 />
              <jvmarg 
value="-Dorg.apache.commons.logging.simplelog.defaultlog=debug" />
              <test name="org.apache.xindice.core.file.PageTestSuite" />
              <formatter type="plain" usefile="no" />
              <classpath>
                  <path refid="project.class.path"/>
                  <pathelement location="${test.build.dir}"/>
              </classpath>
          </junit>
      </target>
      
     <target name="clean">
        <delete dir="${src.build.dir}"/>
        <delete dir="${dist.dir}"/>
     </target>
  
  </project>
  
  
  1.1                  
xml-xindice/java/scratchpad/solemnis/src/org/apache/xindice/core/file/Page.java
  
  Index: Page.java
  ===================================================================
  package org.apache.xindice.core.file;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: Page.java,v 1.1 2003/02/07 17:09:06 kstaken Exp $
   */
  
  public class Page {
     protected byte[] data;
     protected long pageNumber;
     protected long pinCount = 0;
     protected long lastAccess = 0;
     protected boolean isDirty = false;
  
     public Page(byte[] data, long pageNumber) {
        this.data = data;
        this.pageNumber = pageNumber;
     }
  
     public void writeData(byte[] data) {
  
     }
  
     public byte[] readData() {
        return data;
     }
  
     public long getLastAccess() {
        return lastAccess;
     }
  
     public long getPageNumber() {
        return pageNumber;
     }
  
     public byte[] getData() {
        return data;
     }
  
     public void setData(byte[] data) {
        this.data = data;
     }
  
     public synchronized void pin() {
        pinCount++;
     }
  
     public synchronized void unpin() {
        pinCount--;
     }
  }
  
  
  
  1.1                  
xml-xindice/java/scratchpad/solemnis/src/org/apache/xindice/core/file/PageFile.java
  
  Index: PageFile.java
  ===================================================================
  package org.apache.xindice.core.file;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: PageFile.java,v 1.1 2003/02/07 17:09:06 kstaken Exp $
   */
  
  import java.io.*;
  
  public class PageFile {
     public static final int HEADER_PAGE = 0;
  
     /* Version markers are used to determine compatibility of file changes.
        These numbers should be incremented anytime a change to the file format
        occurs. The minor version number is bumped when a backwards compatibile
        change is made and the major version is bumped when a non-backwards
        compatible change is made.
      */
     public static final int FILE_VERSION_MAJOR = 1;
     public static final int FILE_VERSION_MINOR = 0;
  
     public static final long INITIAL_EXTENT = 2048;
  
     // Header fields, these should be listed in the order in which they appear
     // in the file.
     protected int versionMajor = FILE_VERSION_MAJOR;
     protected int versionMinor = FILE_VERSION_MINOR;
     protected int pageSize = 4096;
     // Number of pages, not including the header page
     protected long numberOfPages = 0;
     protected long nextFreePage = 1;
     // End header fields
  
     protected boolean headerDirty = false;
  
     protected RandomAccessFile file;
  
     public PageFile(String filename, int pageSize) {
        try {
           this.pageSize = pageSize;
  
           File testFile = new File(filename);
           if ( ! testFile.exists() ) {
              createFile(testFile);
  
              // We're creating a new file so write a new header to it.
              writeHeader();
           }
           else {
              file = new RandomAccessFile(testFile, "rw");
              // Opening an existing file so read the header.
              readHeader();
           }
        }
        catch (Exception e) {
           e.printStackTrace();
        }
     }
  
     protected void createFile(File testFile) {
        try {
           file = new RandomAccessFile(testFile, "rw");
           file.seek(INITIAL_EXTENT * pageSize);
           file.write(1);
        }
        catch (Exception e) {
           e.printStackTrace();
        }
     }
  
     protected void readHeader() {
        try {
           Page page = readPage(HEADER_PAGE);
           ByteArrayInputStream bytes = new 
ByteArrayInputStream(page.getData());
           DataInputStream stream = new DataInputStream(bytes);
  
           versionMajor = stream.readInt();
           versionMinor = stream.readInt();
           pageSize = stream.readInt();
           numberOfPages = stream.readLong();
           nextFreePage = stream.readLong();
        }
        catch (Exception e) {
           e.printStackTrace();
        }
     }
  
     protected synchronized void writeHeader() {
        try {
           ByteArrayOutputStream bytes = new ByteArrayOutputStream(pageSize);
           DataOutputStream stream = new DataOutputStream(bytes);
  
           stream.writeInt(versionMajor);
           stream.writeInt(versionMinor);
           stream.writeInt(pageSize);
           stream.writeLong(numberOfPages);
           stream.writeLong(nextFreePage);
  
           Page page = new Page(bytes.toByteArray(), HEADER_PAGE);
           writePage(page);
        }
        catch (Exception e) {
           e.printStackTrace();
        }
     }
  
     public Page readPage(long pageNumber) {
        try {
           byte[] buffer = new byte[pageSize];
           synchronized(this) {
              file.seek(pageNumber * pageSize);
              file.read(buffer);
           }
  
           return new Page(buffer, pageNumber);
        }
        catch (Exception e) {
           e.printStackTrace();
           return null;
        }
     }
  
     public synchronized Page getFreePage() {
        try {
           long pageNumber = nextFreePage;
           byte[] buffer = new byte[pageSize];
           file.seek(pageNumber * pageSize);
           file.read(buffer);
  
           // Read the pointer to the next free page, or look to end of file.
           nextFreePage++;
           headerDirty = true;
  
           return new Page(buffer, pageNumber);
        }
        catch (Exception e) {
           e.printStackTrace();
           return null;
        }
     }
  
     public synchronized void writePage(Page page) {
        try {
           file.seek(page.getPageNumber() * pageSize);
           file.write(page.getData());
        }
        catch (Exception e) {
           e.printStackTrace();
        }
     }
  
     public void close() {
        try {
           if ( headerDirty ) {
              writeHeader();
           }
  
           file.close();
        }
        catch (Exception e) {
           e.printStackTrace();
        }
     }
  }
  
  
  1.1                  
xml-xindice/java/scratchpad/solemnis/src/org/apache/xindice/core/file/PageFileTest.java
  
  Index: PageFileTest.java
  ===================================================================
  package org.apache.xindice.core.file;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: PageFileTest.java,v 1.1 2003/02/07 17:09:06 kstaken Exp $
   */
  
  import junit.framework.*;
  import java.io.*;
  
  public class PageFileTest extends TestCase {
     PageFile file;
  
     public PageFileTest(String s) {
        super(s);
     }
  
     public void setUp() {
        file = new PageFile("test.dat", 4096);
     }
  
     public void tearDown() {
        // Delete the file
        file.close();
        File file2 = new File("test.dat");
        file2.delete();
     }
  
     public void testInit() {
        assertTrue(file.numberOfPages == 0);
     }
  
     public void testGetFreePage() {
        Page page = file.getFreePage();
        assertTrue(page != null);
        assertTrue(page.getPageNumber() == 1);
  
     }
  
     public void testReadPage() {
        // Test reading the header page since it's the only page in the file
        // at this point.
        Page page = file.readPage(PageFile.HEADER_PAGE);
        assertTrue(page != null);
        try {
           ByteArrayInputStream bytes = new 
ByteArrayInputStream(page.getData());
           DataInputStream stream = new DataInputStream(bytes);
  
           assertTrue(stream.readInt() > 0);
           assertTrue(stream.readInt() == 0);
           assertTrue(stream.readInt() == 4096);
           assertTrue(stream.readLong() == 0);
        }
        catch (Exception e) {
           this.fail(e.toString());
        }
     }
  }
  
  
  1.1                  
xml-xindice/java/scratchpad/solemnis/src/org/apache/xindice/core/file/PageKey.java
  
  Index: PageKey.java
  ===================================================================
  package org.apache.xindice.core.file;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: PageKey.java,v 1.1 2003/02/07 17:09:06 kstaken Exp $
   */
  
  /**
   * Enacapsulates a page reference. A page is identified by the fileID in
   * which it is located and by the page number within that file.
   */
  public class PageKey {
     private long fileID;
     private long pageID;
  
     public PageKey(long fileID, long pageID) {
        this.fileID = fileID;
        this.pageID = pageID;
     }
  
     public long getFileID() {
        return fileID;
     }
  
     public long getPageID() {
        return fileID;
     }
  }
  
  
  1.1                  
xml-xindice/java/scratchpad/solemnis/src/org/apache/xindice/core/file/PageManager.java
  
  Index: PageManager.java
  ===================================================================
  package org.apache.xindice.core.file;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: PageManager.java,v 1.1 2003/02/07 17:09:06 kstaken Exp $
   */
  
  import java.util.*;
  import java.io.*;
  
  public class PageManager {
     private List fileList;
     private Map pageCache;
     private PageManager theInstance;
  
     private PageManager() {
        fileList =  Collections.synchronizedList(new ArrayList());
        pageCache = Collections.synchronizedMap(new HashMap());
     }
  
     public PageManager getPageManager() {
        if ( theInstance == null ) {
           theInstance = new PageManager();
        }
  
        return theInstance;
     }
  
     public Page getPage(PageKey key) {
        return null;
     }
  
     public void setPage(PageKey key, Page page) {
  
     }
  
     public void releasePage(PageKey key) {
  
     }
  
     /**
      * Registers a new file to be managed by the PageManager. The fileID for 
the
      * file is returned. The fileID is to be considered a transient ID and
      * should not be preserved across database executions.
      */
     public long registerFile(String filename) {
        int pageSize = 4096;
  
        PageFile file = new PageFile(filename, pageSize);
  
        fileList.add(file);
  
        return fileList.indexOf(file);
     }
  }
  
  
  1.1                  
xml-xindice/java/scratchpad/solemnis/src/org/apache/xindice/core/file/PageTestSuite.java
  
  Index: PageTestSuite.java
  ===================================================================
  package org.apache.xindice.core.file;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: PageTestSuite.java,v 1.1 2003/02/07 17:09:06 kstaken Exp $
   */
  
  import junit.framework.*;
  
  public class PageTestSuite extends TestSuite {
     public PageTestSuite( String s ) {
         super( s );
     }
  
     public static Test suite(){
         TestSuite theSuite = new TestSuite();
  
         theSuite.addTestSuite( PageFileTest.class );
         return theSuite;
     }
  
     public static void main( String[] args ){
         junit.textui.TestRunner.run( PageTestSuite.class );
     }
  }
  
  

Reply via email to