~sword-devel/jsword/trunk

« back to all changes in this revision

Viewing changes to jsword/java/jsword/org/crosswire/jsword/book/basic/VersewiseBible.java

  • Committer: joe
  • Date: 2002-10-08 21:36:18 UTC
  • Revision ID: svn-v4:a88caf3b-7e0a-0410-8d0d-cecb45342206:trunk:80
big config and comment update

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
import java.io.IOException;
5
5
import java.io.PrintWriter;
6
 
import java.net.MalformedURLException;
7
6
import java.net.URL;
8
7
import java.util.Iterator;
9
8
import java.util.ArrayList;
17
16
import org.crosswire.jsword.passage.Passage;
18
17
import org.crosswire.jsword.passage.PassageFactory;
19
18
import org.crosswire.jsword.passage.Verse;
20
 
import org.crosswire.common.config.Config;
21
 
import org.crosswire.common.config.choices.TextViewChoice;
22
19
import org.crosswire.common.util.LogicError;
23
20
import org.crosswire.common.util.NetUtil;
24
21
 
25
22
/**
26
 
* The VersewiseMutableBook class makes it easier to implement
27
 
* MutableBook by splitting the job up into a Verse by Verse effort.
28
 
* setDocument() is called once for every verse in the Bible in order,
29
 
* and flush() is called when done.
30
 
*
31
 
* <table border='1' cellPadding='3' cellSpacing='0' width="100%">
32
 
* <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
33
 
* Distribution Licence:<br />
34
 
* Project B is free software; you can redistribute it
35
 
* and/or modify it under the terms of the GNU General Public License,
36
 
* version 2 as published by the Free Software Foundation.<br />
37
 
* This program is distributed in the hope that it will be useful,
38
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
39
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40
 
* General Public License for more details.<br />
41
 
* The License is available on the internet
42
 
* <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
43
 
* <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
44
 
* MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
45
 
* The copyright to this program is held by it's authors.
46
 
* </font></td></tr></table>
47
 
* @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
48
 
* @see <{docs.Licence}>
49
 
* @author Joe Walker
50
 
* @version $Id$
51
 
*/
 
23
 * The VersewiseMutableBook class makes it easier to implement
 
24
 * MutableBook by splitting the job up into a Verse by Verse effort.
 
25
 * setDocument() is called once for every verse in the Bible in order,
 
26
 * and flush() is called when done.
 
27
 * 
 
28
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 
29
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 
30
 *
 
31
 * Distribution Licence:<br />
 
32
 * JSword is free software; you can redistribute it
 
33
 * and/or modify it under the terms of the GNU General Public License,
 
34
 * version 2 as published by the Free Software Foundation.<br />
 
35
 * This program is distributed in the hope that it will be useful,
 
36
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
37
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
38
 * General Public License for more details.<br />
 
39
 * The License is available on the internet
 
40
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 
41
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
42
 * MA 02111-1307, USA<br />
 
43
 * The copyright to this program is held by it's authors.
 
44
 * </font></td></tr></table>
 
45
 * @see docs.Licence
 
46
 * @author Joe Walker [joe at eireneh dot com]
 
47
 * @version $Id$
 
48
 */
52
49
public abstract class VersewiseBible extends AbstractWritableBible
53
50
{
54
51
    /**
55
 
    * Write the XML to disk. Children will almost certainly want to
56
 
    * override this.
57
 
    * @param verse The verse to write
58
 
    * @param text The data to write
59
 
    */
 
52
     * Write the XML to disk. Children will almost certainly want to
 
53
     * override this.
 
54
     * @param verse The verse to write
 
55
     * @param text The data to write
 
56
     */
60
57
    public abstract void setDocument(BibleData text) throws BookException;
61
58
 
62
59
    /**
63
 
    * Save a list of found words. Children will probably want to
64
 
    * override this.
65
 
    * @param word The word to write
66
 
    * @param ref The data to write
67
 
    */
 
60
     * Save a list of found words. Children will probably want to
 
61
     * override this.
 
62
     * @param word The word to write
 
63
     * @param ref The data to write
 
64
     */
68
65
    public abstract void foundPassage(String word, Passage ref) throws BookException;
69
66
 
70
67
    /**
71
 
    * Setup the Version information
72
 
    * @param version The version that this Bible is becoming
73
 
    */
 
68
     * Setup the Version information
 
69
     * @param version The version that this Bible is becoming
 
70
     */
74
71
    public abstract void setVersion(BookMetaData version);
75
72
 
76
73
    /**
77
 
    * Flush the data written to disk
78
 
    */
 
74
     * Flush the data written to disk
 
75
     */
79
76
    public void flush() throws BookException
80
77
    {
81
78
    }
82
79
 
83
80
    /**
84
 
    * Get a URL in which we can save a generation report
85
 
    * @return A directory URL into which we can save files
86
 
    */
 
81
     * Get a URL in which we can save a generation report
 
82
     * @return A directory URL into which we can save files
 
83
     */
87
84
    public abstract URL getBaseURL();
88
85
 
89
86
    /**
90
 
    * This returns a simple Config, that displays the generation notes
91
 
    */
92
 
    public Config getProperties() throws BookException
93
 
    {
94
 
        try
95
 
        {
96
 
            URL dir = NetUtil.lengthenURL(getBaseURL(), "generate.log");
97
 
 
98
 
            Config config = new Config("Bible Settings");
99
 
            config.add("Notes.Log", new TextViewChoice(dir));
100
 
 
101
 
            return config;
102
 
        }
103
 
        catch (MalformedURLException ex)
104
 
        {
105
 
            throw new BookException("book_prop", ex);
106
 
        }
107
 
    }
108
 
 
109
 
    /**
110
 
    * Read from the given source version to generate ourselves
111
 
    * @param version The source
112
 
    */
 
87
     * Read from the given source version to generate ourselves
 
88
     * @param version The source
 
89
     */
113
90
    public void generate(Bible version) throws BookException
114
91
    {
115
92
        try
141
118
    }
142
119
 
143
120
    /**
144
 
    * Read from the given source version to generate ourselves
145
 
    * @param version The source
146
 
    */
 
121
     * Read from the given source version to generate ourselves
 
122
     * @param version The source
 
123
     */
147
124
    protected void generateText(Bible source) throws IOException, NoSuchVerseException, BookException
148
125
    {
149
126
        Passage temp = PassageFactory.createPassage(PassageFactory.SPEED);
174
151
    }
175
152
 
176
153
    /**
177
 
    * Read from the given source version to generate ourselves
178
 
    * @param version The source
179
 
    */
 
154
     * Read from the given source version to generate ourselves
 
155
     * @param version The source
 
156
     */
180
157
    protected void generatePassages(Bible source) throws IOException, NoSuchVerseException, BookException
181
158
    {
182
159
        int count = 0;