Package Question8_3

Examples of Question8_3.Song


     * @throws {@link Exception} To signal a problem creating the new song
     * (e.g. a song with that title already exists).
     */
    public static Song createSong(String title) throws Exception {

        Song song = null;
        try {
       
            song = (Song)db.createObject( SongImpl.class.getName(),
                                      OzoneInterface.Public);

            song.setTitle(title);
            allSongs.addSong(title.toUpperCase(), song);

        } catch (Exception e){
            System.out.println("createSong(): something went wrong adding to Ozone.");
            throw e;           
View Full Code Here


     * @return true if successful. False if not found.
     */
    public static boolean deleteSong(String title)  {
        System.out.println("deleteSong <" + title + ">" );

        Song song = allSongs.deleteSong(title.toUpperCase());
      
        return  (song != null);
    }
View Full Code Here

     *
     * @return A proxy object for the requested Song object, or null if not found.
     */
    public static Song songForTitle(String title){

        Song song = null;
        try {
            song = allSongs.findSong(title.toUpperCase());

            if (song == null) {
                System.out.println("Song not found by title <" + title + ">" );
View Full Code Here

     *
     * @return A proxy object for the requested Song object, or null if not found.
     */
    public static Song songForHandle(String handle) {

        Song song = null;
        try {
       
            song = (Song)db.objectForHandle(handle);

            if (song == null) {
View Full Code Here

    /**
     * Adds a Song to the SongCollection
     *
     */
    public void addSong(String title, Song song) throws Exception {
        Song old = (Song) songMap.put(title, song);
        if (old != null) {
            System.out.println("SongCollection.addSong: song already exists, not added : " + title);
            songMap.put(old.getTitle(), old);

            throw new  Exception ("Duplicate song title");
        }
    }
View Full Code Here

    /**
     * Deletes a Song from the SongCollection and database
     *
     */
    public Song deleteSong(String  title) {
        Song song = null;
        try{
            song = (Song)songMap.remove(title);
            if (song != null){
                database().deleteObject(song);
            }
View Full Code Here

        System.out.println( " PrintAllSongs");
    }           
       

    private static void addSong(String title, String author, String publisher, String copyright) throws Exception{
        Song song = SongServices.createSong(title);
        song.setAuthor(author);
        song.setPublisher(publisher);
        song.setCopyright(copyright);
        printSong(song);

    }
View Full Code Here

    }
    private static void removeSong(String title){
        SongServices.deleteSong(title);
    }
    private static void printSongForTitle(String title){
        Song song = SongServices.songForTitle(title);
        printSong(song);
    }
View Full Code Here

    private static void printSongForTitle(String title){
        Song song = SongServices.songForTitle(title);
        printSong(song);
    }
    private static void printSongForHandle(String handle){
        Song song = SongServices.songForHandle(handle);
        printSong(song);
    }
View Full Code Here

    private static void printAllSongs(){
        Collection songs = SongServices.getAllSongs().getAllSongs().values();
        System.out.println(songs.size() + " songs in collection.");

        Iterator it = songs.iterator();
        Song song;
        while (it.hasNext()){
            song = (Song)it.next();
            printSong(song);
        }
           
View Full Code Here

TOP

Related Classes of Question8_3.Song

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.