1   /**
2    * Distribution License:
3    * JSword is free software; you can redistribute it and/or modify it under
4    * the terms of the GNU Lesser General Public License, version 2.1 as published by
5    * the Free Software Foundation. This program is distributed in the hope
6    * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8    * See the GNU Lesser General Public License for more details.
9    *
10   * The License is available on the internet at:
11   *       http://www.gnu.org/copyleft/lgpl.html
12   * or by writing to:
13   *      Free Software Foundation, Inc.
14   *      59 Temple Place - Suite 330
15   *      Boston, MA 02111-1307, USA
16   *
17   * Copyright: 2007
18   *     The copyright to this program is held by it's authors.
19   *
20   * ID: $Id: Bookmark.java 1605 2007-08-03 21:34:46Z dmsmith $
21   */
22  package org.crosswire.jsword.book.basic;
23  
24  import java.util.ArrayList;
25  import java.util.Collections;
26  import java.util.List;
27  
28  import org.crosswire.jsword.book.Book;
29  import org.crosswire.jsword.book.BookData;
30  import org.crosswire.jsword.book.Bookmark;
31  import org.crosswire.jsword.index.search.SearchRequest;
32  
33  /**
34   * A Bookmark remembers a particular view of one or more Books. What is viewed
35   * regarding a book set is either a SearchRequest or a key lookup request.
36   * 
37   * @see gnu.lgpl.License for license details.<br>
38   *      The copyright to this program is held by it's authors.
39   * @author DM Smith [dmsmith555 at yahoo dot com]
40   */
41  public class DefaultBookmark implements Bookmark {
42      /**
43       * Create an empty default bookmark
44       */
45      public DefaultBookmark() {
46          books = new ArrayList<Book>();
47      }
48  
49      /* (non-Javadoc)
50       * @see org.crosswire.jsword.book.Bookmark#addBook(org.crosswire.jsword.book.Book)
51       */
52      public void addBook(Book book) {
53          books.add(book);
54      }
55  
56      /* (non-Javadoc)
57       * @see org.crosswire.jsword.book.Bookmark#getBooks()
58       */
59      public List<Book> getBooks() {
60          return Collections.unmodifiableList(books);
61      }
62  
63      /* (non-Javadoc)
64       * @see org.crosswire.jsword.book.Bookmark#setSearchRequest(org.crosswire.jsword.index.search.SearchRequest)
65       */
66      public void setSearchRequest(SearchRequest request) {
67          searchRequest = request;
68          lookupRequest = null;
69      }
70  
71      /* (non-Javadoc)
72       * @see org.crosswire.jsword.book.Bookmark#getSearchRequest()
73       */
74      public SearchRequest getSearchRequest() {
75          return searchRequest;
76      }
77  
78      /* (non-Javadoc)
79       * @see org.crosswire.jsword.book.Bookmark#setLookupRequest(java.lang.String)
80       */
81      public void setLookupRequest(String request) {
82          lookupRequest = request;
83          searchRequest = null;
84      }
85  
86      /* (non-Javadoc)
87       * @see org.crosswire.jsword.book.Bookmark#getLookupRequest()
88       */
89      public String getLookupRequest() {
90          return lookupRequest;
91      }
92  
93      /* (non-Javadoc)
94       * @see org.crosswire.jsword.book.Bookmark#getBookData()
95       */
96      public BookData getBookData() {
97          return null;
98      }
99  
100     @Override
101     public DefaultBookmark clone() {
102         DefaultBookmark clone = null;
103         try {
104             clone = (DefaultBookmark) super.clone();
105         } catch (CloneNotSupportedException e) {
106             assert false : e;
107         }
108         return clone;
109     }
110 
111     /**
112      * The list of books.
113      */
114     private transient List<Book> books;
115 
116     /**
117      * The lookup request.
118      */
119     private String lookupRequest;
120 
121     /**
122      * The search request.
123      */
124     private SearchRequest searchRequest;
125 
126     /**
127      * Serialization ID
128      */
129     private static final long serialVersionUID = 6959196267292499574L;
130 }
131