PlayList.java :  » Google-tech » castcluster » net » chowda » castcluster » Java Open Source

Java Open Source » Google tech » castcluster 
castcluster » net » chowda » castcluster » PlayList.java
package net.chowda.castcluster;

import java.util.List;
import java.util.ArrayList;

/**
 * this class represents playlists in the castcluster object model.
 */
public class PlayList {
    private String id;
    private String name;
    private String description;
    private List<String> urls = new ArrayList<String>();
    private List<VideoSource> sources = null;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void addUrl(String url) {
        if(sources == null) {
            sources = new ArrayList<VideoSource>(10);
        }
        sources.add(VideoProvider.getSourceForCCUrl(url));
        urls.add(url);
    }

    public List<String> getUrls() {
        return urls;
    }

    public void setUrls(List<String> urls) {
        this.urls = urls;
    }

    public List<VideoSource> getSources() {
        if(sources == null) {
            sources = new ArrayList<VideoSource>(10);
            for (String url : urls) {
                sources.add(VideoProvider.getSourceForCCUrl(url));
            }

        }
        return sources;
    }

    public void setSources(List<VideoSource> sources) {
        this.sources = sources;
    }

    public void removeUrl(String videoUrl) {
        urls.remove(videoUrl);
        
        for (int i = 0; i < getSources().size(); i++) {
            VideoSource source = sources.get(i);
            if(videoUrl.equals(source.getCcUrl())) {
                sources.remove(i);
                break;
            }
        }
    }


    public String toString() {
        return "id: " + id + " name: " + name;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.