RC2 compatibility
[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, final int begin, final int end, final boolean sentence, final boolean match) {
60                 fChecker= checker;
61                 fEnd= end;
62                 fBegin= begin;
63                 fWord= word;
64                 fSentence= sentence;
65                 fMatch= match;
66         }
67
68         /*
69          * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getBegin()
70          */
71         public final int getBegin() {
72                 return fBegin;
73         }
74
75         /*
76          * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getEnd()
77          */
78         public final int getEnd() {
79                 return fEnd;
80         }
81
82         /*
83          * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
84          */
85         public final Set getProposals() {
86                 return fChecker.getProposals(fWord, fSentence);
87         }
88
89         /*
90          * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getWord()
91          */
92         public final String getWord() {
93                 return fWord;
94         }
95
96         /*
97          * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#isMatch()
98          */
99         public final boolean isMatch() {
100                 return fMatch;
101         }
102
103         /*
104          * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#isStart()
105          */
106         public final boolean isStart() {
107                 return fSentence;
108         }
109 }