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 and to move caret to right
20   * position. Position is specified by ITextPieceKeeper and offset.
21   * 
22   * @author Martin Kollar 17.11.2005
23   */
24  public class InsertTextRequest extends EditTextRequest implements
25                  IRequestSpecialization {
26          /***
27           * Holds text to insert.
28           */
29          private String text;
30  
31          /***
32           * Holds offset in text piece where to insert text.
33           */
34          private int offset;
35  
36          /***
37           * Constructor.
38           * 
39           * @param text
40           *                to insert
41           * @param offset
42           *                offset in text piece(ITextPieceKeeper's text) from
43           *                where text should be deleted, must be valid (in range
44           *                of text piece)
45           * @param keeper
46           *                ITextPieceKeeper where to insert text
47           */
48          public InsertTextRequest(ITextPieceKeeper keeper, String text,
49                          int offset) {
50                  super(keeper);
51                  this.text = text;
52                  this.offset = offset;
53          }
54  
55          /***
56           * Returns position in text piece where to insert text.
57           * 
58           * @return offset in text piece (ITextPieceKeeper's text)
59           */
60          public int getOffset() {
61                  return this.offset;
62          }
63  
64          /***
65           * Returns text to insert.
66           * 
67           * @return Returns the text.
68           */
69          public String getText() {
70                  return this.text;
71          }
72          
73          /*
74           * (non-Javadoc)
75           * @see sk.uniba.euromath.editor.textEditor.requests.IRequestSpecialization#getSpecialization()
76           */
77          public String getSpecialization() {
78                  return RequestConstants.INSERT_TEXT_REQUEST;
79          }
80  
81  }