Skip to content

Commit 0ebf19b

Browse files
committed
Add detailed Javadoc comments to core classes
Extensive Javadoc comments were added to many classes and methods in the AICC, SCORM, CMI5, LOM, and file access implementations to improve code documentation and clarity. Three utility/test scripts (TestJsonSerialization.java, fix_classes.sh, remove_builder_annotations.sh) were removed as part of codebase cleanup.
1 parent 1df61bd commit 0ebf19b

142 files changed

Lines changed: 6381 additions & 218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

TestJsonSerialization.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

fix_classes.sh

Lines changed: 0 additions & 75 deletions
This file was deleted.

remove_builder_annotations.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/dev/jcputney/elearning/parser/impl/AbstractS3FileAccess.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public abstract class AbstractS3FileAccess implements FileAccess {
100100
* A thread-safe cache storing the list of all file paths within the module.
101101
* <p>
102102
* This cache is intended to improve performance for file-related operations by storing the result
103-
* of a full scan of the S3 bucket or prefix. The cache is stored in an {@link AtomicReference}
104-
* to ensure safe publication across threads once populated.
103+
* of a full scan of the S3 bucket or prefix. The cache is stored in an {@link AtomicReference} to
104+
* ensure safe publication across threads once populated.
105105
* <p>
106106
* Modifications to this cache should be controlled to maintain data consistency across the class,
107107
* particularly when the underlying S3 bucket contents change.
@@ -445,6 +445,12 @@ public String fullPath(String relativePath) {
445445
return rootPath + "/" + path;
446446
}
447447

448+
/**
449+
* Retrieves the root path of the current instance.
450+
*
451+
* @return the root path as a String
452+
*/
453+
@Override
448454
public String getRootPath() {
449455
return this.rootPath;
450456
}
@@ -507,6 +513,13 @@ protected InputStream getFileContentsBase(String path) throws IOException {
507513
}
508514
}
509515

516+
/**
517+
* Wraps the provided input stream with additional processing or functionality.
518+
*
519+
* @param stream the original input stream to be wrapped
520+
* @param fileSize the size of the file associated with the input stream, in bytes
521+
* @return an InputStream instance which provides a wrapped version of the original input stream
522+
*/
510523
protected abstract InputStream getInputStreamWrapper(InputStream stream, long fileSize);
511524

512525
/**

src/main/java/dev/jcputney/elearning/parser/impl/ClasspathFileAccess.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ public long getTotalSize() throws IOException {
132132
return -1;
133133
}
134134

135+
/**
136+
* Retrieves the root path used for file access.
137+
*
138+
* @return The root path as a string.
139+
*/
140+
@Override
135141
public String getRootPath() {
136142
return this.rootPath;
137143
}

