View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics and Informatics, Comenius
3    * University, Bratislava. This file is protected by the Mozilla Public License
4    * version 1.1 (the License); you may not use this file except in compliance
5    * with the License. You may obtain a copy of the License at
6    * http://euromath2.sourceforge.net/license.html Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is
8    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9    * KIND, either express or implied. See the License for the specific language
10   * governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.editor.textEditor.requests.editTextRequests;
13  
14  import sk.uniba.euromath.editor.textEditor.ITextPieceKeeper;
15  import sk.uniba.euromath.editor.textEditor.requests.IRequestSpecialization;
16  import sk.uniba.euromath.editor.textEditor.requests.RequestConstants;
17  
18  /***
19   * Request to insert text at specified position. Position is specified by
20   * ITextPieceKeeper and offset.
21   * 
22   * @author Martin Kollar 17.11.2005
23   */
24  public class InsertTextRequest extends EditTextRequest implements IRequestSpecialization {
25      /***
26       * Holds text to insert.
27       */
28      private String text;
29  
30      /***
31       * Holds offset in text piece where to insert text.
32       */
33      private int offset;
34  
35      /***
36       * Constructor.
37       * 
38       * @param text
39       *            to insert
40       * @param offset
41       *            offset in text piece(ITextPieceKeeper's text) from where text
42       *            should be deleted, must be valid (in range of text piece)
43       * @param source
44       *            ITextPieceKeeper where to insert Text
45       */
46      public InsertTextRequest(ITextPieceKeeper source, String text, int offset) {
47          super(source);
48          this.text = text;
49          this.offset = offset;
50      }
51  
52      /***
53       * Returns position in text piece where to insert text.
54       * 
55       * @return offset in text piece (ITextPieceKeeper's text)
56       */
57      public int getOffset() {
58          return this.offset;
59      }
60  
61      /***
62       * Returns text to insert.
63       * @return Returns the text.
64       */
65      public String getText() {
66          return this.text;
67      }
68      
69      public String getSpecialization() {
70          return RequestConstants.INSERT_TEXT_REQUEST;
71      }
72  
73  
74  }