Package MediaPlayer
Class SongDatabaseController
- java.lang.Object
-
- MediaPlayer.SongDatabaseController
-
public class SongDatabaseController extends java.lang.ObjectController 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.intgetSize()Get the number of songs in the database.SonggetSongAt(int index)Get a song from the database by its index.voidloadSongDatabase()Loads the song database from the CSV file.voidsearchSongs(java.lang.String query)Searches the song database for songs matching the given query.
-
-
-
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 dataparentFrame- 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
-
-