src/main/java/dev/jcputney/elearning/parser/impl/DefaultModuleFileProvider.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ public class DefaultModuleFileProvider implements ModuleFileProvider {
4242
* The name of the xAPI send statement file.
4343
*/
4444
public static final String XAPI_SEND_STATEMENT_FILE = "sendStatement.js";
45+
46+
/**
47+
* A FileAccess instance used to handle file operations within the module package.
48+
* <p>
49+
* This variable provides an abstraction layer for file-related operations, such as reading,
50+
* checking existence, and accessing files in a consistent manner. It is integral to the
51+
* functionality provided by the DefaultModuleFileProvider.
52+
* <p>
53+
* The FileAccess instance ensures that file operations are centralized and can be delegated
54+
* appropriately, facilitating modular and testable design.
55+
* <p>
56+
* This field is immutable and must be initialized during the construction of the
57+
* DefaultModuleFileProvider.
58+
*/
4559
private final FileAccess fileAccess;
4660

4761
/**

src/main/java/dev/jcputney/elearning/parser/impl/InMemoryFileAccess.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,40 @@
5151
*/
5252
public class InMemoryFileAccess implements FileAccess, AutoCloseable {
5353

54+
/**
55+
* Represents the root path of the detected directory structure within the ZIP data.
56+
* <p>
57+
* The root path is determined by analyzing the file entries from the input ZIP data. If all files
58+
* are contained within a single top-level directory, the root path will be set to that
59+
* directory's name. If the files are distributed across multiple directories or at the root of
60+
* the ZIP, the root path will be an empty string.
61+
* <p>
62+
* This variable is final and is initialized during the loading process of the in-memory file
63+
* system.
64+
*/
5465
private final String rootPath;
66+
67+
/**
68+
* A list of file entries representing the in-memory files loaded from a ZIP file. Each entry
69+
* corresponds to a file within the in-memory file system, encapsulating its path, content, and
70+
* size.
71+
*/
5572
private final List<FileEntry> fileEntries;
73+
74+
/**
75+
* A set containing the unique directory paths detected in the in-memory file system.
76+
* <p>
77+
* This set ensures that no duplicate directory paths are stored and is used internally for
78+
* operations that require knowledge of the directory structure, such as detecting parent
79+
* directories or listing directory contents.
80+
*/
5681
private final Set<String> directories;
82+
83+
/**
84+
* Represents the total size of all files stored in the in-memory file system. This value is
85+
* calculated during the loading of ZIP data and reflects the combined size of all files,
86+
* excluding additional metadata or directory structures.
87+
*/
5788
private final long totalSize;
5889

5990
/**
@@ -102,6 +133,13 @@ public InMemoryFileAccess(InputStream zipInputStream) throws IOException {
102133
this.rootPath = detectRootPath();
103134
}
104135

136+
/**
137+
* Retrieves the root path for the in-memory file system. The root path is typically determined
138+
* during the initialization of the instance and provides the base directory for all file
139+
* operations within the system.
140+
*
141+
* @return The root path as a string.
142+
*/
105143
@Override
106144
public String getRootPath() {
107145
return rootPath;
@@ -206,6 +244,12 @@ public List<String> getAllFiles() throws IOException {
206244
.toList();
207245
}
208246

247+
/**
248+
* Retrieves the total size of all files stored in the in-memory file system.
249+
*
250+
* @return The total size of all files in bytes.
251+
* @throws IOException If an error occurs while calculating the total size.
252+
*/
209253
@Override
210254
public long getTotalSize() throws IOException {
211255
return totalSize;
@@ -384,8 +428,22 @@ private String getSimilarFiles(String targetPath) {
384428
*/
385429
private static class FileEntry {
386430

431+
/**
432+
* The file path associated with this file entry, representing the location or identifier of the
433+
* file within an in-memory file system.
434+
*/
387435
private final String path;
436+
437+
/**
438+
* Holds the content of the file represented by this file entry. This is a byte array that
439+
* stores the raw data of the file in memory.
440+
*/
388441
private final byte[] content;
442+
443+
/**
444+
* Represents the size of the file in bytes. This value is derived from the length of the
445+
* content array and indicates the total amount of data stored in this file entry.
446+
*/
389447
private final long size;
390448

391449
FileEntry(String path, byte[] content) {
@@ -394,14 +452,29 @@ private static class FileEntry {
394452
this.size = content.length;
395453
}
396454

455+
/**
456+
* Retrieves the file path associated with this file entry.
457+
*
458+
* @return the file path as a string
459+
*/
397460
String getPath() {
398461
return path;
399462
}
400463

464+
/**
465+
* Retrieves the content of the file represented by this file entry.
466+
*
467+
* @return a byte array containing the raw data of the file
468+
*/
401469
byte[] getContent() {
402470
return content;
403471
}
404472

473+
/**
474+
* Retrieves the size of the file in bytes.
475+
*
476+
* @return the file size as a long value
477+
*/
405478
long getSize() {
406479
return size;
407480
}

src/main/java/dev/jcputney/elearning/parser/impl/LocalFileAccess.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ public long getTotalSize() throws IOException {
201201
}
202202
}
203203

204+
/**
205+
* Retrieves the root path for file access.
206+
*
207+
* @return The root path as a String.
208+
*/
209+
@Override
204210
public String getRootPath() {
205211
return this.rootPath;
206212
}

0 commit comments

Comments
 (0)