~sword-devel/jsword/trunk

« back to all changes in this revision

Viewing changes to jsword/java/jsword/org/crosswire/jsword/control/search/SubLeftParamWord.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:
1
1
 
2
2
package org.crosswire.jsword.control.search;
3
3
 
4
 
import java.util.Enumeration;
 
4
import java.util.Iterator;
5
5
import java.util.Vector;
6
6
 
7
7
import org.crosswire.jsword.passage.Passage;
8
8
 
9
9
/**
10
 
* The Search Word for a Word to search for. The default
11
 
* if no other SearchWords match.
12
 
*
13
 
* <table border='1' cellPadding='3' cellSpacing='0' width="100%">
14
 
* <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
15
 
* Distribution Licence:<br />
16
 
* Project B is free software; you can redistribute it
17
 
* and/or modify it under the terms of the GNU General Public License,
18
 
* version 2 as published by the Free Software Foundation.<br />
19
 
* This program is distributed in the hope that it will be useful,
20
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
 
* General Public License for more details.<br />
23
 
* The License is available on the internet
24
 
* <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
25
 
* <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26
 
* MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
27
 
* The copyright to this program is held by it's authors.
28
 
* </font></td></tr></table>
29
 
* @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
30
 
* @see <{docs.Licence}>
31
 
* @author Joe Walker
32
 
*/
 
10
 * The Search Word for a Word to search for. The default
 
11
 * if no other SearchWords match.
 
12
 * 
 
13
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 
14
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 
15
 *
 
16
 * Distribution Licence:<br />
 
17
 * JSword is free software; you can redistribute it
 
18
 * and/or modify it under the terms of the GNU General Public License,
 
19
 * version 2 as published by the Free Software Foundation.<br />
 
20
 * This program is distributed in the hope that it will be useful,
 
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
23
 * General Public License for more details.<br />
 
24
 * The License is available on the internet
 
25
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 
26
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
27
 * MA 02111-1307, USA<br />
 
28
 * The copyright to this program is held by it's authors.
 
29
 * </font></td></tr></table>
 
30
 * @see docs.Licence
 
31
 * @author Joe Walker [joe at eireneh dot com]
 
32
 * @version $Id$
 
33
 */
33
34
public class SubLeftParamWord implements ParamWord
34
35
{
35
36
    /**
36
 
    * Get a word for something else to word on.
37
 
    * @param engine The controller that can provide access to the search
38
 
    *               string or a default Bible.
39
 
    * @return The requested text
40
 
    * @exception SearchException If this action is not appropriate
41
 
    */
 
37
     * Get a word for something else to word on.
 
38
     * @param engine The controller that can provide access to the search
 
39
     *               string or a default Bible.
 
40
     * @return The requested text
 
41
     * @exception SearchException If this action is not appropriate
 
42
     */
42
43
    public String getWord(Engine engine) throws SearchException
43
44
    {
44
45
        throw new SearchException("search_left_param");
45
46
    }
46
47
 
47
48
    /**
48
 
    * Get a Passage for something else to word on.
49
 
    * @param engine The controller that can provide access to the search
50
 
    *               string or a default Bible.
51
 
    * @return A Passage relevant to this command
52
 
    * @exception SearchException If this action is not appropriate
53
 
    */
 
49
     * Get a Passage for something else to word on.
 
50
     * @param engine The controller that can provide access to the search
 
51
     *               string or a default Bible.
 
52
     * @return A Passage relevant to this command
 
53
     * @exception SearchException If this action is not appropriate
 
54
     */
54
55
    public Passage getPassage(Engine engine) throws SearchException
55
56
    {
56
 
        Enumeration en = engine.elements();
 
57
        Iterator it = engine.iterator();
57
58
        Vector output = new Vector();
58
59
 
59
60
        int paren_level = 1;
60
61
        while (true)
61
62
        {
62
 
            if (!engine.elements().hasMoreElements())
 
63
            if (!engine.iterator().hasNext())
63
64
                throw new SearchException("search_left_brackets");
64
65
 
65
 
            SearchWord word = (SearchWord) en.nextElement();
 
66
            SearchWord word = (SearchWord) it.next();
66
67
 
67
68
            if (word instanceof SubLeftParamWord)   paren_level++;
68
69
            if (word instanceof SubRightParamWord)  paren_level--;
72
73
            output.addElement(word);
73
74
        }
74
75
 
75
 
        Engine sub_engine = new Engine(engine.getBible(), engine.getSearchHashtable());
 
76
        Engine sub_engine = new Engine(engine.getBible(), engine.getSearchMap());
76
77
        Passage sub_ref = sub_engine.search(output);
77
78
 
78
79
        return sub_ref;