1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor.textEditor;
13
14 import java.util.List;
15
16 import sk.uniba.euromath.document.XMLAccess;
17
18 /***
19 * Container for ITextPieceKeepers. As logical unit represents one text node in
20 * XSLT-transformed document. Text of that node is rendered(formated into more
21 * lines or line segments(first and last can be segments), where each line or
22 * line segment keeps one ITextPieceKeeper and is located (drawn) by
23 * ITextLocator. Keepers are ordered and indexed as follows text in node they
24 * keeps. Only in noticed order can be added to container. Container creates
25 * ItextPieceInfo for each added keeper and stores it.
26 *
27 * @author Tomáš Studva
28 *
29 * @see ITextPieceKeeper
30 * @see ITextPieceInfo
31 */
32 public interface ITextPieceContainer {
33
34 /***
35 * Returns ITextPieceKeeper stored with index index.
36 *
37 * @param index
38 * of wanted keeper
39 * @return ITextPieceKeeper with index index
40 */
41 public ITextPieceKeeper getKeeper(int index);
42
43 /***
44 * Returns ITextPieceKeepers stored with index in closed interval
45 * startIndex, endIndex.
46 *
47 * @param startIndex
48 * of first wanted keeper
49 * @param endIndex
50 * of last wanted keeper
51 * @return List of ITextPieceKeeper within interval
52 */
53 public List<ITextPieceKeeper> getKeepers(int startIndex, int endIndex);
54
55 /***
56 * Returns ITextPieceKeepers stored after startKeeper including and
57 * before endKeeper including.
58 *
59 *
60 * @param startKeeper
61 * first wanted keeper
62 * @param endKeeper
63 * last wanted keeper
64 * @return List of ITextPieceKeeper within interval
65 */
66 public List<ITextPieceKeeper> getKeepers(ITextPieceKeeper startKeeper,
67 ITextPieceKeeper endKeeper);
68
69 /***
70 * Adds ITextPieceKeeper to container. Returns for that keeper
71 * ITextPieceInfo. Keepers are ordered and indexed as follows text in
72 * node they keeps. Only in noticed order can be added to container.
73 *
74 * @param pieceKeeper
75 * keeper to add
76 * @return ITextPieceInfo for pieceKeeper
77 */
78 public ITextPieceInfo add(ITextPieceKeeper pieceKeeper);
79
80 /***
81 * Returns number of all stored pieces.
82 *
83 * @return number of all stored pieces
84 */
85 public int size();
86
87 /***
88 * Returns ITextPieceInfo for ITextPieceKeeper. This info is the same as
89 * ITextPieceKeeper has set.
90 *
91 * @param forPiece
92 * ITextPieceKeeper stored in this container
93 * @return ITextPieceInfo about ITextPieceKeeper forPiece
94 */
95 public ITextPieceInfo getInfo(ITextPieceKeeper forPiece);
96
97 /***
98 * Returns all stored ITextPieceKeeper. If is correctly filled by
99 * ITextPieceKeepers, than returns all ITexPieceKeepers for node.
100 *
101 * @return all stored ITextPieceKeeper
102 */
103 public List<ITextPieceKeeper> getAll();
104
105 /***
106 * Returns next stored ITextPieceKeeper in order they are stored.
107 *
108 * @param keeper
109 * asked for successor
110 * @return successor or IllegalArgumentException if <code>piece</code>
111 * is the last part
112 */
113 public ITextPieceKeeper getNext(ITextPieceKeeper keeper);
114
115 /***
116 * Returns if keeper is last or not.
117 *
118 * @param keeper
119 * asked for successor
120 * @return true if keeper is not last in container
121 */
122 public boolean hasNext(ITextPieceKeeper keeper);
123
124 /***
125 * Returns previous stored ITextPieceKeeper in order they are stored.
126 *
127 * @param keeper
128 * asked for predeccessor
129 * @return predeccessor or IllegalArgumentException if
130 * <code>piece</code> is the first part
131 */
132 public ITextPieceKeeper getPrevious(ITextPieceKeeper keeper);
133
134 /***
135 * Returns if keeper is first or not.
136 *
137 * @param keeper
138 * asked for predeccessor
139 * @return true if keeper is not first in container
140 */
141 public boolean hasPrevious(ITextPieceKeeper keeper);
142
143 /***
144 * Returns index of ITextPieceKeeper piece in this container as is
145 * stored.
146 *
147 * @param piece
148 * asked for index
149 * @return returns index of piece
150 */
151 public int indexOf(ITextPieceKeeper piece);
152
153 /***
154 * Resolves index in DOM node's text of original document(not
155 * XSLT-transformed) to index in node's rendered text.
156 *
157 * @param indexInOriginalText
158 * index in DOM node's original text or one behind
159 *
160 * @return index in rendered text of container (node) or one behind
161 */
162 public int resolveOriginalIndex(int indexInOriginalText,
163 XMLAccess xmlAccess);
164
165 /***
166 * Resolves index in container rendered text to DOM node's text of
167 * original document(not XSLT-transformed).
168 *
169 * @param indexInRenderedText
170 * index in rendered text of container (node) (0 to
171 * text.length-1)or index one behind the text(for example
172 * when index is character gap index, can be text lenght)
173 * @return index in DOM node's original text or one behind the text
174 */
175 public int resolveRenderedIndex(int indexInRenderedText,
176 XMLAccess xmlAccess);
177
178 /***
179 * Returns keeper holding rendered text where index falls.
180 *
181 * @param indexInRenderedText
182 * index in whole rendered text or one behind
183 * @return ITextPieceKeeper keeper holding rendered text where index
184 * falls
185 */
186 public ITextPieceKeeper getKeeperByRenderedOffset(
187 int indexInRenderedText);
188
189 /***
190 * Returns rendered text of all stored keepers, exactly the same as is
191 * rendered.
192 *
193 * @return whole rendered text of node associated with this container
194 */
195 public String getWholeRenderedText();
196 }