A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / spelling / engine / SpellEvent.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.internal.ui.text.spelling.engine;
13
14 import java.util.Set;
15
16 /**
17  * Spell event fired for words detected by a spell-check iterator.
18  * 
19  * @since 3.0
20  */
21 public class SpellEvent implements ISpellEvent {
22
23         /** The begin index of the word in the spell-checkable medium */
24         private final int fBegin;
25
26         /** The spell-checker that causes the event */
27         private final ISpellChecker fChecker;
28
29         /** The end index of the word in the spell-checkable medium */
30         private final int fEnd;
31
32         /** Was the word found in the dictionary? */
33         private final boolean fMatch;
34
35         /** Does the word start a new sentence? */
36         private final boolean fSentence;
37
38         /** The word that causes the spell event */
39         private final String fWord;
40
41         /**
42          * Creates a new spell event.
43          * 
44          * @param checker
45          *            The spell-checker that causes the event
46          * @param word
47          *            The word that causes the event
48          * @param begin
49          *            The begin index of the word in the spell-checkable medium
50          * @param end
51          *            The end index of the word in the spell-checkable medium
52          * @param sentence
53          *            <code>true</code> iff the word starts a new sentence,
54          *            <code>false</code> otherwise
55          * @param match
56          *            <code>true</code> iff the word was found in the dictionary,
57          *            <code>false</code> otherwise
58          */
59         protected SpellEvent(final ISpellChecker checker, final String word,
60                         final int begin, final int end, final boolean sentence,
61                         final boolean match) {
62                 fChecker = checker;
63                 fEnd = end;
64                 fBegin = begin;
65                 fWord = word;
66                 fSentence = sentence;
67                 fMatch = match;
68         }
69
70         /*
71          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent#getBegin()
72          */
73         public final int getBegin() {
74                 return fBegin;
75         }
76
77         /*
78          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent#getEnd()
79          */
80         public final int getEnd() {
81                 return fEnd;
82         }
83
84         /*
85          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
86          */
87         public final Set getProposals() {
88                 return fChecker.getProposals(fWord, fSentence);
89         }
90
91         /*
92          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent#getWord()
93          */
94         public final String getWord() {
95                 return fWord;
96         }
97
98         /*
99          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent#isMatch()
100          */
101         public final boolean isMatch() {
102                 return fMatch;
103         }
104
105         /*
106          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent#isStart()
107          */
108         public final boolean isStart() {
109                 return fSentence;
110         }
111 }