[jsword-svn] jsword/java/jsword/org/crosswire/jsword/examples s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Mar 18 18:56:49 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/examples
In directory www.crosswire.org:/tmp/cvs-serv10359/java/jsword/org/crosswire/jsword/examples

Modified Files:
	APIExamples.java 
Log Message:
Made Book the primary interface to a module and put BookMetaData within it. All of BookMetaData is accessible through the Book interface.

Index: APIExamples.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/examples/APIExamples.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** APIExamples.java	9 Oct 2004 21:45:05 -0000	1.19
--- APIExamples.java	19 Mar 2005 01:56:47 -0000	1.20
***************
*** 13,17 ****
  import org.crosswire.jsword.book.BookFilter;
  import org.crosswire.jsword.book.BookFilters;
- import org.crosswire.jsword.book.BookMetaData;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.BooksEvent;
--- 13,16 ----
***************
*** 62,66 ****
      {
          Books books = Books.installed();
!         Book bible = books.getBookMetaData(BIBLE_NAME).getBook();
  
          Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
--- 61,65 ----
      {
          Books books = Books.installed();
!         Book bible = books.getBook(BIBLE_NAME);
  
          Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
***************
*** 80,84 ****
      public void readStyledText() throws NoSuchKeyException, BookException, TransformerException, SAXException
      {
!         Book bible = Books.installed().getBookMetaData(BIBLE_NAME).getBook();
  
          Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
--- 79,83 ----
      public void readStyledText() throws NoSuchKeyException, BookException, TransformerException, SAXException
      {
!         Book bible = Books.installed().getBook(BIBLE_NAME);
  
          Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
***************
*** 105,111 ****
          // first. In a real world app you will probably have a better way
          // of doing this.
!         List dicts = Books.installed().getBookMetaDatas(BookFilters.getDictionaries());
!         BookMetaData bmd = (BookMetaData) dicts.get(0);
!         Book dict = bmd.getBook();
  
          // If I want every key in the Dictionary then I do this (or something
--- 104,109 ----
          // first. In a real world app you will probably have a better way
          // of doing this.
!         List dicts = Books.installed().getBooks(BookFilters.getDictionaries());
!         Book dict = (Book) dicts.get(0);
  
          // If I want every key in the Dictionary then I do this (or something
***************
*** 126,130 ****
      public void search() throws BookException
      {
!         Book bible = Books.installed().getBookMetaData(BIBLE_NAME).getBook();
  
          // This does a standard operator search. See the search documentation
--- 124,128 ----
      public void search() throws BookException
      {
!         Book bible = Books.installed().getBook(BIBLE_NAME);
  
          // This does a standard operator search. See the search documentation
***************
*** 149,167 ****
      {
          // The Default Bible - JSword does everything it can to make this work
!         BookMetaData bmd = Books.installed().getBookMetaData(BIBLE_NAME);
! 
!         // You get a Book via a MetaData object to help save resources.
!         Book book = bmd.getBook();
  
!         // And you can get back to the MetaData object to find out more too:
!         bmd = book.getBookMetaData();
!         System.out.println(bmd.getLanguage());
  
          // If you want a greater selection of Books:
!         List books = Books.installed().getBookMetaDatas();
!         bmd = (BookMetaData) books.get(0);
  
          // Or you can narrow the range a bit
!         books = Books.installed().getBookMetaDatas(BookFilters.getBibles());
  
          // There are implementations of BookFilter for all sorts of things in
--- 147,161 ----
      {
          // The Default Bible - JSword does everything it can to make this work
!         Book book = Books.installed().getBook(BIBLE_NAME);
  
!         // And you can find out more too:
!         System.out.println(book.getLanguage());
  
          // If you want a greater selection of Books:
!         List books = Books.installed().getBooks();
!         book = (Book) books.get(0);
  
          // Or you can narrow the range a bit
!         books = Books.installed().getBooks(BookFilters.getBibles());
  
          // There are implementations of BookFilter for all sorts of things in
***************
*** 170,181 ****
          // If you are wanting to get really fancy you can implement your own
          // Bookfilter easily
!         List test = Books.installed().getBookMetaDatas(new BookFilter()
          {
!             public boolean test(BookMetaData tbmd)
              {
!                 return tbmd.getName().equals("My Favorite Version"); //$NON-NLS-1$
              }
          });
!         bmd = (BookMetaData) test.get(0);
  
          // If you want to know about new books as they arrive:
--- 164,175 ----
          // If you are wanting to get really fancy you can implement your own
          // Bookfilter easily
!         List test = Books.installed().getBooks(new BookFilter()
          {
!             public boolean test(Book bk)
              {
!                 return bk.getName().equals("My Favorite Version"); //$NON-NLS-1$
              }
          });
!         book = (Book) test.get(0);
  
          // If you want to know about new books as they arrive:



More information about the jsword-svn mailing list