[jsword-svn] r1699 - in trunk/jsword/src/main/java/org/crosswire/jsword/book: . basic

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Tue Oct 9 12:34:39 MST 2007


Author: dmsmith
Date: 2007-10-09 12:34:39 -0700 (Tue, 09 Oct 2007)
New Revision: 1699

Added:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.properties
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookmarkFactory.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java
Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.java
Log:
Stubbed implementation of a Bookmark.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.java	2007-10-09 19:06:36 UTC (rev 1698)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.java	2007-10-09 19:34:39 UTC (rev 1699)
@@ -35,7 +35,7 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public interface Bookmark extends Serializable
+public interface Bookmark extends Serializable, Cloneable
 {
     /**
      * Add a Book to this Bookmark.
@@ -88,4 +88,11 @@
      * @return the resulting BookData
      */
     BookData getBookData();
+
+    /**
+     * This needs to be declared here so that it is visible as a method
+     * on a derived Bookmark.
+     * @return A complete copy of ourselves
+     */
+    Object clone();
 }

Added: trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.properties
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.properties	                        (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Bookmark.properties	2007-10-09 19:34:39 UTC (rev 1699)
@@ -0,0 +1,2 @@
+
+default=org.crosswire.jsword.book.basic.DefaultBookmark

Added: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookmarkFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookmarkFactory.java	                        (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookmarkFactory.java	2007-10-09 19:34:39 UTC (rev 1699)
@@ -0,0 +1,97 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: IndexManagerFactory.java 1505 2007-07-21 19:40:19Z dmsmith $
+ */
+package org.crosswire.jsword.book;
+
+import java.io.IOException;
+
+import org.crosswire.common.util.ClassUtil;
+import org.crosswire.common.util.Logger;
+import org.crosswire.jsword.index.IndexManager;
+
+/**
+ * A Factory class for Bookmarks.
+ *
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+
+ */
+public final class BookmarkFactory
+{
+    /**
+     * Prevent instantiation
+     */
+    private BookmarkFactory()
+    {
+    }
+
+    /**
+     * Create a new Bookmark.
+     */
+    public static Bookmark getBookmark()
+    {
+        return (Bookmark) 
+        instance.clone();
+    }
+
+    /**
+     * The singleton
+     */
+    private static Bookmark instance;
+
+    /**
+     * The log stream
+     */
+    private static final Logger log = Logger.getLogger(BookmarkFactory.class);
+
+    /**
+     * Setup the instance
+     */
+    static
+    {
+        try
+        {
+            Class impl = ClassUtil.getImplementor(Bookmark.class);
+            instance = (Bookmark) impl.newInstance();
+        }
+        catch (IOException e)
+        {
+            log.error("createBookmark failed", e); //$NON-NLS-1$
+        }
+        catch (ClassCastException e)
+        {
+            log.error("createBookmark failed", e); //$NON-NLS-1$
+        }
+        catch (ClassNotFoundException e)
+        {
+            log.error("createBookmark failed", e); //$NON-NLS-1$
+        }
+        catch (IllegalAccessException e)
+        {
+            log.error("createBookmark failed", e); //$NON-NLS-1$
+        }
+        catch (InstantiationException e)
+        {
+            log.error("createBookmark failed", e); //$NON-NLS-1$
+        }
+    }
+}

Added: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java	                        (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java	2007-10-09 19:34:39 UTC (rev 1699)
@@ -0,0 +1,148 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2007
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: Bookmark.java 1605 2007-08-03 21:34:46Z dmsmith $
+ */
+package org.crosswire.jsword.book.basic;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.Bookmark;
+import org.crosswire.jsword.index.search.SearchRequest;
+
+
+/**
+ * A Bookmark remembers a particular view of one or more Books.
+ * What is viewed regarding a book set is either a SearchRequest
+ * or a key lookup request.
+ *
+ * @see gnu.gpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class DefaultBookmark implements Bookmark
+{
+    /**
+     * Add a Book to this Bookmark.
+     * The books are maintained in the order they are added as a set.
+     * 
+     * @param book the Book to add.
+     */
+    public void addBook(Book book)
+    {
+        books.add(book);
+    }
+
+    /**
+     * Return the ordered set of books.
+     * @return
+     */
+    public List getBooks()
+    {
+        return Collections.unmodifiableList(books);
+    }
+
+    /**
+     * Set the SearchRequest for this Bookmark. A copy of the SearchRequest will be stored.
+     * Note, setting this will clear the lookup request, if any.
+     * 
+     * @param request the SearchRequest
+     */
+    public void setSearchRequest(SearchRequest request)
+    {
+        searchRequest = request;
+        lookupRequest = null;
+    }
+
+    /**
+     * Get the SearchRequest for this Bookmark.
+     * 
+     * @return a copy of the SearchRequest, or null.
+     */
+    public SearchRequest getSearchRequest()
+    {
+        return searchRequest;
+    }
+
+    /**
+     * Set the lookup request for this Bookmark.
+     * Note, setting this will clear the SearchRequest, if any.
+     * 
+     * @param request the lookup request.
+     */
+    public void setLookupRequest(String request)
+    {
+        lookupRequest = request;
+        searchRequest = null;
+    }
+
+    /**
+     * Get the lookup request.
+     * 
+     * @return the lookup request or null.
+     */
+    public String getLookupRequest()
+    {
+        return lookupRequest;
+    }
+
+    /**
+     * Convert this Bookmark into a BookData by converting the SearchReqeust or lookup request
+     * into a key list.
+     * 
+     * @return the resulting BookData
+     */
+    public BookData getBookData()
+    {
+        return null;
+    }
+
+    /**
+     * This needs to be declared here so that it is visible as a method
+     * on a derived Bookmark.
+     * @return A complete copy of ourselves
+     */
+    public Object clone()
+    {
+        return null;
+    }
+
+    /**
+     * The list of books.
+     */
+    private List books;
+
+    /**
+     * The lookup request.
+     */
+    private String lookupRequest;
+
+    /**
+     * The search request.
+     */
+    private SearchRequest searchRequest;
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = 6959196267292499574L;
+}




More information about the jsword-svn mailing list