Package MediaPlayer

Class SongDatabaseController


  • public class SongDatabaseController
    extends java.lang.Object
    Controller class that manages the song database and related table model. Handles loading songs from CSV and updating the UI.
    • Constructor Summary

      Constructors 
      Constructor Description
      SongDatabaseController​(javax.swing.table.DefaultTableModel tableModel, javax.swing.JFrame parentFrame)
      Creates a new SongDatabaseController.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<Song> getAllSongs()
      Get all songs in the database.
      int getSize()
      Get the number of songs in the database.
      Song getSongAt​(int index)
      Get a song from the database by its index.
      void loadSongDatabase()
      Loads the song database from the CSV file.
      void searchSongs​(java.lang.String query)
      Searches the song database for songs matching the given query.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SongDatabaseController

        public SongDatabaseController​(javax.swing.table.DefaultTableModel tableModel,
                                      javax.swing.JFrame parentFrame)
        Creates a new SongDatabaseController.
        Parameters:
        tableModel - The table model to update with song data
        parentFrame - The parent frame for displaying dialogs
    • Method Detail

      • loadSongDatabase

        public void loadSongDatabase()
        Loads the song database from the CSV file.
      • searchSongs

        public void searchSongs​(java.lang.String query)
        Searches the song database for songs matching the given query.
        Parameters:
        query - The search term to match against song title, artist, or album
      • getSongAt

        public Song getSongAt​(int index)
        Get a song from the database by its index.
        Parameters:
        index - The index of the song in the database
        Returns:
        The song at the specified index or null if out of bounds
      • getAllSongs

        public java.util.List<Song> getAllSongs()
        Get all songs in the database.
        Returns:
        An unmodifiable list of all songs
      • getSize

        public int getSize()
        Get the number of songs in the database.
        Returns:
        The number of songs