You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -32,11 +57,29 @@ public FileOps(String fNam,List l, int t,int low, int up) throws FileNotFoundExc
32
57
33
58
}
34
59
60
+
/**
61
+
*
62
+
* A getter function
63
+
*/
35
64
publicFilegetFile()
36
65
{
37
66
returnthis.f;
38
67
}
39
68
69
+
/**
70
+
*
71
+
* A function to read a file line - wise and store its context if between {@code (minSize, maxSize)} in a double linked list, else ignores the given context.
72
+
*
73
+
* @throws IOException
74
+
* @throws FileNotFoundException
75
+
*
76
+
* @implNote Uses the function {@link Files.FileOps.formatInput()} formatInput to decide whether input will be ignored or not.
@@ -113,6 +170,33 @@ public void storeContext() throws IOException,FileNotFoundException
113
170
* -Trims given string - input in case that this exceeds threshold characters.
114
171
*
115
172
* */
173
+
/**
174
+
* Constructs a LineItem if the given key {@literal String} matches the requirements. If not key is either trimmed or null is returned (empty key given)
175
+
* <br><strong>Key Requirements: </strong>
176
+
*
177
+
* <blockquote>If a key is greater than {@code threshold} the key gets trimmed to fit the [0, threshold] range.</blockquote>
178
+
* <blockquote>If an empty key is given ({@code lContext.isEmpty() == true}) null is returned.</blockquote>
179
+
*
180
+
*
181
+
*
182
+
*
183
+
*
184
+
*
185
+
*
186
+
*
187
+
*
188
+
*
189
+
*
190
+
*
191
+
* @param lContext A String key.
192
+
* @param lNum The line in which this key is found inside the text.
@@ -146,6 +230,24 @@ public static Item formatInput(String lContext, int lNum)
146
230
*
147
231
* */
148
232
233
+
234
+
/**
235
+
*Itterates through the double linked list of Line objects ({@linkplain textEditor.Line}) and stores each valid word in an ArrayList of Word objects ({@linkplain util.Word}).
236
+
* <blockquote> The splitting procedure uses a regex in order to be performed. </blockquote>
237
+
* <blockquote> <strong> Valid Words (Keys): </strong></blockquote>
238
+
* <blockquote>
239
+
* <ul>
240
+
* <li> Any String that is delimited via the "\W+" regular expression is possibly valid.</li>
241
+
* <li> Any possibly valid string that has a {@code key.length()} ∃ {@code [minSize, maxSize]} is valid. </li>
242
+
* </ul>
243
+
* </blockquote>
244
+
* @implNote <ul>
245
+
* <li>Validity of a possibly valid Word - Key is checked via the {@code isValidWord()} function. </li>
246
+
* <li>The final ArrayList gets sorted after it is filled.</li>
247
+
* </ul>
248
+
*
249
+
* @return An {@literal ArrayList} of Word (- s) objects retrieved from the list in an ascending lexicographical order.
250
+
*/
149
251
publicArrayList<Word> fillWordMap()
150
252
{
151
253
intindex = 0;
@@ -186,11 +288,15 @@ public ArrayList<Word> fillWordMap()
186
288
187
289
}
188
290
291
+
292
+
189
293
//sort the array list based on the "word"-key.
190
294
Collections.sort(words);
191
295
192
296
///return the sorted arraylist.
193
297
298
+
299
+
194
300
returnwords;
195
301
196
302
@@ -205,7 +311,12 @@ public ArrayList<Word> fillWordMap()
205
311
* Stores a created line item in a double linked list.
206
312
*
207
313
* */
208
-
314
+
/**
315
+
* Gets a List instance and a LineItem and appends the given Item at the end of the list.
316
+
* @param l A list reference.
317
+
* @param line A line item.
318
+
* @return Nothing
319
+
*/
209
320
publicvoidstoreLine(Listl, LineItemline)
210
321
{
211
322
@@ -217,6 +328,14 @@ public void storeLine(List l, LineItem line)
217
328
* Decides for the validity of the given string based on thresholds. (see FileOps class constructor).
218
329
*
219
330
* */
331
+
/**
332
+
* Gets a String representing an actual key and decides whether is valid or not by checking its length which should ∃ [minSize, maxSize].
Copy file name to clipboardExpand all lines: src/Files/FilePageAccess.java
+59-4Lines changed: 59 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,35 @@
8
8
9
9
importutil.Word;
10
10
11
+
/**
12
+
*
13
+
*
14
+
* @author dasApfel - Konstantinos Pantelis
15
+
* {@summary }
16
+
* A class to encapsulate methods for performing r/w operations on RandomAccessFiles representing a dictionary (see {@linkplain RandomAccessFile} for more).
17
+
*
18
+
*/
19
+
11
20
publicclassFilePageAccess
12
21
{
13
22
23
+
24
+
14
25
privateintpageSize;
15
26
privateinttokenSize;
16
27
privateintdataPages;
17
28
privateintkeySize;
18
29
RandomAccessFiledF;
19
30
ArrayList<Word> words;
20
31
32
+
33
+
/**
34
+
*
35
+
* @param ps Size of a datapage in bytes.
36
+
* @param k Tuple of {@literal <String, Integer>} maximum size in bytes.
37
+
* @param f The name of a {@linkplain RandomAccessFile} to write the data in bytes, passed as a {@literal String}.
@@ -199,9 +237,17 @@ public ArrayList<Word> readPage(int pageNum) throws IOException,NullPointerExcep
199
237
}
200
238
201
239
/*
202
-
* Fill the missing parts of a string -> byte conversion with spaces (ASCII 32).
240
+
* Fills the missing parts of a string -> byte conversion with spaces (ASCII 32).
203
241
*
204
242
* */
243
+
244
+
/**
245
+
* Space - padding of a byte array representing a {@literal String} key.
246
+
* @param s A byte array containing the byte representation of a {@literal String} key.
247
+
* @return A byte array containing the byte representation of a {@literal String} key, filled up with spaces (ASCII 32) if {@code key.length < tokenSize }
0 commit comments