Class Helpers

java.lang.Object
com.studentgui.apphelpers.Helpers

public class Helpers extends Object
Miscellaneous filesystem and small utility helpers used by the UI pages. Responsibilities include selecting and creating the application home directory, creating per-student folder hierarchies, and providing a small roster fallback when no students.json exists.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Path
    Application home used for storing app-specific files (defaults to .
    static final Path
    Root directory for persisted application data (alias of APP_HOME).
    static final Path
    Canonical database file path used by SQLite operations.
    static final Path
    Directory that holds the database file.
    static final Path
    The project working directory (where the process was started).
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Create a basic folder hierarchy under DATA_ROOT for each student.
    static String
    Return the default student to use when none is provided by the caller.
    static List<String>
    Attempt to return a simple list of students from PROJECT_ROOT/json_Files/students.json.
    static Path
    latestPlotPath(String studentName, String prefix)
    Find the latest PNG plot file for a named student with the given prefix.
    static String
    Public safe name helper for filesystem paths.
    static void
    Attempt to set the JVM working directory to APP_HOME.
    static Path
    Return the per-student collected data directory path (APP_HOME/StudentDataFiles/{safeName}/collected_data).
    static Path
    studentPlotsDir(String studentName)
    Return the per-student plots directory path (APP_HOME/StudentDataFiles/{safeName}/plots).
    static Path
    Return the per-student reports directory path (APP_HOME/StudentDataFiles/{safeName}/reports).
    static void
    Ensure the working data directory exists under APP_HOME.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PROJECT_ROOT

      public static final Path PROJECT_ROOT
      The project working directory (where the process was started).
    • APP_HOME

      public static final Path APP_HOME
      Application home used for storing app-specific files (defaults to ./app_home).
    • DATA_ROOT

      public static final Path DATA_ROOT
      Root directory for persisted application data (alias of APP_HOME).
    • DATABASE_ROOT

      public static final Path DATABASE_ROOT
      Directory that holds the database file.
    • DATABASE_PATH

      public static final Path DATABASE_PATH
      Canonical database file path used by SQLite operations.
  • Method Details

    • setStartDir

      public static void setStartDir()
      Attempt to set the JVM working directory to APP_HOME. Fails silently if the property cannot be set in the running environment.
    • workingDir

      public static void workingDir()
      Ensure the working data directory exists under APP_HOME. This is idempotent and safe to call on startup.
    • createFolderHierarchy

      public static void createFolderHierarchy()
      Create a basic folder hierarchy under DATA_ROOT for each student. This will create StudentDataFiles, backups and errorLogs and a per-student folder with subfolders for data sheets and materials.
    • safeName

      public static String safeName(String s)
      Public safe name helper for filesystem paths. Mirrors the internal sanitize implementation but is callable from other packages.
      Parameters:
      s - input display name
      Returns:
      sanitized filesystem-safe name (never null)
    • latestPlotPath

      public static Path latestPlotPath(String studentName, String prefix)
      Find the latest PNG plot file for a named student with the given prefix. Returns null when no matching files exist.
      Parameters:
      studentName - display name of student
      prefix - file prefix such as "iOS" or "ScreenReader"
      Returns:
      path to the most recently modified matching PNG, or null
    • studentPlotsDir

      public static Path studentPlotsDir(String studentName)
      Return the per-student plots directory path (APP_HOME/StudentDataFiles/{safeName}/plots).
      Parameters:
      studentName - display name of the student
      Returns:
      path to the student's plots directory (never null)
    • studentReportsDir

      public static Path studentReportsDir(String studentName)
      Return the per-student reports directory path (APP_HOME/StudentDataFiles/{safeName}/reports).
      Parameters:
      studentName - display name of the student
      Returns:
      path to the student's reports directory (never null)
    • studentCollectedDataDir

      public static Path studentCollectedDataDir(String studentName)
      Return the per-student collected data directory path (APP_HOME/StudentDataFiles/{safeName}/collected_data).
      Parameters:
      studentName - display name of the student
      Returns:
      path to the student's collected data directory (never null)
    • getStudents

      public static List<String> getStudents()
      Attempt to return a simple list of students from PROJECT_ROOT/json_Files/students.json. Falls back to a single 'Test Student' entry when the file is missing or cannot be read.
      Returns:
      list of student display names (never null)
    • defaultStudent

      public static String defaultStudent()
      Return the default student to use when none is provided by the caller. This is the first entry from getStudents() or a sensible fallback when the roster is empty.
      Returns:
      display name of the default student (never null)