org.prx.prp.model.Episode.java Source code

Java tutorial

Introduction

Here is the source code for org.prx.prp.model.Episode.java

Source

//  Copyright (c) 2010 Mahesh Sharma,Matt MacDonald
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.

package org.prx.prp.model;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;

public class Episode {
    private int episodeId;

    public int getEpisodeId() {
        return episodeId;
    }

    public void setEpisodeId(int episodeId) {
        this.episodeId = episodeId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public String getPublished() {
        return published;
    }

    public void setPublished(String published) {
        this.published = published;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getEnclosure() {
        return enclosure;
    }

    public void setEnclosure(String enclosure) {
        this.enclosure = enclosure;
    }

    public Bundle getBundle() {
        Bundle b = new Bundle();
        b.putInt("episode_id", episodeId);
        b.putInt("program_id", programId);
        b.putString("title", title);
        b.putString("summary", summary);
        b.putString("url", url);
        b.putString("published", published);
        b.putString("enclosure", enclosure);
        b.putInt("enclosure_length", enclosureLength);
        return b;

    }

    private int programId;
    private String title;
    private String summary;
    private String published;
    private String url;
    private String enclosure;

    public Episode(int episodeId, int programId, String title, String summary, String published, String url,
            String enclosure, String enclosureType, int enclosureLength) {
        super();
        this.episodeId = episodeId;
        this.programId = programId;
        this.title = title;
        this.summary = summary;
        this.published = published;
        this.url = url;
        this.enclosure = enclosure;
        this.enclosureLength = enclosureLength;
    }

    public Episode(JSONObject c) {
        super();
        try {
            this.episodeId = c.getInt("id");
            this.programId = c.getInt("program_id");
            this.title = c.getString("title");
            this.summary = c.getString("summary");
            this.published = c.getString("published");
            this.url = c.getString("url");
            this.enclosure = c.getString("enclosure");
            c.getString("enclosure_type");
            this.enclosureLength = c.getInt("enclosure_length");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    private int enclosureLength;
}