Class AudioDatabase
java.lang.Object
yearreview.app.data.sources.audio.database.AudioDatabase
- All Implemented Interfaces:
Iterable<ListeningEvent>
- Author:
- ColdStone37
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a Database by initializing the internal Datastructures. -
Method Summary
Modifier and TypeMethodDescriptiongetData
(String name, AudioData.Type type) Gets AudioData from the database.getDataById
(AudioData.Type type, String name) Gets AudioData inside the Database by type and name.int
Gets the amount ofAudioData
-elements stored in this database.int
Gets the amount ofevents
stored in the database.getPiece
(String name, List<AudioData> data, AudioData.Type type) Gets AudioPiece from the database.boolean
hasData
(AudioData.Type type, String name) Tests whether certain data is stored in the database.void
insertEvent
(ListeningEvent event) Inserts an event into the database.iterator()
Needed to implement theIterable
-interface.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
events
Set of all events sorted by time. -
dataMap
Map that stores the data with an associated key for fast access. Data of differentTypes
is stored alongside each other and is differentiated by putting the name of the type in front.
-
-
Constructor Details
-
AudioDatabase
public AudioDatabase()Constructs a Database by initializing the internal Datastructures.
-
-
Method Details
-
getDataById
Gets AudioData inside the Database by type and name.- Parameters:
type
- type of data to getname
- name of data to get- Returns:
- AudioData if the value exists otherwise null
-
getFilteredData
- Parameters:
type
- type to filter by- Returns:
- filtered data
-
hasData
Tests whether certain data is stored in the database.- Parameters:
type
- type of data to test forname
- name of data to test for- Returns:
- true if the database contains the data, false otherwise
-
insertEvent
Inserts an event into the database.- Parameters:
event
- event to insert
-
getData
Gets AudioData from the database. If the data does not exist it will be created and inserted.- Parameters:
name
- name of data to gettype
- type of data to get- Returns:
- requested data
-
getPiece
Gets AudioPiece from the database. If the piece does not exist it will be created and inserted- Parameters:
name
- name of piece to getdata
- associated data of the piecetype
- type of data to get (must be a piece)- Returns:
- requested piece
-
getEventCount
public int getEventCount()Gets the amount ofevents
stored in the database.- Returns:
- amount of
events
-
getDataCount
public int getDataCount()Gets the amount ofAudioData
-elements stored in this database.- Returns:
- amount of
AudioData
-elements
-
iterator
Needed to implement theIterable
-interface.- Specified by:
iterator
in interfaceIterable<ListeningEvent>
- Returns:
- iterator for the
events
stored in the database
-