Class Receiver

java.lang.Object
sources.receiver.Receiver

public class Receiver extends Object
The Receiver class is responsible for managing the movie collection. It uses MovieCollection to store the movies and MovieCollectionFileReader/MovieCollectionFileWriter to read/write the movies from/to the XML file.
  • Field Details

  • Constructor Details

  • Method Details

    • info

      public String info()
      Returns information about the collection.
      Returns:
      a String containing information about the collection
    • show

      public HashMap<Integer,Movie> show()
      Returns the HashMap of movies in the collection.
      Returns:
      the HashMap of movies in the collection
    • insert

      public void insert(Integer key, String movieName, Integer x, Integer y, long oscarsCount, MovieGenre movieGenre, MpaaRating mpaaRating, String directorName, LocalDateTime birthday, Integer weight, String passportID) throws CollectionKeyException, WrongArgumentException
      Inserts a new movie into the collection.
      Parameters:
      key - the key of the new movie
      movieName - the name of the new movie
      x - the x coordinate of the new movie
      y - the y coordinate of the new movie
      oscarsCount - the number of Oscars the new movie has won
      movieGenre - the genre of the new movie
      mpaaRating - the MPAA rating of the new movie
      directorName - the name of the director of the new movie
      birthday - the birthday of the director of the new movie
      weight - the weight of the director of the new movie
      passportID - the passport ID of the director of the new movie
      Throws:
      CollectionKeyException - if the specified key is already in use
      WrongArgumentException - if any of the arguments are invalid
    • update

      public void update(Integer id, String movieName, Integer x, Integer y, long oscarsCount, MovieGenre movieGenre, MpaaRating mpaaRating, String directorName, LocalDateTime birthday, Integer weight, String passportID) throws CollectionKeyException, WrongArgumentException
      Updates the information of the specified movie in the collection.
      Parameters:
      id - the ID of the movie to be updated
      movieName - the new name of the movie
      x - the new x coordinate of the movie
      y - the new y coordinate of the movie
      oscarsCount - the new number of Oscars the movie has won
      movieGenre - the new genre of the movie
      mpaaRating - the new MPAA rating of the movie
      directorName - the new name of the director of the movie
      birthday - the new birthday of the director of the movie
      weight - the new weight of the director of the movie
      passportID - the new passport ID of the director of the movie
      Throws:
      CollectionKeyException - if the specified ID is not found in the collection
      WrongArgumentException - if any of the arguments are invalid
    • removeKey

      public void removeKey(Integer key) throws CollectionKeyException
      Removes the element with the specified key from the movie collection.
      Parameters:
      key - the key of the element to remove
      Throws:
      CollectionKeyException - if the specified key does not exist in the collection
    • clear

      public void clear()
      Clears the movie collection.
    • save

      public void save()
      Saves the movie collection to an XML file.
    • removeGreater

      public void removeGreater(String movieName, Integer x, Integer y, long oscarsCount, MovieGenre movieGenre, MpaaRating mpaaRating, String directorName, LocalDateTime birthday, Integer weight, String passportID) throws WrongArgumentException
      Removes all elements that are greater than the specified movie from the collection.
      Parameters:
      movieName - the name of the movie to compare
      x - the x-coordinate of the movie to compare
      y - the y-coordinate of the movie to compare
      oscarsCount - the number of Oscars won by the movie to compare
      movieGenre - the genre of the movie to compare
      mpaaRating - the MPAA rating of the movie to compare
      directorName - the name of the movie director to compare
      birthday - the birthdate of the movie director to compare
      weight - the weight of the movie director to compare
      passportID - the passport ID of the movie director to compare
      Throws:
      WrongArgumentException - if any of the specified arguments are invalid
    • replaceIfLowe

      public void replaceIfLowe(Integer key, String movieName, Integer x, Integer y, long oscarsCount, MovieGenre movieGenre, MpaaRating mpaaRating, String directorName, LocalDateTime birthday, Integer weight, String passportID) throws CollectionKeyException, WrongArgumentException
      Replaces the element with the specified key with the specified movie if it is lower than the original element.
      Parameters:
      key - the key of the element to replace
      movieName - the name of the movie to replace the original element with
      x - the x-coordinate of the movie to replace the original element with
      y - the y-coordinate of the movie to replace the original element with
      oscarsCount - the number of Oscars won by the movie to replace the original element with
      movieGenre - the genre of the movie to replace the original element with
      mpaaRating - the MPAA rating of the movie to replace the original element with
      directorName - the name of the movie director to replace the original element with
      birthday - the birthdate of the movie director to replace the original element with
      weight - the weight of the movie director to replace the original element with
      passportID - the passport ID of the movie director to replace the original element with
      Throws:
      CollectionKeyException - if the specified key does not exist in the collection
      WrongArgumentException - if any of the specified arguments are invalid
    • removeLowerKey

      public void removeLowerKey(Integer key)
      Removes all elements with keys lower than the specified key from the movie collection.
      Parameters:
      key - the key to compare with
    • printAscending

      public List<Movie> printAscending()
      Returns a list of movies in ascending order based on their natural order in the movie collection.
      Returns:
      a list of movies in ascending order
    • printDescending

      public List<Movie> printDescending()
      Returns a list of movies in descending order based on their natural order in the movie collection.
      Returns:
      a list of movies in descending order
    • printFieldDescendingOscarsCount

      public List<Movie> printFieldDescendingOscarsCount()
      Returns a list of movies in descending order based on their Oscars count field in the movie collection.
      Returns:
      a list of movies in descending order based on their Oscars count field